From 93a32bf774cc2b3a4623fab07229512fe053ad13 Mon Sep 17 00:00:00 2001 From: Shengliang Xu Date: Mon, 28 Sep 2026 23:33:38 +0000 Subject: [PATCH 1/3] Add model specs for llama4, qwen3_vl_moe, falcon, step3p5 and step3p7 These model types have model-specific PTQ support but no ModelSpec. Register one for each, recording only facts checked against transformers 4.57 and 5.14: - llama4, qwen3_vl_moe: fused MoE layout (gate_up_proj/down_proj), no gate/up pair, grouped export off. Both blocks were already detected as MoE, so this is data only. - falcon: dense, no sections. - step3p5, step3p7: remote code, no MoESpec. Step's expert projections sit on the MoE MLP itself with no experts container; declaring the block would send AWQ export into get_experts_list, which does not support that layout. Signed-off-by: Shengliang Xu --- modelopt/torch/models/__init__.py | 5 +++ modelopt/torch/models/falcon/__init__.py | 19 ++++++++++ modelopt/torch/models/falcon/specs.py | 24 +++++++++++++ modelopt/torch/models/llama4/__init__.py | 19 ++++++++++ modelopt/torch/models/llama4/specs.py | 36 +++++++++++++++++++ .../torch/models/qwen3_vl_moe/__init__.py | 19 ++++++++++ modelopt/torch/models/qwen3_vl_moe/specs.py | 36 +++++++++++++++++++ modelopt/torch/models/step3p5/__init__.py | 19 ++++++++++ modelopt/torch/models/step3p5/specs.py | 26 ++++++++++++++ modelopt/torch/models/step3p7/__init__.py | 19 ++++++++++ modelopt/torch/models/step3p7/specs.py | 27 ++++++++++++++ tests/unit/torch/models/test_model_specs.py | 10 ++++++ 12 files changed, 259 insertions(+) create mode 100644 modelopt/torch/models/falcon/__init__.py create mode 100644 modelopt/torch/models/falcon/specs.py create mode 100644 modelopt/torch/models/llama4/__init__.py create mode 100644 modelopt/torch/models/llama4/specs.py create mode 100644 modelopt/torch/models/qwen3_vl_moe/__init__.py create mode 100644 modelopt/torch/models/qwen3_vl_moe/specs.py create mode 100644 modelopt/torch/models/step3p5/__init__.py create mode 100644 modelopt/torch/models/step3p5/specs.py create mode 100644 modelopt/torch/models/step3p7/__init__.py create mode 100644 modelopt/torch/models/step3p7/specs.py diff --git a/modelopt/torch/models/__init__.py b/modelopt/torch/models/__init__.py index fef532fde08..2e6b98cf133 100644 --- a/modelopt/torch/models/__init__.py +++ b/modelopt/torch/models/__init__.py @@ -70,6 +70,7 @@ deepseek, deepseek_v3, deepseek_v4, + falcon, gemma, gemma2, gemma3, @@ -77,6 +78,7 @@ gemma4_text, gpt_oss, llama, + llama4, minimax, mixtral, phimoe, @@ -87,4 +89,7 @@ qwen3_5_moe, qwen3_moe, qwen3_next, + qwen3_vl_moe, + step3p5, + step3p7, ) diff --git a/modelopt/torch/models/falcon/__init__.py b/modelopt/torch/models/falcon/__init__.py new file mode 100644 index 00000000000..c08e11541cb --- /dev/null +++ b/modelopt/torch/models/falcon/__init__.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + + +"""Per-model specs for HF model type ``falcon``.""" + +from . import specs diff --git a/modelopt/torch/models/falcon/specs.py b/modelopt/torch/models/falcon/specs.py new file mode 100644 index 00000000000..4dfbbd2ffe7 --- /dev/null +++ b/modelopt/torch/models/falcon/specs.py @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + +"""Falcon specs (HF model type ``falcon``).""" + +from ..specs import ModelSpec, register + +__all__: list[str] = [] + +# Dense, and nothing model-specific for export. Older remote-code Falcon checkpoints +# (RWForCausalLM) report other model types and are handled by the HF quantization plugin alone. +register(ModelSpec(model_type="falcon", min_transformers_version="4.57")) diff --git a/modelopt/torch/models/llama4/__init__.py b/modelopt/torch/models/llama4/__init__.py new file mode 100644 index 00000000000..e9fd7824c40 --- /dev/null +++ b/modelopt/torch/models/llama4/__init__.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + + +"""Per-model specs for HF model type ``llama4``.""" + +from . import specs diff --git a/modelopt/torch/models/llama4/specs.py b/modelopt/torch/models/llama4/specs.py new file mode 100644 index 00000000000..70a7779883d --- /dev/null +++ b/modelopt/torch/models/llama4/specs.py @@ -0,0 +1,36 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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 specs (HF model type ``llama4``).""" + +from ..specs import ModelSpec, MoESpec, register + +__all__: list[str] = [] + +# Llama4TextExperts is fused: one module holding 3-D gate_up_proj and down_proj +# parameters, run through torch.bmm. There is no (gate, up) pair left to fuse, and the +# grouped-export path (get_experts_list) does not apply. The block also carries a +# shared_expert MLP, which is an ordinary dense MLP, not part of this layout. +register( + ModelSpec( + model_type="llama4", + min_transformers_version="4.57", + moe_spec=MoESpec( + block_names=("Llama4TextMoe",), + expert_linear_names=("gate_up_proj", "down_proj"), + fused_expert_names=True, + ), + ) +) diff --git a/modelopt/torch/models/qwen3_vl_moe/__init__.py b/modelopt/torch/models/qwen3_vl_moe/__init__.py new file mode 100644 index 00000000000..e99407906be --- /dev/null +++ b/modelopt/torch/models/qwen3_vl_moe/__init__.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + + +"""Per-model specs for HF model type ``qwen3_vl_moe``.""" + +from . import specs diff --git a/modelopt/torch/models/qwen3_vl_moe/specs.py b/modelopt/torch/models/qwen3_vl_moe/specs.py new file mode 100644 index 00000000000..853beae743b --- /dev/null +++ b/modelopt/torch/models/qwen3_vl_moe/specs.py @@ -0,0 +1,36 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + +"""Qwen3-VL-MoE specs (HF model type ``qwen3_vl_moe``).""" + +from ..specs import ModelSpec, MoESpec, register + +__all__: list[str] = [] + +# Qwen3VLMoeTextExperts is fused on every supported transformers: 3-D gate_up_proj and +# down_proj parameters (transposed before 5.12, standard layout from 5.12 on). Before 5.12 +# the PTQ wrapper unrolls them into gate_proj/up_proj/down_proj ModuleLists (see +# quantization/plugins/huggingface.py); that rewrite is not iterable per expert, so no export path groups it. +register( + ModelSpec( + model_type="qwen3_vl_moe", + min_transformers_version="4.57", + moe_spec=MoESpec( + block_names=("Qwen3VLMoeTextSparseMoeBlock",), + expert_linear_names=("gate_up_proj", "down_proj"), + fused_expert_names=True, + ), + ) +) diff --git a/modelopt/torch/models/step3p5/__init__.py b/modelopt/torch/models/step3p5/__init__.py new file mode 100644 index 00000000000..e5c436ddc2d --- /dev/null +++ b/modelopt/torch/models/step3p5/__init__.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + + +"""Per-model specs for HF model type ``step3p5``.""" + +from . import specs diff --git a/modelopt/torch/models/step3p5/specs.py b/modelopt/torch/models/step3p5/specs.py new file mode 100644 index 00000000000..541bdfbf42c --- /dev/null +++ b/modelopt/torch/models/step3p5/specs.py @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + +"""Step-3.5 specs (HF model type ``step3p5``).""" + +from ..specs import ModelSpec, register + +__all__: list[str] = [] + +# No MoESpec: the routed experts are expert-indexed MoELinear projections on the MoE MLP +# itself, with no `experts` container, and are exported by the MoELinear handler rather +# than through the MoE-block lookups. Declaring the block would make is_moe claim it and +# send AWQ export into get_experts_list, which does not support this layout. +register(ModelSpec(model_type="step3p5", modeling_source="remote_code")) diff --git a/modelopt/torch/models/step3p7/__init__.py b/modelopt/torch/models/step3p7/__init__.py new file mode 100644 index 00000000000..1f34f24c93b --- /dev/null +++ b/modelopt/torch/models/step3p7/__init__.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + + +"""Per-model specs for HF model type ``step3p7``.""" + +from . import specs diff --git a/modelopt/torch/models/step3p7/specs.py b/modelopt/torch/models/step3p7/specs.py new file mode 100644 index 00000000000..9cc9afdaa10 --- /dev/null +++ b/modelopt/torch/models/step3p7/specs.py @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 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. + +"""Step-3.7 specs (HF model type ``step3p7``). + +Shares Step-3.5's architecture; its PTQ modeling (in the HF quantization plugin) +matches every Step revision. +""" + +from ..specs import ModelSpec, register + +__all__: list[str] = [] + +# No MoESpec, for the same reason as step3p5 (see step3p5/specs.py). +register(ModelSpec(model_type="step3p7", modeling_source="remote_code")) diff --git a/tests/unit/torch/models/test_model_specs.py b/tests/unit/torch/models/test_model_specs.py index 3e77844f91a..f06f72dcf5e 100644 --- a/tests/unit/torch/models/test_model_specs.py +++ b/tests/unit/torch/models/test_model_specs.py @@ -552,6 +552,7 @@ def test_fused_experts_shortcut_ignores_unrelated_attributes(): ("gate_proj", "up_proj"), ), ("gpt_oss", ("GptOssMLP", "GptOssMoE"), ("gate_up_proj", "down_proj"), True, None), + ("llama4", ("Llama4TextMoe",), ("gate_up_proj", "down_proj"), True, None), ("minimax", ("MiniMaxSparseMoeBlock",), ("w1", "w2", "w3"), False, ("w1", "w3")), ("mixtral", ("MixtralSparseMoeBlock",), ("w1", "w2", "w3"), False, ("w1", "w3")), ("phimoe", ("PhimoeSparseMoeBlock",), ("w1", "w2", "w3"), False, ("w1", "w3")), @@ -584,6 +585,13 @@ def test_fused_experts_shortcut_ignores_unrelated_attributes(): False, ("gate_proj", "up_proj"), ), + ( + "qwen3_vl_moe", + ("Qwen3VLMoeTextSparseMoeBlock",), + ("gate_up_proj", "down_proj"), + True, + None, + ), ] @@ -717,6 +725,7 @@ def test_iterable_experts_matches_pre_refactor_support(): "gemma4": "Gemma4ForConditionalGeneration", "gemma4_text": "Gemma4TextForCausalLM", "gpt_oss": "GptOssForCausalLM", + "llama4": "Llama4ForConditionalGeneration", "minimax": "MiniMaxForCausalLM", "mixtral": "MixtralForCausalLM", "phimoe": "PhimoeForCausalLM", @@ -725,6 +734,7 @@ def test_iterable_experts_matches_pre_refactor_support(): "qwen3_5_moe": "Qwen3_5MoeForCausalLM", "qwen3_moe": "Qwen3MoeForCausalLM", "qwen3_next": "Qwen3NextForCausalLM", + "qwen3_vl_moe": "Qwen3VLMoeForConditionalGeneration", } moe_specs = [s for s in get_specs() if _layouts(s)] assert {s.model_type for s in moe_specs} == set(root_class_names), ( From b811de25cd340a7bf29a7bfaa64fa1b350ff1f2c Mon Sep 17 00:00:00 2001 From: Shengliang Xu Date: Fri, 2 Oct 2026 17:37:06 +0000 Subject: [PATCH 2/3] Use the current copyright year on the new model spec files The new llama4, qwen3_vl_moe, falcon, step3p5 and step3p7 packages copied a 2024 header from an existing spec; new files carry the year in LICENSE_HEADER (2026). Signed-off-by: Shengliang Xu --- modelopt/torch/models/falcon/__init__.py | 2 +- modelopt/torch/models/falcon/specs.py | 2 +- modelopt/torch/models/llama4/__init__.py | 2 +- modelopt/torch/models/llama4/specs.py | 2 +- modelopt/torch/models/qwen3_vl_moe/__init__.py | 2 +- modelopt/torch/models/qwen3_vl_moe/specs.py | 2 +- modelopt/torch/models/step3p5/__init__.py | 2 +- modelopt/torch/models/step3p5/specs.py | 2 +- modelopt/torch/models/step3p7/__init__.py | 2 +- modelopt/torch/models/step3p7/specs.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modelopt/torch/models/falcon/__init__.py b/modelopt/torch/models/falcon/__init__.py index c08e11541cb..3611c504f3e 100644 --- a/modelopt/torch/models/falcon/__init__.py +++ b/modelopt/torch/models/falcon/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/falcon/specs.py b/modelopt/torch/models/falcon/specs.py index 4dfbbd2ffe7..0e4d9dca8eb 100644 --- a/modelopt/torch/models/falcon/specs.py +++ b/modelopt/torch/models/falcon/specs.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/llama4/__init__.py b/modelopt/torch/models/llama4/__init__.py index e9fd7824c40..88868e24a77 100644 --- a/modelopt/torch/models/llama4/__init__.py +++ b/modelopt/torch/models/llama4/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/llama4/specs.py b/modelopt/torch/models/llama4/specs.py index 70a7779883d..c2efaef42ae 100644 --- a/modelopt/torch/models/llama4/specs.py +++ b/modelopt/torch/models/llama4/specs.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/qwen3_vl_moe/__init__.py b/modelopt/torch/models/qwen3_vl_moe/__init__.py index e99407906be..19757e3ac6e 100644 --- a/modelopt/torch/models/qwen3_vl_moe/__init__.py +++ b/modelopt/torch/models/qwen3_vl_moe/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/qwen3_vl_moe/specs.py b/modelopt/torch/models/qwen3_vl_moe/specs.py index 853beae743b..1416d7e107d 100644 --- a/modelopt/torch/models/qwen3_vl_moe/specs.py +++ b/modelopt/torch/models/qwen3_vl_moe/specs.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/step3p5/__init__.py b/modelopt/torch/models/step3p5/__init__.py index e5c436ddc2d..27d981bcbbf 100644 --- a/modelopt/torch/models/step3p5/__init__.py +++ b/modelopt/torch/models/step3p5/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/step3p5/specs.py b/modelopt/torch/models/step3p5/specs.py index 541bdfbf42c..f2eb490aaef 100644 --- a/modelopt/torch/models/step3p5/specs.py +++ b/modelopt/torch/models/step3p5/specs.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/step3p7/__init__.py b/modelopt/torch/models/step3p7/__init__.py index 1f34f24c93b..3e229183c76 100644 --- a/modelopt/torch/models/step3p7/__init__.py +++ b/modelopt/torch/models/step3p7/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); diff --git a/modelopt/torch/models/step3p7/specs.py b/modelopt/torch/models/step3p7/specs.py index 9cc9afdaa10..6da2a42a791 100644 --- a/modelopt/torch/models/step3p7/specs.py +++ b/modelopt/torch/models/step3p7/specs.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# 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"); From 49237f3191891542b4d77c10ac1a86ae7a81008e Mon Sep 17 00:00:00 2001 From: Shengliang Xu Date: Tue, 6 Oct 2026 21:31:21 +0000 Subject: [PATCH 3/3] Record Step-3.5/3.7 as native in transformers 5.16 transformers 5.16 added the step3p7 package, which also registers the step3p5 text model type, so the specs no longer describe remote-code-only models. Set min_transformers_version to 5.16 instead of modeling_source=remote_code; older Step checkpoints still load as remote code and are covered by step3p5/modeling_ptq.py. Signed-off-by: Shengliang Xu --- modelopt/torch/models/step3p5/specs.py | 14 +++++++++----- modelopt/torch/models/step3p7/specs.py | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modelopt/torch/models/step3p5/specs.py b/modelopt/torch/models/step3p5/specs.py index f2eb490aaef..e76c8ad97ba 100644 --- a/modelopt/torch/models/step3p5/specs.py +++ b/modelopt/torch/models/step3p5/specs.py @@ -19,8 +19,12 @@ __all__: list[str] = [] -# No MoESpec: the routed experts are expert-indexed MoELinear projections on the MoE MLP -# itself, with no `experts` container, and are exported by the MoELinear handler rather -# than through the MoE-block lookups. Declaring the block would make is_moe claim it and -# send AWQ export into get_experts_list, which does not support this layout. -register(ModelSpec(model_type="step3p5", modeling_source="remote_code")) +# Native in transformers since 5.16, where the step3p7 package also registers this text model +# type; older Step-3.5 checkpoints ship their own modeling code (trust_remote_code). +# +# No MoESpec. The native MoE block (Step3p7SparseMoeBlock, with fused gate_up_proj/down_proj +# experts) is already recognized by is_moe by name and handled by the generic fused-experts +# path. The remote-code layout keeps its routed experts as expert-indexed MoELinear +# projections on the MoE MLP itself, with no `experts` container; declaring that block would +# make is_moe claim it and send AWQ export into get_experts_list, which does not support it. +register(ModelSpec(model_type="step3p5", min_transformers_version="5.16")) diff --git a/modelopt/torch/models/step3p7/specs.py b/modelopt/torch/models/step3p7/specs.py index 6da2a42a791..f38c0339989 100644 --- a/modelopt/torch/models/step3p7/specs.py +++ b/modelopt/torch/models/step3p7/specs.py @@ -23,5 +23,6 @@ __all__: list[str] = [] -# No MoESpec, for the same reason as step3p5 (see step3p5/specs.py). -register(ModelSpec(model_type="step3p7", modeling_source="remote_code")) +# Native in transformers since 5.16. No MoESpec, for the same reasons as step3p5 (see +# step3p5/specs.py). +register(ModelSpec(model_type="step3p7", min_transformers_version="5.16"))