extend modelbuilder to build Olmo3, SmolLM3 and other models - #2078
extend modelbuilder to build Olmo3, SmolLM3 and other models#2078Xavier Dupré (xadupre) wants to merge 93 commits into
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR expands the Python modelbuilder to cover additional HF architectures (e.g., OLMo3, SmolLM3, Qwen3/Qwen3.5, Nemotron-H, Gemma3) and adds a comprehensive “fast” test suite that builds tiny random-weight models offline and validates ONNX vs PyTorch (and/or validates export output). It also adds a compatibility shim to post-process genai_config.json for transformers>=5 generation defaults.
Changes:
- Add many new offline “fast” unit tests that export minimal random-weight models and compare ORT outputs against PyTorch (prefill/decode and some greedy generation).
- Extend/fix multiple builder implementations (OLMo*, SmolLM, Nemotron/Nemotron-H, Gemma3, Ernie, GPT-OSS, etc.) to match architecture quirks and transformers v4/v5 config differences.
- Add
fix_genai_configutility + tests, relax pytest--test_modelsoption requirement, and introduce a GitHub Actions workflow for fast tests.
Reviewed changes
Copilot reviewed 52 out of 53 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/python/models/fast/test_random_whisper.py | Adds offline Whisper encoder/decoder export + ORT vs PyTorch discrepancy checks. |
| test/python/models/fast/test_random_smollm3.py | Adds SmolLM3 random-weight discrepancy tests and greedy generation checks. |
| test/python/models/fast/test_random_qwen3_vl.py | Adds Qwen3-VL text-path discrepancy tests (transformers>=5 guarded). |
| test/python/models/fast/test_random_qwen3_5.py | Adds Qwen3.5 full-attention execution test + hybrid build validation (transformers>=5). |
| test/python/models/fast/test_random_qwen3_0_6b.py | Adds Qwen3 random-weight discrepancy and greedy generation tests. |
| test/python/models/fast/test_random_qwen2_5_vl.py | Adds Qwen2.5-VL text-path discrepancy tests (transformers>=5 guarded). |
| test/python/models/fast/test_random_phi4mm.py | Adds Phi4MM synthetic-weight build + ORT vs PyTorch comparisons (uses PEFT LoRA). |
| test/python/models/fast/test_random_phi3.py | Adds Phi-3 random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_phi.py | Adds Phi-2 random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_olmo3.py | Adds OLMo3 random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_olmo2.py | Adds OLMo2 random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_olmo.py | Adds OLMo (v1) random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_nemotron.py | Adds Nemotron random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_nemotron_h.py | Adds Nemotron-H random-weight discrepancy + greedy generation tests (transformers>=5 guarded). |
| test/python/models/fast/test_random_granite.py | Adds Granite random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_random_gemma3.py | Adds Gemma3 random-weight discrepancy + greedy generation tests (transformers>=5 guarded). |
| test/python/models/fast/test_random_gemma.py | Adds Gemma random-weight discrepancy + greedy generation tests. |
| test/python/models/fast/test_onnx_generate.py | Adds unit tests for ONNX greedy generation helper (no-cache and KV-cache paths). |
| test/python/models/fast/test_llama_attention_discrepancies.py | Adds attention-only Llama export + numeric discrepancy tests. |
| test/python/models/fast/test_fix_genai_config.py | Adds tests validating fix_genai_config behavior for null generation defaults. |
| test/python/models/fast/test_check_extra_options.py | Adds tests for extra_options parsing/validation behavior. |
| test/python/conftest.py | Makes --test_models optional for pytest runs. |
| src/python/py/models/genai_config_utils.py | Introduces fix_genai_config to fill null search defaults for transformers>=5. |
| src/python/py/models/builders/smollm.py | Fixes per-layer RoPE enable/disable handling for SmolLM. |
| src/python/py/models/builders/phi.py | Minor formatting tweak around position_ids reformatting naming. |
| src/python/py/models/builders/olmo.py | Adds OLMo2/OLMo3 builders + OLMo v1 LayerNorm handling + OLMo2/3 q/k norm + post-norm residual flow. |
| src/python/py/models/builders/nemotron.py | Adds Nemotron-H builder and fixes Nemotron epsilon handling. |
| src/python/py/models/builders/internlm.py | Formatting/quoting cleanup (no apparent logic change in diff shown). |
| src/python/py/models/builders/gptoss.py | Fixes RoPE cache inv_freq math and tightens some style/robustness in bias combining. |
| src/python/py/models/builders/gemma.py | Improves Gemma3 RoPE parameter handling (v4/v5) and adds conditional-generation load_weights path. |
| src/python/py/models/builders/ernie.py | Patches rope_theta extraction from rope_parameters for Ernie4.5 configs. |
| src/python/py/models/builders/init.py | Re-exports fix_genai_config and narrows __all__. |
| .gitignore | Ignores dump_models/ and stats/ produced by fast tests. |
| .github/workflows/modelbuilder_fast_tests.yml | Adds a GitHub Actions workflow to run fast modelbuilder tests across transformers versions. |
…n overriding method' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
… in attention test Agent-Logs-Url: https://github.com/microsoft/onnxruntime-genai/sessions/76ce540d-7d1c-44e8-9035-a1230aeaaddd Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
…flict Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
|
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
I assume the MacOS pipeline is failing because of : I removed it. I used it to install onnxruntime nightly. I hope that's the issue because I did not see many successful MacOS jobs lately. |
|
Copilot resolve the merge conflicts in this pull request |
…(add HunyuanDenseV1 support) Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
|
Copilot resolve the merge conflicts in this pull request |
…5MoE and VideoChatFlash support) Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Done in d7b7be8. Resolved conflicts in |
|
Copilot explain why CAPITests.EndToEndPhiEOSPAD is failing |
The What the test does: It runs Phi2 inference on WebGPU with input The actual failure (from The generated text was Why this PR is not the cause:
Root cause: The hardcoded expected token IDs were recorded on a specific GPU/driver configuration. On the WebGPU execution provider, floating-point computation can differ between GPU hardware or driver versions in the self-hosted runner pool, producing different token IDs from a greedy decode even with identical code. The workflow was re-run 3 times ( This is a pre-existing flakiness in the WebGPU test that predates this PR. |
|
Is this PR still relevant? Could we update it? |
We can leave it open for now. I will update it. |
Uh oh!
There was an error while loading. Please reload this page.