Defuser 0.0.25__tar.gz → 0.0.27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {defuser-0.0.25 → defuser-0.0.27}/Defuser.egg-info/PKG-INFO +2 -2
- {defuser-0.0.25 → defuser-0.0.27}/PKG-INFO +2 -2
- {defuser-0.0.25 → defuser-0.0.27}/README.md +1 -1
- {defuser-0.0.25 → defuser-0.0.27}/defuser/model_registry.py +18 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/moe_experts_interface.py +4 -0
- {defuser-0.0.25 → defuser-0.0.27}/pyproject.toml +2 -2
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_candidate_coverage.py +38 -0
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_convert_model.py +53 -0
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_meta_model_defusion.py +52 -0
- {defuser-0.0.25 → defuser-0.0.27}/Defuser.egg-info/SOURCES.txt +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/Defuser.egg-info/dependency_links.txt +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/Defuser.egg-info/requires.txt +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/Defuser.egg-info/top_level.txt +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/LICENSE +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/__init__.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/checkpoint_ops.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/defuser.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/__init__.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/glm4v.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/model_patches.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/replace_modules.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/runtime_defusion.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/__init__.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/common.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/glm4_moe.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/glm4_moe_lite.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/mixtral.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen2_moe.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen3_moe.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen3_next.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen3_omni_moe.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/modeling/update_module.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/utils/__init__.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/utils/common.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/utils/device.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/utils/hf.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/defuser/utils/model.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/setup.cfg +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/setup.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_device_utils.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_filter_rules.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_moe_experts_interface.py +0 -0
- {defuser-0.0.25 → defuser-0.0.27}/tests/test_replace_modules_tracker.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Defuser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.27
|
|
4
4
|
Summary: Model defuser helper for HF Transformers.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -93,7 +93,7 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
93
93
|
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
94
94
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
95
95
|
| Standard routed expert tensors 🧱 | `deepseek_v2`, `dots1`, `ernie4_5_moe`, `ernie4_5_vl_moe`, `exaone_moe`, `flex_olmo`, `glm4_moe_lite`, `glm4v_moe`, `hunyuan_v1_moe`, `jamba`, `laguna`, `lfm2_moe`, `minimax`, `minimax_m2`, `olmoe`, `qwen3_vl_moe`, `solar_open`, `solar_open2` | Splits fused expert tensors or registered expert buffers into numbered expert `nn.Linear` modules with per-expert `gate_proj`, `up_proj`, and `down_proj`. |
|
|
96
|
-
| Mixed sparse and shared experts | `deepseek_v3`, deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`
|
|
96
|
+
| Mixed sparse and shared experts | `deepseek_v3`, `deepseek_v32`, `deepseek_v4`, `glm5_next`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`, `qwen4_exp`, `qwen4_exp_text` | Runtime expert tensor defusion for routed experts while preserving the model's shared-expert path. |
|
|
97
97
|
| Transposed or packed expert tensors | `gpt_oss`, `phimoe` | Splits transposed fused expert `gate_up_proj` tensors into per-expert `gate_proj` + `up_proj`, preserves expert bias when present, and converts expert tensors into numbered expert `nn.Linear` modules. |
|
|
98
98
|
| Flattened expert layout | `dbrx` | Rebuilds the flattened DBRX expert FFN weights into numbered expert `gate_proj`, `up_proj`, and `down_proj` `nn.Linear` modules. |
|
|
99
99
|
| Batched expert-input execution | `llama4` | Runtime expert tensor defusion plus preservation of the llama4 batched expert-input execution contract. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Defuser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.27
|
|
4
4
|
Summary: Model defuser helper for HF Transformers.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -93,7 +93,7 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
93
93
|
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
94
94
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
95
95
|
| Standard routed expert tensors 🧱 | `deepseek_v2`, `dots1`, `ernie4_5_moe`, `ernie4_5_vl_moe`, `exaone_moe`, `flex_olmo`, `glm4_moe_lite`, `glm4v_moe`, `hunyuan_v1_moe`, `jamba`, `laguna`, `lfm2_moe`, `minimax`, `minimax_m2`, `olmoe`, `qwen3_vl_moe`, `solar_open`, `solar_open2` | Splits fused expert tensors or registered expert buffers into numbered expert `nn.Linear` modules with per-expert `gate_proj`, `up_proj`, and `down_proj`. |
|
|
96
|
-
| Mixed sparse and shared experts | `deepseek_v3`, deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`
|
|
96
|
+
| Mixed sparse and shared experts | `deepseek_v3`, `deepseek_v32`, `deepseek_v4`, `glm5_next`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`, `qwen4_exp`, `qwen4_exp_text` | Runtime expert tensor defusion for routed experts while preserving the model's shared-expert path. |
|
|
97
97
|
| Transposed or packed expert tensors | `gpt_oss`, `phimoe` | Splits transposed fused expert `gate_up_proj` tensors into per-expert `gate_proj` + `up_proj`, preserves expert bias when present, and converts expert tensors into numbered expert `nn.Linear` modules. |
|
|
98
98
|
| Flattened expert layout | `dbrx` | Rebuilds the flattened DBRX expert FFN weights into numbered expert `gate_proj`, `up_proj`, and `down_proj` `nn.Linear` modules. |
|
|
99
99
|
| Batched expert-input execution | `llama4` | Runtime expert tensor defusion plus preservation of the llama4 batched expert-input execution contract. |
|
|
@@ -67,7 +67,7 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
67
67
|
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
68
68
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
69
69
|
| Standard routed expert tensors 🧱 | `deepseek_v2`, `dots1`, `ernie4_5_moe`, `ernie4_5_vl_moe`, `exaone_moe`, `flex_olmo`, `glm4_moe_lite`, `glm4v_moe`, `hunyuan_v1_moe`, `jamba`, `laguna`, `lfm2_moe`, `minimax`, `minimax_m2`, `olmoe`, `qwen3_vl_moe`, `solar_open`, `solar_open2` | Splits fused expert tensors or registered expert buffers into numbered expert `nn.Linear` modules with per-expert `gate_proj`, `up_proj`, and `down_proj`. |
|
|
70
|
-
| Mixed sparse and shared experts | `deepseek_v3`, deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`
|
|
70
|
+
| Mixed sparse and shared experts | `deepseek_v3`, `deepseek_v32`, `deepseek_v4`, `glm5_next`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`, `qwen4_exp`, `qwen4_exp_text` | Runtime expert tensor defusion for routed experts while preserving the model's shared-expert path. |
|
|
71
71
|
| Transposed or packed expert tensors | `gpt_oss`, `phimoe` | Splits transposed fused expert `gate_up_proj` tensors into per-expert `gate_proj` + `up_proj`, preserves expert bias when present, and converts expert tensors into numbered expert `nn.Linear` modules. |
|
|
72
72
|
| Flattened expert layout | `dbrx` | Rebuilds the flattened DBRX expert FFN weights into numbered expert `gate_proj`, `up_proj`, and `down_proj` `nn.Linear` modules. |
|
|
73
73
|
| Batched expert-input execution | `llama4` | Runtime expert tensor defusion plus preservation of the llama4 batched expert-input execution contract. |
|
|
@@ -37,6 +37,9 @@ MODEL_CONFIG = {
|
|
|
37
37
|
"deepseek_v3": {
|
|
38
38
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
39
39
|
},
|
|
40
|
+
"deepseek_v32": {
|
|
41
|
+
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
42
|
+
},
|
|
40
43
|
"deepseek_v4": {
|
|
41
44
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
42
45
|
},
|
|
@@ -143,6 +146,12 @@ MODEL_CONFIG = {
|
|
|
143
146
|
),
|
|
144
147
|
],
|
|
145
148
|
},
|
|
149
|
+
"qwen4_exp": {
|
|
150
|
+
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
151
|
+
},
|
|
152
|
+
"qwen4_exp_text": {
|
|
153
|
+
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
154
|
+
},
|
|
146
155
|
"glm4_moe": {
|
|
147
156
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
148
157
|
PATCH.REPLACE_MODULE: [
|
|
@@ -190,6 +199,15 @@ MODEL_CONFIG = {
|
|
|
190
199
|
"glm_image": {
|
|
191
200
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
192
201
|
},
|
|
202
|
+
"glm5_next": {
|
|
203
|
+
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
204
|
+
PATCH.EXPERTS_DEFUSE: [
|
|
205
|
+
{
|
|
206
|
+
"module_class": "transformers.models.glm5_next.modeling_glm5_next.Glm5NextTextExperts",
|
|
207
|
+
"forward_impl": "linear_loop",
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
},
|
|
193
211
|
"glm_moe_dsa": {
|
|
194
212
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
195
213
|
},
|
|
@@ -282,6 +282,10 @@ def _matching_experts_defuse_spec(module: nn.Module, specs: list[dict]) -> dict
|
|
|
282
282
|
|
|
283
283
|
def _install_instance_forward(module: nn.Module, implementation: str) -> None:
|
|
284
284
|
"""Attach a generic forward implementation directly to one experts module."""
|
|
285
|
+
if implementation == LINEAR_LOOP_IMPL:
|
|
286
|
+
module.forward = MethodType(linear_loop_experts_forward, module)
|
|
287
|
+
return
|
|
288
|
+
|
|
285
289
|
if implementation == BATCHED_INPUT_IMPL:
|
|
286
290
|
module.forward = MethodType(batched_input_experts_forward, module)
|
|
287
291
|
return
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
# Contact: qubitium@modelcloud.ai, x.com/qubitium
|
|
5
5
|
|
|
6
6
|
[build-system]
|
|
7
|
-
requires = ["setuptools>=77.0.1,<
|
|
7
|
+
requires = ["setuptools>=77.0.1,<85"]
|
|
8
8
|
build-backend = "setuptools.build_meta"
|
|
9
9
|
|
|
10
10
|
[project]
|
|
11
11
|
name = "Defuser"
|
|
12
|
-
version = "0.0.
|
|
12
|
+
version = "0.0.27"
|
|
13
13
|
description = "Model defuser helper for HF Transformers."
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
requires-python = ">=3.9"
|
|
@@ -161,6 +161,40 @@ STANDARD_MOE_CASES = [
|
|
|
161
161
|
"route_indices": [[0], [1], [2], [3], [0]],
|
|
162
162
|
"expert_attrs": ("gate_proj", "up_proj", "down_proj"),
|
|
163
163
|
},
|
|
164
|
+
{
|
|
165
|
+
"model_type": "deepseek_v32",
|
|
166
|
+
"module_path": "transformers.models.deepseek_v32.modeling_deepseek_v32",
|
|
167
|
+
"class_name": "DeepseekV32Experts",
|
|
168
|
+
"config_module": "transformers.models.deepseek_v32.configuration_deepseek_v32",
|
|
169
|
+
"config_name": "DeepseekV32Config",
|
|
170
|
+
"config_updates": {
|
|
171
|
+
"hidden_size": 64,
|
|
172
|
+
"moe_intermediate_size": 32,
|
|
173
|
+
"n_routed_experts": 4,
|
|
174
|
+
"hidden_act": "silu",
|
|
175
|
+
},
|
|
176
|
+
"input_dim": 64,
|
|
177
|
+
"route_indices": [[0], [1], [2], [3], [0]],
|
|
178
|
+
"expert_attrs": ("gate_proj", "up_proj", "down_proj"),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"model_type": "glm5_next",
|
|
182
|
+
"module_path": "transformers.models.glm5_next.modeling_glm5_next",
|
|
183
|
+
"class_name": "Glm5NextTextExperts",
|
|
184
|
+
"config_module": "transformers.models.glm5_next.configuration_glm5_next",
|
|
185
|
+
"config_name": "Glm5NextTextConfig",
|
|
186
|
+
"config_updates": {
|
|
187
|
+
"hidden_size": 64,
|
|
188
|
+
"moe_intermediate_size": 32,
|
|
189
|
+
"n_routed_experts": 4,
|
|
190
|
+
"hidden_act": "silu",
|
|
191
|
+
"swiglu_limit": 1.0,
|
|
192
|
+
"_experts_implementation": "grouped_mm",
|
|
193
|
+
},
|
|
194
|
+
"input_dim": 64,
|
|
195
|
+
"route_indices": [[0], [1], [2], [3], [0]],
|
|
196
|
+
"expert_attrs": ("gate_proj", "up_proj", "down_proj"),
|
|
197
|
+
},
|
|
164
198
|
{
|
|
165
199
|
"model_type": "dots1",
|
|
166
200
|
"module_path": "transformers.models.dots1.modeling_dots1",
|
|
@@ -547,6 +581,7 @@ ALL_CANDIDATE_MODEL_TYPES = {
|
|
|
547
581
|
"dbrx",
|
|
548
582
|
"deepseek_v2",
|
|
549
583
|
"deepseek_v3",
|
|
584
|
+
"deepseek_v32",
|
|
550
585
|
"dia",
|
|
551
586
|
"dots1",
|
|
552
587
|
"ernie4_5_moe",
|
|
@@ -559,6 +594,7 @@ ALL_CANDIDATE_MODEL_TYPES = {
|
|
|
559
594
|
"glm4_moe_lite",
|
|
560
595
|
"glm4v",
|
|
561
596
|
"glm4v_moe",
|
|
597
|
+
"glm5_next",
|
|
562
598
|
"glm_image",
|
|
563
599
|
"glm_moe_dsa",
|
|
564
600
|
"glm_ocr",
|
|
@@ -586,6 +622,8 @@ ALL_CANDIDATE_MODEL_TYPES = {
|
|
|
586
622
|
"qwen3_next",
|
|
587
623
|
"qwen3_omni_moe",
|
|
588
624
|
"qwen3_vl_moe",
|
|
625
|
+
"qwen4_exp",
|
|
626
|
+
"qwen4_exp_text",
|
|
589
627
|
"solar_open",
|
|
590
628
|
"solar_open2",
|
|
591
629
|
"zamba2",
|
|
@@ -38,6 +38,8 @@ from transformers.models.qwen3_next.modeling_qwen3_next import (
|
|
|
38
38
|
Qwen3NextSparseMoeBlock,
|
|
39
39
|
)
|
|
40
40
|
from transformers.models.qwen3_omni_moe.configuration_qwen3_omni_moe import Qwen3OmniMoeConfig
|
|
41
|
+
from transformers.models.qwen4_exp.configuration_qwen4_exp import Qwen4ExpTextConfig
|
|
42
|
+
from transformers.models.qwen4_exp.modeling_qwen4_exp import Qwen4ExpForCausalLM
|
|
41
43
|
from transformers.models.gpt_oss.modeling_gpt_oss import GptOssConfig, GptOssForCausalLM
|
|
42
44
|
from transformers.models.phimoe.modeling_phimoe import PhimoeConfig, PhimoeForCausalLM
|
|
43
45
|
from transformers.models.llama4.modeling_llama4 import Llama4Config, Llama4ForConditionalGeneration
|
|
@@ -176,6 +178,39 @@ def _tiny_qwen3_5_moe_config():
|
|
|
176
178
|
)
|
|
177
179
|
|
|
178
180
|
|
|
181
|
+
def _tiny_qwen4_exp_text_config():
|
|
182
|
+
return Qwen4ExpTextConfig(
|
|
183
|
+
vocab_size=64,
|
|
184
|
+
hidden_size=16,
|
|
185
|
+
num_hidden_layers=2,
|
|
186
|
+
num_attention_heads=4,
|
|
187
|
+
num_key_value_heads=2,
|
|
188
|
+
head_dim=4,
|
|
189
|
+
moe_intermediate_size=8,
|
|
190
|
+
shared_expert_intermediate_size=8,
|
|
191
|
+
num_experts=3,
|
|
192
|
+
num_experts_per_tok=2,
|
|
193
|
+
max_position_embeddings=32,
|
|
194
|
+
layer_types=["linear_attention", "qwen_sparse_attention"],
|
|
195
|
+
linear_num_key_heads=2,
|
|
196
|
+
linear_num_value_heads=4,
|
|
197
|
+
linear_key_head_dim=4,
|
|
198
|
+
linear_value_head_dim=4,
|
|
199
|
+
linear_conv_kernel_dim=2,
|
|
200
|
+
hc_count=2,
|
|
201
|
+
hc_lowrank=4,
|
|
202
|
+
ple_layer_ids=[],
|
|
203
|
+
bos_token_id=1,
|
|
204
|
+
eos_token_id=2,
|
|
205
|
+
pad_token_id=0,
|
|
206
|
+
indexer_n_heads=2,
|
|
207
|
+
indexer_kv_heads=1,
|
|
208
|
+
indexer_head_dim=4,
|
|
209
|
+
indexer_budget=8,
|
|
210
|
+
indexer_compress_ratio=2,
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
|
|
179
214
|
def _tiny_mixtral_config():
|
|
180
215
|
return MixtralConfig(
|
|
181
216
|
vocab_size=128,
|
|
@@ -739,6 +774,24 @@ def test_qwen3_5_moe():
|
|
|
739
774
|
torch.testing.assert_close(expert0.down_proj.weight, expected_down)
|
|
740
775
|
|
|
741
776
|
|
|
777
|
+
def test_qwen4_exp_text_preserves_forward():
|
|
778
|
+
model = Qwen4ExpForCausalLM(_tiny_qwen4_exp_text_config()).eval()
|
|
779
|
+
input_ids = torch.tensor([[1, 7, 8, 2]])
|
|
780
|
+
|
|
781
|
+
with torch.inference_mode():
|
|
782
|
+
expected = model(input_ids=input_ids, use_cache=False).logits
|
|
783
|
+
|
|
784
|
+
assert convert_model(model, cleanup_original=False)
|
|
785
|
+
assert model.config.model_type == "qwen4_exp_text"
|
|
786
|
+
experts = model.model.layers[0].mlp.experts
|
|
787
|
+
assert hasattr(experts, "0")
|
|
788
|
+
assert not hasattr(experts, "gate_up_proj")
|
|
789
|
+
|
|
790
|
+
with torch.inference_mode():
|
|
791
|
+
actual = model(input_ids=input_ids, use_cache=False).logits
|
|
792
|
+
torch.testing.assert_close(actual, expected, rtol=1e-5, atol=1e-7)
|
|
793
|
+
|
|
794
|
+
|
|
742
795
|
@pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA required")
|
|
743
796
|
def test_qwen3_5_moe_runtime_defusion_preserves_cuda_device():
|
|
744
797
|
model = Qwen3_5MoeForConditionalGeneration(_tiny_qwen3_5_moe_config()).cuda().eval()
|
|
@@ -155,6 +155,8 @@ def _build_model_config(case: dict):
|
|
|
155
155
|
config.ffn_config.ffn_act_fn = {"name": "silu"}
|
|
156
156
|
elif model_type == "deepseek_v3":
|
|
157
157
|
config.first_k_dense_replace = 0
|
|
158
|
+
elif model_type == "deepseek_v32":
|
|
159
|
+
config.mlp_layer_types = ["sparse"] * config.num_hidden_layers
|
|
158
160
|
elif model_type == "ernie4_5_vl_moe":
|
|
159
161
|
config.text_config.moe_intermediate_size = [32, 32]
|
|
160
162
|
config.text_config.rope_parameters = {
|
|
@@ -164,6 +166,8 @@ def _build_model_config(case: dict):
|
|
|
164
166
|
}
|
|
165
167
|
elif model_type == "glm4_moe":
|
|
166
168
|
config.first_k_dense_replace = -1
|
|
169
|
+
elif model_type == "glm5_next":
|
|
170
|
+
config.text_config.mlp_layer_types = ["sparse"] * config.text_config.num_hidden_layers
|
|
167
171
|
elif model_type == "glm_moe_dsa":
|
|
168
172
|
config.mlp_layer_types = ["sparse"] * config.num_hidden_layers
|
|
169
173
|
elif model_type == "granitemoehybrid":
|
|
@@ -342,6 +346,19 @@ META_MODEL_CASES = [
|
|
|
342
346
|
"validator": "experts",
|
|
343
347
|
"min_targets": 2,
|
|
344
348
|
},
|
|
349
|
+
{
|
|
350
|
+
"model_type": "deepseek_v32",
|
|
351
|
+
"mode": "convert",
|
|
352
|
+
"model_module": "transformers.models.deepseek_v32.modeling_deepseek_v32",
|
|
353
|
+
"model_class": "DeepseekV32ForCausalLM",
|
|
354
|
+
"config_module": "transformers.models.deepseek_v32.configuration_deepseek_v32",
|
|
355
|
+
"config_class": "DeepseekV32Config",
|
|
356
|
+
"target_class_paths": (
|
|
357
|
+
"transformers.models.deepseek_v32.modeling_deepseek_v32.DeepseekV32Experts",
|
|
358
|
+
),
|
|
359
|
+
"validator": "experts",
|
|
360
|
+
"min_targets": 2,
|
|
361
|
+
},
|
|
345
362
|
{
|
|
346
363
|
"model_type": "deepseek_v4",
|
|
347
364
|
"mode": "convert",
|
|
@@ -485,6 +502,19 @@ META_MODEL_CASES = [
|
|
|
485
502
|
"target_class_paths": ("transformers.models.glm_image.modeling_glm_image.GlmImageTextMLP",),
|
|
486
503
|
"validator": "dense_split",
|
|
487
504
|
},
|
|
505
|
+
{
|
|
506
|
+
"model_type": "glm5_next",
|
|
507
|
+
"mode": "convert",
|
|
508
|
+
"model_module": "transformers.models.glm5_next.modeling_glm5_next",
|
|
509
|
+
"model_class": "Glm5NextForConditionalGeneration",
|
|
510
|
+
"config_module": "transformers.models.glm5_next.configuration_glm5_next",
|
|
511
|
+
"config_class": "Glm5NextConfig",
|
|
512
|
+
"target_class_paths": (
|
|
513
|
+
"transformers.models.glm5_next.modeling_glm5_next.Glm5NextTextExperts",
|
|
514
|
+
),
|
|
515
|
+
"validator": "experts",
|
|
516
|
+
"min_targets": 2,
|
|
517
|
+
},
|
|
488
518
|
{
|
|
489
519
|
"model_type": "glm_moe_dsa",
|
|
490
520
|
"mode": "convert",
|
|
@@ -735,6 +765,28 @@ META_MODEL_CASES = [
|
|
|
735
765
|
"validator": "experts",
|
|
736
766
|
"min_targets": 2,
|
|
737
767
|
},
|
|
768
|
+
{
|
|
769
|
+
"model_type": "qwen4_exp",
|
|
770
|
+
"mode": "convert",
|
|
771
|
+
"model_module": "transformers.models.qwen4_exp.modeling_qwen4_exp",
|
|
772
|
+
"model_class": "Qwen4ExpForConditionalGeneration",
|
|
773
|
+
"config_module": "transformers.models.qwen4_exp.configuration_qwen4_exp",
|
|
774
|
+
"config_class": "Qwen4ExpConfig",
|
|
775
|
+
"target_class_paths": ("transformers.models.qwen4_exp.modeling_qwen4_exp.Qwen4ExpTextExperts",),
|
|
776
|
+
"validator": "experts",
|
|
777
|
+
"min_targets": 2,
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
"model_type": "qwen4_exp_text",
|
|
781
|
+
"mode": "convert",
|
|
782
|
+
"model_module": "transformers.models.qwen4_exp.modeling_qwen4_exp",
|
|
783
|
+
"model_class": "Qwen4ExpForCausalLM",
|
|
784
|
+
"config_module": "transformers.models.qwen4_exp.configuration_qwen4_exp",
|
|
785
|
+
"config_class": "Qwen4ExpTextConfig",
|
|
786
|
+
"target_class_paths": ("transformers.models.qwen4_exp.modeling_qwen4_exp.Qwen4ExpTextExperts",),
|
|
787
|
+
"validator": "experts",
|
|
788
|
+
"min_targets": 2,
|
|
789
|
+
},
|
|
738
790
|
{
|
|
739
791
|
"model_type": "qwen3_moe",
|
|
740
792
|
"mode": "replace",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|