Defuser 0.0.27__tar.gz → 0.0.28__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.27 → defuser-0.0.28}/Defuser.egg-info/PKG-INFO +2 -2
- {defuser-0.0.27 → defuser-0.0.28}/PKG-INFO +2 -2
- {defuser-0.0.27 → defuser-0.0.28}/README.md +1 -1
- {defuser-0.0.27 → defuser-0.0.28}/defuser/model_registry.py +15 -0
- {defuser-0.0.27 → defuser-0.0.28}/pyproject.toml +1 -1
- {defuser-0.0.27 → defuser-0.0.28}/tests/test_meta_model_defusion.py +58 -1
- {defuser-0.0.27 → defuser-0.0.28}/Defuser.egg-info/SOURCES.txt +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/Defuser.egg-info/dependency_links.txt +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/Defuser.egg-info/requires.txt +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/Defuser.egg-info/top_level.txt +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/LICENSE +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/__init__.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/checkpoint_ops.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/defuser.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/__init__.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/glm4v.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/model_patches.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/moe_experts_interface.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/replace_modules.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/runtime_defusion.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/__init__.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/common.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/glm4_moe.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/glm4_moe_lite.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/mixtral.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/qwen2_moe.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/qwen3_moe.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/qwen3_next.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/unfused_moe/qwen3_omni_moe.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/modeling/update_module.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/utils/__init__.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/utils/common.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/utils/device.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/utils/hf.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/defuser/utils/model.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/setup.cfg +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/setup.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/tests/test_candidate_coverage.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/tests/test_convert_model.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/tests/test_device_utils.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/tests/test_filter_rules.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/tests/test_moe_experts_interface.py +0 -0
- {defuser-0.0.27 → defuser-0.0.28}/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.28
|
|
4
4
|
Summary: Model defuser helper for HF Transformers.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -92,7 +92,7 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
92
92
|
|
|
93
93
|
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
94
94
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
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`. |
|
|
95
|
+
| Standard routed expert tensors 🧱 | `deepseek_v2`, `diffusion_gemma`, `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
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. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Defuser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.28
|
|
4
4
|
Summary: Model defuser helper for HF Transformers.
|
|
5
5
|
Author-email: ModelCloud <qubitium@modelcloud.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -92,7 +92,7 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
92
92
|
|
|
93
93
|
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
94
94
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
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`. |
|
|
95
|
+
| Standard routed expert tensors 🧱 | `deepseek_v2`, `diffusion_gemma`, `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
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. |
|
|
@@ -66,7 +66,7 @@ Defuser currently supports the following `transformers>=5.3.0` `model_type` valu
|
|
|
66
66
|
|
|
67
67
|
| Pattern | Supported model types | Defused op performed ⚙️ |
|
|
68
68
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
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`. |
|
|
69
|
+
| Standard routed expert tensors 🧱 | `deepseek_v2`, `diffusion_gemma`, `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
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. |
|
|
@@ -46,6 +46,21 @@ MODEL_CONFIG = {
|
|
|
46
46
|
"dia": {
|
|
47
47
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
48
48
|
},
|
|
49
|
+
"diffusion_gemma": {
|
|
50
|
+
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
51
|
+
PATCH.EXPERTS_DEFUSE: [
|
|
52
|
+
{
|
|
53
|
+
# DiffusionGemma's fused experts need an instance-level
|
|
54
|
+
# implementation after defusion so their per-expert Linear
|
|
55
|
+
# leaves remain compatible with the upstream routing call.
|
|
56
|
+
"module_class": (
|
|
57
|
+
"transformers.models.diffusion_gemma.modeling_diffusion_gemma."
|
|
58
|
+
"DiffusionGemmaTextExperts"
|
|
59
|
+
),
|
|
60
|
+
"forward_impl": "linear_loop",
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
},
|
|
49
64
|
"dots1": {
|
|
50
65
|
"min_transformers_version": MIN_SUPPORTED_TRANSFORMERS_VERSION,
|
|
51
66
|
},
|
|
@@ -138,7 +138,49 @@ def _mutate_common_config_tree(config, visited: set[int] | None = None) -> None:
|
|
|
138
138
|
|
|
139
139
|
def _build_model_config(case: dict):
|
|
140
140
|
"""Construct a small config tree for one registered public model type."""
|
|
141
|
-
|
|
141
|
+
config_cls = _load(case["config_module"], case["config_class"])
|
|
142
|
+
if case["model_type"] == "diffusion_gemma":
|
|
143
|
+
# Unlike the generic cases, DiffusionGemma validates its nested text /
|
|
144
|
+
# vision configs during construction; provide a minimal valid pair so
|
|
145
|
+
# this registry test remains a meta-only structural check.
|
|
146
|
+
return config_cls(
|
|
147
|
+
text_config={
|
|
148
|
+
"vocab_size": 128,
|
|
149
|
+
"hidden_size": 64,
|
|
150
|
+
"intermediate_size": 128,
|
|
151
|
+
"moe_intermediate_size": 32,
|
|
152
|
+
"num_hidden_layers": 2,
|
|
153
|
+
"num_attention_heads": 4,
|
|
154
|
+
"num_key_value_heads": 1,
|
|
155
|
+
"num_global_key_value_heads": 1,
|
|
156
|
+
"head_dim": 16,
|
|
157
|
+
"global_head_dim": 16,
|
|
158
|
+
"num_experts": 4,
|
|
159
|
+
"top_k_experts": 1,
|
|
160
|
+
"max_position_embeddings": 64,
|
|
161
|
+
"sliding_window": 8,
|
|
162
|
+
"layer_types": ["sliding_attention", "full_attention"],
|
|
163
|
+
"use_bidirectional_attention": "vision",
|
|
164
|
+
},
|
|
165
|
+
vision_config={
|
|
166
|
+
"hidden_size": 64,
|
|
167
|
+
"intermediate_size": 128,
|
|
168
|
+
"num_hidden_layers": 1,
|
|
169
|
+
"num_attention_heads": 4,
|
|
170
|
+
"num_key_value_heads": 4,
|
|
171
|
+
"head_dim": 16,
|
|
172
|
+
"max_position_embeddings": 64,
|
|
173
|
+
"patch_size": 4,
|
|
174
|
+
"pooling_kernel_size": 1,
|
|
175
|
+
"position_embedding_size": 16,
|
|
176
|
+
},
|
|
177
|
+
canvas_length=4,
|
|
178
|
+
image_token_id=124,
|
|
179
|
+
boi_token_id=125,
|
|
180
|
+
eoi_token_id=126,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
config = config_cls()
|
|
142
184
|
_mutate_common_config_tree(config)
|
|
143
185
|
|
|
144
186
|
model_type = case["model_type"]
|
|
@@ -390,6 +432,21 @@ META_MODEL_CASES = [
|
|
|
390
432
|
"target_class_paths": ("transformers.models.dots1.modeling_dots1.Dots1NaiveMoe",),
|
|
391
433
|
"validator": "experts",
|
|
392
434
|
},
|
|
435
|
+
{
|
|
436
|
+
"model_type": "diffusion_gemma",
|
|
437
|
+
"mode": "convert",
|
|
438
|
+
"model_module": "transformers.models.diffusion_gemma.modeling_diffusion_gemma",
|
|
439
|
+
"model_class": "DiffusionGemmaForBlockDiffusion",
|
|
440
|
+
"config_module": "transformers.models.diffusion_gemma.configuration_diffusion_gemma",
|
|
441
|
+
"config_class": "DiffusionGemmaConfig",
|
|
442
|
+
"target_class_paths": (
|
|
443
|
+
"transformers.models.diffusion_gemma.modeling_diffusion_gemma.DiffusionGemmaTextExperts",
|
|
444
|
+
),
|
|
445
|
+
"validator": "experts",
|
|
446
|
+
# There are separate experts blocks in the encoder and decoder; seeing
|
|
447
|
+
# both ensures the declarative class-path patch is applied everywhere.
|
|
448
|
+
"min_targets": 2,
|
|
449
|
+
},
|
|
393
450
|
{
|
|
394
451
|
"model_type": "ernie4_5_moe",
|
|
395
452
|
"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
|
|
File without changes
|
|
File without changes
|