Draft
Conversation
…tralExperts
- Replace Block/mixer abstraction with NemotronH{Dense,Sparse}DecoderLayer
holding exactly one of self.mamba / self.self_attn / self.mlp|block_sparse_moe
based on layer_type, matching the standard decoder-layer pattern.
- Pass attention_mask (4D causal) + mamba_attention_mask (raw 2D) uniformly
to every layer instead of pre-dispatching per layer type.
- NemotronHSparseExperts now inherits from MixtralExperts (non-gated variant).
- Drop moe_latent_size from sparse config and the matching latent projections —
the field is not present in the released Nemotron-3 config.
- Replace the single-class `if layer_type == ...` decoder layer with two
dedicated classes per architecture, mirroring Jamba's pattern:
`NemotronH{Dense,Sparse}{Mamba,Attention}DecoderLayer`, each containing
norm -> mixer -> residual -> norm -> ffn -> residual.
- `NemotronHDenseMLP` now inherits `NemotronMLP`; dense/sparse Models and
ForCausalLM inherit from the Jamba stack via the modular converter.
- Collapse the per-char `hybrid_override_pattern` into a per-decoder-layer
`layer_types` list: each `M`/`*` becomes one layer (with mlp or moe FFN
tail), `-` / `E` are absorbed. `num_hidden_layers` is now the count of
logical decoder layers (not raw pattern characters).
- Sparse MoE experts continue to inherit from MixtralExperts (non-gated
variant), MoE block from DeepseekV3MoE.
- Tests updated for the new layer structure; BC dispatcher still routes
`NemotronHConfig(hybrid_override_pattern=...)` to the right subclass.
…e-sparse # Conflicts: # src/transformers/models/nemotron_h/configuration_nemotron_h.py # src/transformers/models/nemotron_h/modeling_nemotron_h.py # src/transformers/models/nemotron_h/modular_nemotron_h.py
Rewrite the per-model test files to inherit `CausalLMModelTester` / `CausalLMModelTest`
(the LLMTester base), which drastically shrinks the boilerplate and gives us
the standard ModelTester / Generation / Pipeline / Training / TensorParallel
mixin coverage. Override only the hybrid-cache and attention-count specifics:
- `test_attention_outputs` re-counted from `hybrid_override_pattern.count("*")`.
- Hybrid cache / continue-from-cache / single-layer tests skipped with reasons.
(`use_experts_implementation(has_gate=False)` is only used by
`nemotron_h_sparse` — no other model in the library uses it, so
`NemotronHSparseExperts` keeps inheriting from `MixtralExperts`.)
…split - `modeling_nemotron_h.py` dispatcher: suppress TRF009 (cross-model imports are the whole point of this BC shim) and drop the explicit `trust_remote_code=` kwarg (TRF014). - `configuration_nemotron_h.py`: wire `@auto_docstring(checkpoint=...)` so `check_config_docstrings` finds a Hub model link. - Add stub `tests/models/nemotron_h/test_modeling_nemotron_h.py` covering the BC dispatcher (config + model + ForCausalLM) and register it in `TEST_FILES_WITH_NO_COMMON_TESTS` (the dispatcher has no model classes for the standard common-test machinery). - Add model docs for `NemotronHDense` / `NemotronHSparse`, update the TOC, and drop the `- forward` autodoc lines for the BC dispatcher classes (they route via `__new__`, no `forward` of their own). - Allow-list the small set of config attributes inherited from the hub `config.json` format that the split architectures no longer consume.
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto, nemotron_h, nemotron_h_dense, nemotron_h_sparse |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes # (issue)
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.
PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.
This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read
CONTRIBUTING.md.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.