Defuser 0.0.26__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.26 → defuser-0.0.27}/Defuser.egg-info/PKG-INFO +2 -2
- {defuser-0.0.26 → defuser-0.0.27}/PKG-INFO +2 -2
- {defuser-0.0.26 → defuser-0.0.27}/README.md +1 -1
- {defuser-0.0.26 → defuser-0.0.27}/defuser/model_registry.py +9 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/moe_experts_interface.py +4 -0
- {defuser-0.0.26 → defuser-0.0.27}/pyproject.toml +1 -1
- {defuser-0.0.26 → defuser-0.0.27}/tests/test_candidate_coverage.py +19 -0
- {defuser-0.0.26 → defuser-0.0.27}/tests/test_meta_model_defusion.py +15 -0
- {defuser-0.0.26 → defuser-0.0.27}/Defuser.egg-info/SOURCES.txt +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/Defuser.egg-info/dependency_links.txt +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/Defuser.egg-info/requires.txt +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/Defuser.egg-info/top_level.txt +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/LICENSE +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/__init__.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/checkpoint_ops.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/defuser.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/__init__.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/glm4v.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/model_patches.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/replace_modules.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/runtime_defusion.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/__init__.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/common.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/glm4_moe.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/glm4_moe_lite.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/mixtral.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen2_moe.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen3_moe.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen3_next.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/unfused_moe/qwen3_omni_moe.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/modeling/update_module.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/utils/__init__.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/utils/common.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/utils/device.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/utils/hf.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/defuser/utils/model.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/setup.cfg +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/setup.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/tests/test_convert_model.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/tests/test_device_utils.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/tests/test_filter_rules.py +0 -0
- {defuser-0.0.26 → defuser-0.0.27}/tests/test_moe_experts_interface.py +0 -0
- {defuser-0.0.26 → 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_v32`, `deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`, `qwen4_exp`, `qwen4_exp_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_v32`, `deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`, `qwen4_exp`, `qwen4_exp_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_v32`, `deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`, `qwen4_exp`, `qwen4_exp_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. |
|
|
@@ -199,6 +199,15 @@ MODEL_CONFIG = {
|
|
|
199
199
|
"glm_image": {
|
|
200
200
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
201
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
|
+
},
|
|
202
211
|
"glm_moe_dsa": {
|
|
203
212
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
204
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
|
|
@@ -177,6 +177,24 @@ STANDARD_MOE_CASES = [
|
|
|
177
177
|
"route_indices": [[0], [1], [2], [3], [0]],
|
|
178
178
|
"expert_attrs": ("gate_proj", "up_proj", "down_proj"),
|
|
179
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
|
+
},
|
|
180
198
|
{
|
|
181
199
|
"model_type": "dots1",
|
|
182
200
|
"module_path": "transformers.models.dots1.modeling_dots1",
|
|
@@ -576,6 +594,7 @@ ALL_CANDIDATE_MODEL_TYPES = {
|
|
|
576
594
|
"glm4_moe_lite",
|
|
577
595
|
"glm4v",
|
|
578
596
|
"glm4v_moe",
|
|
597
|
+
"glm5_next",
|
|
579
598
|
"glm_image",
|
|
580
599
|
"glm_moe_dsa",
|
|
581
600
|
"glm_ocr",
|
|
@@ -166,6 +166,8 @@ def _build_model_config(case: dict):
|
|
|
166
166
|
}
|
|
167
167
|
elif model_type == "glm4_moe":
|
|
168
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
|
|
169
171
|
elif model_type == "glm_moe_dsa":
|
|
170
172
|
config.mlp_layer_types = ["sparse"] * config.num_hidden_layers
|
|
171
173
|
elif model_type == "granitemoehybrid":
|
|
@@ -500,6 +502,19 @@ META_MODEL_CASES = [
|
|
|
500
502
|
"target_class_paths": ("transformers.models.glm_image.modeling_glm_image.GlmImageTextMLP",),
|
|
501
503
|
"validator": "dense_split",
|
|
502
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
|
+
},
|
|
503
518
|
{
|
|
504
519
|
"model_type": "glm_moe_dsa",
|
|
505
520
|
"mode": "convert",
|
|
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
|
|
File without changes
|