Skip to content

fix(model): default MODEL_CONFIG_CLASS to None and opt in per family - #6305

Merged
cuichenx merged 5 commits into
NVIDIA-NeMo:mainfrom
jayzuccarelli:fix/model-config-reject-unmigrated
Oct 13, 2026
Merged

cuichenx merged 5 commits into
NVIDIA-NeMo:mainfrom
jayzuccarelli:fix/model-config-reject-unmigrated

Conversation

@jayzuccarelli

@jayzuccarelli jayzuccarelli commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

Makes the builder-backed config path opt-in per model family. Builder calls for families that have not migrated now raise instead of returning a wrong config, and the provider path no longer tells those families to switch.

Every bridge used to inherit MODEL_CONFIG_CLASS = BridgeGPTModelConfig, but only the migrated families map their HF config into it. For the rest, get_model_config() returned generic defaults and to_megatron_provider() warned users toward it.

Changelog

  • MegatronModelBridge.MODEL_CONFIG_CLASS now defaults to None. Migrated families opt in explicitly: LlamaBridge and Qwen3Bridge set BridgeGPTModelConfig; MuseGlimmerBridge already sets MuseGlimmerModelConfig. Subclasses of a migrated bridge inherit the opt-in.
  • hf_config_to_model_config() rejects unmigrated families through the existing MODEL_CONFIG_CLASS is None branch. The error names the bridge and points to AutoBridge.to_megatron_provider().
  • provider_bridge() emits the deprecation FutureWarning only when MODEL_CONFIG_CLASS is set. The provider path itself is unchanged.
  • Removed the _has_model_config_mapping() hook-override guard from the first revision.
  • Removed the explicit MODEL_CONFIG_CLASS = None on GLM5Bridge and BagelBridge, which is now the default.
  • Updated the class comment, docstrings and docs/bridge-guide.md to describe the opt-in default.
  • Tests: test_bridge_can_explicitly_disable_model_config is parametrized over every registered bridge (64). Unmigrated bridges must reject the builder path and have no config mapping; opted-in bridges must provide one; a subclass that sets None is rejected. Added an inheritance test and a provider test on Qwen2 (unmigrated) that asserts no FutureWarning. The Qwen3-based tests are gone since Qwen3 is migrated.

Testing

CPU only, no TransformerEngine (stubbed locally). Run against unmodified main, the updated test file gives 65 failed, 9 passed, 1 skipped; with this change it gives 74 passed, 1 skipped.

Unchanged between main and this branch: models/llama 44 passed, models/qwen 118 passed, models/glm_moe_dsa 25 passed, models/bagel conversion/checkpoint/dependencies 16 passed and 1 skipped, test_gpu_backend.py 21 passed, test_vlm_generation.py 7 passed, test_llama_recipes.py 105 passed, test_llama_perf_recipes.py 16 passed, test_qwen3_recipes.py 24 passed. test_auto_bridge.py: 97 passed, with the same 5 failures before and after locally (they need TE or a writable /tmp/output). The Muse Glimmer tests need real TransformerEngine and were not run locally; no Muse Glimmer file changed. ruff check and format clean.

Additional Information

AI-assisted (Claude Code); I reviewed the change and ran the tests.

…apping

# What does this PR do ?

Builder calls for families that have not migrated their config mapping now raise instead of returning a wrong config, and the provider path no longer tells those families to switch.

Every bridge inherits MODEL_CONFIG_CLASS = BridgeGPTModelConfig, but only Llama and Muse Glimmer map their HF config into it. For the rest, get_model_config() returned generic defaults (Qwen3: learned_absolute position embeddings, linear bias on, no QK norm), and to_megatron_provider() warned users toward it.

# Changelog

- Add MegatronModelBridge._has_model_config_mapping(): true when a bridge overrides hf_config_to_model_config_kwargs() or hf_config_to_model_config().
- hf_config_to_model_config() raises ModelConfigNotSupportedError naming the bridge and pointing to AutoBridge.to_megatron_provider() when there is no mapping.
- provider_bridge() only emits the deprecation FutureWarning for families with a mapping. The provider path itself is unchanged.
- Two unit tests in test_gpt_model_config.py (Qwen3 as the unmigrated family).

This is a guard on the hook overrides; the alternative is flipping the MODEL_CONFIG_CLASS default to None and opting in per family. Happy to switch if you prefer that.

# Testing

CPU only. Both new tests fail on main (DID NOT RAISE, and the FutureWarning) and pass with this change. test_gpt_model_config.py, llama/test_llama_bridge.py and qwen/test_qwen3_bridge.py: 74 passed, 1 skipped. Llama builder tests in test_auto_bridge.py still pass; the rest of that file has the same failures before and after locally (no TE/modelopt). ruff check and format clean.

# Additional Information

- Fixes NVIDIA-NeMo#6242

AI-assisted (Claude Code); I reviewed the change and ran the tests.

Signed-off-by: Eugenio "Jay" Zuccarelli <11176606+jayzuccarelli@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@jayzuccarelli
jayzuccarelli marked this pull request as ready for review October 3, 2026 02:51
@cuichenx cuichenx added bug Something isn't working area:model Model implementations and HF bridge logic needs-review PR is ready for code review and waiting on a reviewer labels Oct 3, 2026
@jayzuccarelli

Copy link
Copy Markdown
Contributor Author

@cuichenx when you have time, could you take a look at this one? #6347 (the follow-up to #6236 for the Mamba and GDN mappings) is also ready, and I just merged main into it to clear a conflict.

@cuichenx cuichenx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"flipping the MODEL_CONFIG_CLASS default to None", i think i prefer this approach slightly, one because in case there's a two level inheritance of model configs in the future (e.g. different muse glimmer model sizes) and two because it would make testing easier, the existing test_bridge_can_explicitly_disable_model_config can be modified to cover all models

Comment thread tests/unit_tests/models/test_gpt_model_config.py Outdated
…ct-unmigrated

Signed-off-by: Eugenio "Jay" Zuccarelli <11176606+jayzuccarelli@users.noreply.github.com>
Make the builder-backed config path opt-in. MegatronModelBridge.MODEL_CONFIG_CLASS
now defaults to None, and the migrated families (Llama, Qwen3, Muse Glimmer) set
it explicitly. Unmigrated families reject get_model_config() through the existing
MODEL_CONFIG_CLASS is None branch, and provider_bridge() only emits the
deprecation FutureWarning for opted-in families.

This replaces the _has_model_config_mapping() hook-override guard. The explicit
MODEL_CONFIG_CLASS = None on GLM5Bridge and BagelBridge is now the default and
is removed.

test_bridge_can_explicitly_disable_model_config is parametrized over every
registered bridge.

Signed-off-by: Eugenio "Jay" Zuccarelli <11176606+jayzuccarelli@users.noreply.github.com>
…ge test

Signed-off-by: Eugenio "Jay" Zuccarelli <11176606+jayzuccarelli@users.noreply.github.com>
@jayzuccarelli jayzuccarelli changed the title fix(model): reject get_model_config() for families without a config mapping fix(model): default MODEL_CONFIG_CLASS to None and opt in per family Oct 11, 2026
@jayzuccarelli

Copy link
Copy Markdown
Contributor Author

@cuichenx thanks, switched to that approach. MODEL_CONFIG_CLASS now defaults to None on MegatronModelBridge, and the migrated families opt in: LlamaBridge and Qwen3Bridge set BridgeGPTModelConfig, and MuseGlimmerBridge already sets its own config. The hook-override guard is removed, so unmigrated families are rejected by the existing None branch, and the provider deprecation warning is gated on the same attribute. Subclasses of a migrated bridge inherit the opt-in.

test_bridge_can_explicitly_disable_model_config is now parametrized over every registered bridge. It checks that unmigrated bridges reject get_model_config() and that opting in and providing a config mapping always go together. One exception: MuseGlimmerBridge overrides hf_config_to_model_config() entirely and does not read MODEL_CONFIG_CLASS, so the subclass-sets-None check skips it. I left that behavior unchanged.

I also removed the explicit MODEL_CONFIG_CLASS = None on GLM5Bridge and BagelBridge since it is now the default. I can restore those lines if you prefer them as documentation.

@cuichenx cuichenx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, LGTM

@cuichenx

Copy link
Copy Markdown
Contributor

/ok to test 0ef959a

@cuichenx cuichenx added ready-to-merge PR is approved, current, and only waiting for CI to pass before merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automatic Claude reviews have been retired. To request a pull-request review, post a comment containing:

/review

Add model=claude to use a Claude reviewer (the default is model=codex). mode=light|strict selects the review depth; for example, /review model=claude mode=strict. Comment /review help for all options.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor

The link check failed on retired documentation targets, which are now corrected on main. Could you bring in current main and rerun validation? The Qwen3 review thread also looks addressed and can be resolved.

…ct-unmigrated

Signed-off-by: Eugenio "Jay" Zuccarelli <11176606+jayzuccarelli@users.noreply.github.com>
@jayzuccarelli

Copy link
Copy Markdown
Contributor Author

@aroshanghias-nvd done: merged current main (no conflicts, same 8 files in the diff) and resolved the Qwen3 thread. CI is re-running.

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor

/ok to test 69e2521

@cuichenx
cuichenx enabled auto-merge (squash) October 13, 2026 00:16
@cuichenx
cuichenx merged commit 1234500 into NVIDIA-NeMo:main Oct 13, 2026
84 checks passed
@jayzuccarelli
jayzuccarelli deleted the fix/model-config-reject-unmigrated branch October 13, 2026 13:08
kamran-nvidia added a commit that referenced this pull request Oct 14, 2026
…configs

After #6305, MODEL_CONFIG_CLASS defaults to None and each family opts in.
Set MODEL_CONFIG_CLASS = BridgeGPTModelConfig on the bridges this PR
migrates, matching Qwen3 and Llama, and assert it in their tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
kamran-nvidia added a commit that referenced this pull request Oct 14, 2026
…configs

After #6305, MODEL_CONFIG_CLASS defaults to None and each family opts in.
Set MODEL_CONFIG_CLASS = BridgeGPTModelConfig on the bridges this PR
migrates, matching Qwen3 and Llama, and assert it in their tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
kamran-nvidia added a commit that referenced this pull request Oct 14, 2026
…configs

After #6305, MODEL_CONFIG_CLASS defaults to None and each family opts in.
Set MODEL_CONFIG_CLASS = BridgeGPTModelConfig on the bridges this PR
migrates, matching Qwen3 and Llama, and assert it in their tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
kamran-nvidia added a commit that referenced this pull request Oct 14, 2026
…configs

After #6305, MODEL_CONFIG_CLASS defaults to None and each family opts in.
Set MODEL_CONFIG_CLASS = BridgeGPTModelConfig on the bridges this PR
migrates, matching Qwen3 and Llama, and assert it in their tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>

This branch was successfully deployed

1 active deployment
test — 69e25210 Deployed Oct 12, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #22793
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:model Model implementations and HF bridge logic bug Something isn't working community-request ready-to-merge PR is approved, current, and only waiting for CI to pass before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_model_config() returns incorrect configs for families without a config mapping

3 participants