Defuser 0.0.21__tar.gz → 0.0.22__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.21 → defuser-0.0.22}/Defuser.egg-info/PKG-INFO +11 -11
- {defuser-0.0.21 → defuser-0.0.22}/PKG-INFO +11 -11
- {defuser-0.0.21 → defuser-0.0.22}/README.md +10 -10
- {defuser-0.0.21 → defuser-0.0.22}/defuser/defuser.py +0 -1
- {defuser-0.0.21 → defuser-0.0.22}/defuser/model_registry.py +3 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/replace_modules.py +0 -1
- {defuser-0.0.21 → defuser-0.0.22}/pyproject.toml +1 -1
- {defuser-0.0.21 → defuser-0.0.22}/tests/test_meta_model_defusion.py +11 -0
- {defuser-0.0.21 → defuser-0.0.22}/Defuser.egg-info/SOURCES.txt +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/Defuser.egg-info/dependency_links.txt +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/Defuser.egg-info/requires.txt +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/Defuser.egg-info/top_level.txt +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/LICENSE +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/__init__.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/checkpoint_ops.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/__init__.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/glm4v.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/model_patches.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/moe_experts_interface.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/runtime_defusion.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/__init__.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/common.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/glm4_moe.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/glm4_moe_lite.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/mixtral.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/qwen2_moe.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/qwen3_moe.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/qwen3_next.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/unfused_moe/qwen3_omni_moe.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/modeling/update_module.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/utils/__init__.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/utils/common.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/utils/device.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/utils/hf.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/defuser/utils/model.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/setup.cfg +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/setup.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/tests/test_candidate_coverage.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/tests/test_convert_model.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/tests/test_device_utils.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/tests/test_filter_rules.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/tests/test_moe_experts_interface.py +0 -0
- {defuser-0.0.21 → defuser-0.0.22}/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.22
|
|
4
4
|
Summary: Model defuser helper for HF Transformers.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -90,17 +90,17 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
90
90
|
|
|
91
91
|
### 🔄 `convert_model(model)` after load
|
|
92
92
|
|
|
93
|
-
| Pattern | Supported model types
|
|
94
|
-
| ---
|
|
93
|
+
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
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` | 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`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`
|
|
97
|
-
| Transposed or packed expert tensors | `gpt_oss`, `phimoe`
|
|
98
|
-
| Flattened expert layout | `dbrx`
|
|
99
|
-
| Batched expert-input execution | `llama4`
|
|
100
|
-
| Non-gated expert MLPs | `nemotron_h`
|
|
101
|
-
| Parallel expert blocks | `granitemoe`, `granitemoehybrid`, `granitemoeshared`, `jetmoe`
|
|
102
|
-
| Routed experts with identity experts | `longcat_flash`
|
|
103
|
-
| Fused dense `gate_up_proj` MLPs | `dia`, `glm`, `glm4`, `glm_image`, `glm_ocr`, `phi3`, `phi4_multimodal`, `zamba2`
|
|
96
|
+
| Mixed sparse and shared experts | `deepseek_v3`, deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text` | Runtime expert tensor defusion for routed experts while preserving the model's shared-expert path. |
|
|
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
|
+
| 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
|
+
| Batched expert-input execution | `llama4` | Runtime expert tensor defusion plus preservation of the llama4 batched expert-input execution contract. |
|
|
100
|
+
| Non-gated expert MLPs | `nemotron_h` | Converts routed expert tensors into numbered `up_proj` and `down_proj` `nn.Linear` modules for non-gated experts. |
|
|
101
|
+
| Parallel expert blocks | `granitemoe`, `granitemoehybrid`, `granitemoeshared`, `jetmoe` | Converts packed expert weight tensors into numbered expert `linear` modules while keeping grouped expert execution intact. |
|
|
102
|
+
| Routed experts with identity experts | `longcat_flash` | Defuses routed experts into numbered `gate_proj`, `up_proj`, and `down_proj` modules and preserves zero or identity experts. |
|
|
103
|
+
| Fused dense `gate_up_proj` MLPs | `dia`, `glm`, `glm4`, `glm_image`, `glm_ocr`, `phi3`, `phi4_multimodal`, `zamba2` | Splits fused dense `gate_up_proj` layers into `gate_proj` + `up_proj` and updates the block `forward()` to preserve the original MLP math. |
|
|
104
104
|
|
|
105
105
|
## 🔁 Workflow Summary
|
|
106
106
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Defuser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.22
|
|
4
4
|
Summary: Model defuser helper for HF Transformers.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -90,17 +90,17 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
90
90
|
|
|
91
91
|
### 🔄 `convert_model(model)` after load
|
|
92
92
|
|
|
93
|
-
| Pattern | Supported model types
|
|
94
|
-
| ---
|
|
93
|
+
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
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` | 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`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`
|
|
97
|
-
| Transposed or packed expert tensors | `gpt_oss`, `phimoe`
|
|
98
|
-
| Flattened expert layout | `dbrx`
|
|
99
|
-
| Batched expert-input execution | `llama4`
|
|
100
|
-
| Non-gated expert MLPs | `nemotron_h`
|
|
101
|
-
| Parallel expert blocks | `granitemoe`, `granitemoehybrid`, `granitemoeshared`, `jetmoe`
|
|
102
|
-
| Routed experts with identity experts | `longcat_flash`
|
|
103
|
-
| Fused dense `gate_up_proj` MLPs | `dia`, `glm`, `glm4`, `glm_image`, `glm_ocr`, `phi3`, `phi4_multimodal`, `zamba2`
|
|
96
|
+
| Mixed sparse and shared experts | `deepseek_v3`, deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text` | Runtime expert tensor defusion for routed experts while preserving the model's shared-expert path. |
|
|
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
|
+
| 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
|
+
| Batched expert-input execution | `llama4` | Runtime expert tensor defusion plus preservation of the llama4 batched expert-input execution contract. |
|
|
100
|
+
| Non-gated expert MLPs | `nemotron_h` | Converts routed expert tensors into numbered `up_proj` and `down_proj` `nn.Linear` modules for non-gated experts. |
|
|
101
|
+
| Parallel expert blocks | `granitemoe`, `granitemoehybrid`, `granitemoeshared`, `jetmoe` | Converts packed expert weight tensors into numbered expert `linear` modules while keeping grouped expert execution intact. |
|
|
102
|
+
| Routed experts with identity experts | `longcat_flash` | Defuses routed experts into numbered `gate_proj`, `up_proj`, and `down_proj` modules and preserves zero or identity experts. |
|
|
103
|
+
| Fused dense `gate_up_proj` MLPs | `dia`, `glm`, `glm4`, `glm_image`, `glm_ocr`, `phi3`, `phi4_multimodal`, `zamba2` | Splits fused dense `gate_up_proj` layers into `gate_proj` + `up_proj` and updates the block `forward()` to preserve the original MLP math. |
|
|
104
104
|
|
|
105
105
|
## 🔁 Workflow Summary
|
|
106
106
|
|
|
@@ -64,17 +64,17 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
64
64
|
|
|
65
65
|
### 🔄 `convert_model(model)` after load
|
|
66
66
|
|
|
67
|
-
| Pattern | Supported model types
|
|
68
|
-
| ---
|
|
67
|
+
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
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` | 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`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text`
|
|
71
|
-
| Transposed or packed expert tensors | `gpt_oss`, `phimoe`
|
|
72
|
-
| Flattened expert layout | `dbrx`
|
|
73
|
-
| Batched expert-input execution | `llama4`
|
|
74
|
-
| Non-gated expert MLPs | `nemotron_h`
|
|
75
|
-
| Parallel expert blocks | `granitemoe`, `granitemoehybrid`, `granitemoeshared`, `jetmoe`
|
|
76
|
-
| Routed experts with identity experts | `longcat_flash`
|
|
77
|
-
| Fused dense `gate_up_proj` MLPs | `dia`, `glm`, `glm4`, `glm_image`, `glm_ocr`, `phi3`, `phi4_multimodal`, `zamba2`
|
|
70
|
+
| Mixed sparse and shared experts | `deepseek_v3`, deepseek_v4`, `glm_moe_dsa`, `qwen3_5_moe`, `qwen3_5_moe_text` | Runtime expert tensor defusion for routed experts while preserving the model's shared-expert path. |
|
|
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
|
+
| 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
|
+
| Batched expert-input execution | `llama4` | Runtime expert tensor defusion plus preservation of the llama4 batched expert-input execution contract. |
|
|
74
|
+
| Non-gated expert MLPs | `nemotron_h` | Converts routed expert tensors into numbered `up_proj` and `down_proj` `nn.Linear` modules for non-gated experts. |
|
|
75
|
+
| Parallel expert blocks | `granitemoe`, `granitemoehybrid`, `granitemoeshared`, `jetmoe` | Converts packed expert weight tensors into numbered expert `linear` modules while keeping grouped expert execution intact. |
|
|
76
|
+
| Routed experts with identity experts | `longcat_flash` | Defuses routed experts into numbered `gate_proj`, `up_proj`, and `down_proj` modules and preserves zero or identity experts. |
|
|
77
|
+
| Fused dense `gate_up_proj` MLPs | `dia`, `glm`, `glm4`, `glm_image`, `glm_ocr`, `phi3`, `phi4_multimodal`, `zamba2` | Splits fused dense `gate_up_proj` layers into `gate_proj` + `up_proj` and updates the block `forward()` to preserve the original MLP math. |
|
|
78
78
|
|
|
79
79
|
## 🔁 Workflow Summary
|
|
80
80
|
|
|
@@ -75,7 +75,6 @@ def replace_fused_blocks(model_type: str) -> bool:
|
|
|
75
75
|
try:
|
|
76
76
|
orig_module = importlib.import_module(orig_module_path)
|
|
77
77
|
custom_module = importlib.import_module(custom_module_path)
|
|
78
|
-
print("orig_module", orig_module, orig_class_name)
|
|
79
78
|
# Validate class existence before patching
|
|
80
79
|
if not hasattr(orig_module, orig_class_name):
|
|
81
80
|
raise PatchError(f"Original class[{orig_class_name}] not found: {orig_module}")
|
|
@@ -25,6 +25,9 @@ MODEL_CONFIG = {
|
|
|
25
25
|
"deepseek_v3": {
|
|
26
26
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
27
27
|
},
|
|
28
|
+
"deepseek_v4": {
|
|
29
|
+
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
30
|
+
},
|
|
28
31
|
"dia": {
|
|
29
32
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
30
33
|
},
|
|
@@ -331,6 +331,17 @@ META_MODEL_CASES = [
|
|
|
331
331
|
"validator": "experts",
|
|
332
332
|
"min_targets": 2,
|
|
333
333
|
},
|
|
334
|
+
{
|
|
335
|
+
"model_type": "deepseek_v4",
|
|
336
|
+
"mode": "convert",
|
|
337
|
+
"model_module": "transformers.models.deepseek_v4.modeling_deepseek_v4",
|
|
338
|
+
"model_class": "DeepseekV4ForCausalLM",
|
|
339
|
+
"config_module": "transformers.models.deepseek_v4.configuration_deepseek_v4",
|
|
340
|
+
"config_class": "DeepseekV4Config",
|
|
341
|
+
"target_class_paths": ("transformers.models.deepseek_v4.modeling_deepseek_v4.DeepseekV4Experts",),
|
|
342
|
+
"validator": "experts",
|
|
343
|
+
"min_targets": 2,
|
|
344
|
+
},
|
|
334
345
|
{
|
|
335
346
|
"model_type": "dia",
|
|
336
347
|
"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
|