Repository navigation
[OMNIML-6076] [13/21] Describe expert parallelism in the model specs #2746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shengliangxu
wants to merge
23
commits into
shengliangx/hfep-9b-ep-load-routing
from
shengliangx/hfep-9-ep-model-specs
+835
−41
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
77ce43b
Describe expert parallelism in the model specs
shengliangxu e2d9883
Stop threading keep_compressed through apply_distributed_support
shengliangxu 7412089
Skip the EP spec tests without transformers
shengliangxu 0b9e776
Refuse expert-parallel PTQ for GPT-OSS until its experts can be exported
shengliangxu 478807e
Add the Llama-4 and MiniMax-M3 expert-parallel adapters
shengliangxu b04c1a7
Refuse Llama-4 expert parallelism and drop the MiniMax-M3 adapter
shengliangxu 9234b4d
Drop Nemotron-H's expert-parallel style, which the loader never used
shengliangxu 9c2b71c
Record that transformers ships NemotronH-Omni from 5.18
shengliangxu 16d013e
Cite the expert-parallel loader where it lives, in model_load_utils
shengliangxu 83be9cb
Apply the model spec before deciding and loading expert-parallel
shengliangxu a621d1d
Apply the model spec on every rank as rank 0 decided
shengliangxu f42ac0a
Refuse a whole-on-every-rank MoE whose plan only its spec supplies
shengliangxu ce1be23
Let a spec state the expert plan its prepare attaches
shengliangxu 755eb54
Point an MoE whose spec refuses expert parallelism at FSDP2 alone
shengliangxu 9411438
Test on two real ranks that every rank applies the spec as rank 0 dec…
shengliangxu 9844a83
Import the spec-plan test's modules at module scope
shengliangxu c2fbb79
Trim the model-spec EP tests: drop what the applier tests cover
shengliangxu 37e3877
List EPSpec in the model specs' public API
shengliangxu 6e28865
Read an expert-parallel load's config with the Hub options too
shengliangxu c11dd7b
Date the nemotron_h_omni spec package 2026, as LICENSE_HEADER does
shengliangxu 3abacc2
Prepare a config passed with a handed-in expert-parallel plan
shengliangxu 84c6795
Refuse what a model's spec refuses for a config handed in with its plan
shengliangxu 09817e9
Name the way around expert parallelism when a model is below its tran…
shengliangxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """llama4_text specs (HF model type ``llama4_text``).""" | ||
|
|
||
| from . import specs |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Llama-4 text-only specs (HF model type ``llama4_text``). | ||
|
|
||
| The same architecture as ``llama4`` reached through ``Llama4ForCausalLM``, with its own | ||
| ``base_model_ep_plan`` on the root config, so it is refused expert parallelism the same way. | ||
| """ | ||
|
|
||
| from ..llama4.specs import EP_UNSUPPORTED | ||
| from ..specs import EPSpec, ModelSpec, register | ||
|
|
||
| __all__: list[str] = [] | ||
|
|
||
| register( | ||
| ModelSpec( | ||
| model_type="llama4_text", | ||
| min_transformers_version="5.5", | ||
| ep_spec=EPSpec(unsupported=EP_UNSUPPORTED), | ||
| ) | ||
| ) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """minimax_m3_vl specs (HF model type ``minimax_m3_vl``).""" | ||
|
|
||
| from . import specs |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """MiniMax-M3 specs (HF model type ``minimax_m3_vl``). | ||
|
|
||
| transformers ships everything M3 needs to run expert-parallel: its MoE block calls the experts with | ||
| the router's top-k, its experts dispatch through the experts interface, and its text config carries a | ||
| ``base_model_ep_plan``. The generic all-to-all transport takes over unchanged. | ||
| """ | ||
|
|
||
| from ..specs import EPSpec, ModelSpec, register | ||
|
|
||
| __all__: list[str] = [] | ||
|
|
||
| register( | ||
| ModelSpec( | ||
| model_type="minimax_m3_vl", | ||
| min_transformers_version="5.13", | ||
| ep_spec=EPSpec(requires_transformers="5.13"), | ||
| ) | ||
| ) |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| """NemotronH-Omni specs (HF model type ``nemotron_h_omni``).""" | ||
|
|
||
| from . import specs |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| """NemotronH-Omni specs (HF model type ``nemotron_h_omni``). | ||
|
|
||
| The Omni VLM's language sub-model is a native NemotronH, so its MoE facts are NemotronH's. | ||
| What differs is where the expert-parallel plan has to be attached: on the nested ``llm_config``, | ||
| not the VLM root. transformers aggregates each sub-model's plan up to the root WITH its module | ||
| prefix, so a plan on ``llm_config`` surfaces as ``language_model.<base>.layers.*`` and matches the | ||
| real parameter paths -- while a plan on the top config reaches no expert at all. | ||
| """ | ||
|
|
||
| from ..nemotron_h.specs import BASE_MODEL_EP_PLAN | ||
| from ..specs import EPSpec, ModelSpec, register | ||
|
|
||
| __all__: list[str] = [] | ||
|
|
||
| register( | ||
| ModelSpec( | ||
| model_type="nemotron_h_omni", | ||
| # transformers ships the Omni VLM itself from 5.18. Expert parallelism still runs on the | ||
| # checkpoint's own code (``trust_remote_code=True``), whose sub-model config is the | ||
| # ``llm_config`` the plan below targets; transformers' port names it ``text_config``. | ||
| min_transformers_version="5.18", | ||
| ep_spec=EPSpec( | ||
| base_model_ep_plan=BASE_MODEL_EP_PLAN, | ||
| plan_config_attr="llm_config", | ||
| ), | ||
| ) | ||
| ) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.