Defuser 0.0.1__tar.gz → 0.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Defuser
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Model defuser helper for HF Transformers.
5
5
  Author-email: ModelCloud <qubitium@modelcloud.ai>
6
6
  License-Expression: Apache-2.0
@@ -19,7 +19,17 @@ Classifier: Topic :: Text Processing :: Linguistic
19
19
  Requires-Python: >=3.9
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
+ Requires-Dist: transformers
22
23
  Dynamic: license-file
23
24
 
24
- # Defuser
25
- Model defuser helper for HF Transformers
25
+
26
+ <div align=center>
27
+ <img width="50%" alt="image" src="https://github.com/user-attachments/assets/f801617b-8959-474a-a565-6b8897e2fcbf" />
28
+ <h1 align="center">Defuser</h1>
29
+ </div>
30
+
31
+
32
+ Model defuser helper for HF Transformers >= 5.0. In HF Transformers 5.x releases, many MoE modules became auto-stacked or auto-fused by new modeling code which has benefits but also downsides.
33
+
34
+ * Goal is to provide naive module/layer forwarding code for all models supported by HF transformers where run-time weight and structure level optimizations such weight merging, stacking, fusing are reversed so the model is operating in a simple naive state.
35
+ * There are cases, quantization libraries, where we need to run inference where module input/output needs to be individually captured and this pkg can help complete this task.
@@ -5,5 +5,9 @@ setup.py
5
5
  Defuser.egg-info/PKG-INFO
6
6
  Defuser.egg-info/SOURCES.txt
7
7
  Defuser.egg-info/dependency_links.txt
8
+ Defuser.egg-info/requires.txt
8
9
  Defuser.egg-info/top_level.txt
9
- defuser/__init__.py
10
+ defuser/__init__.py
11
+ defuser/defuser.py
12
+ defuser/logger.py
13
+ tests/test_convert_model.py
@@ -0,0 +1 @@
1
+ transformers
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Defuser
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Model defuser helper for HF Transformers.
5
5
  Author-email: ModelCloud <qubitium@modelcloud.ai>
6
6
  License-Expression: Apache-2.0
@@ -19,7 +19,17 @@ Classifier: Topic :: Text Processing :: Linguistic
19
19
  Requires-Python: >=3.9
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
+ Requires-Dist: transformers
22
23
  Dynamic: license-file
23
24
 
24
- # Defuser
25
- Model defuser helper for HF Transformers
25
+
26
+ <div align=center>
27
+ <img width="50%" alt="image" src="https://github.com/user-attachments/assets/f801617b-8959-474a-a565-6b8897e2fcbf" />
28
+ <h1 align="center">Defuser</h1>
29
+ </div>
30
+
31
+
32
+ Model defuser helper for HF Transformers >= 5.0. In HF Transformers 5.x releases, many MoE modules became auto-stacked or auto-fused by new modeling code which has benefits but also downsides.
33
+
34
+ * Goal is to provide naive module/layer forwarding code for all models supported by HF transformers where run-time weight and structure level optimizations such weight merging, stacking, fusing are reversed so the model is operating in a simple naive state.
35
+ * There are cases, quantization libraries, where we need to run inference where module input/output needs to be individually captured and this pkg can help complete this task.
@@ -0,0 +1,11 @@
1
+
2
+ <div align=center>
3
+ <img width="50%" alt="image" src="https://github.com/user-attachments/assets/f801617b-8959-474a-a565-6b8897e2fcbf" />
4
+ <h1 align="center">Defuser</h1>
5
+ </div>
6
+
7
+
8
+ Model defuser helper for HF Transformers >= 5.0. In HF Transformers 5.x releases, many MoE modules became auto-stacked or auto-fused by new modeling code which has benefits but also downsides.
9
+
10
+ * Goal is to provide naive module/layer forwarding code for all models supported by HF transformers where run-time weight and structure level optimizations such weight merging, stacking, fusing are reversed so the model is operating in a simple naive state.
11
+ * There are cases, quantization libraries, where we need to run inference where module input/output needs to be individually captured and this pkg can help complete this task.
@@ -0,0 +1,6 @@
1
+ # SPDX-FileCopyrightText: 2026 ModelCloud.ai
2
+ # SPDX-FileCopyrightText: 2026 qubitium@modelcloud.ai
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ # Contact: qubitium@modelcloud.ai, x.com/qubitium
5
+
6
+ from .defuser import convert_hf_model
@@ -0,0 +1,14 @@
1
+ # SPDX-FileCopyrightText: 2026 ModelCloud.ai
2
+ # SPDX-FileCopyrightText: 2026 qubitium@modelcloud.ai
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ # Contact: qubitium@modelcloud.ai, x.com/qubitium
5
+
6
+ from torch import nn
7
+
8
+ from defuser.utils.hf import apply_modeling_patch
9
+
10
+
11
+ def convert_hf_model(model: nn.Module) -> bool:
12
+ return apply_modeling_patch(model)
13
+
14
+ __all__ = ["convert_hf_model"]
@@ -0,0 +1,8 @@
1
+ # SPDX-FileCopyrightText: 2026 ModelCloud.ai
2
+ # SPDX-FileCopyrightText: 2026 qubitium@modelcloud.ai
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ # Contact: qubitium@modelcloud.ai, x.com/qubitium
5
+
6
+ import logging
7
+
8
+ logger = logging.getLogger("defuser")
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
9
9
 
10
10
  [project]
11
11
  name = "Defuser"
12
- version = "0.0.1"
12
+ version = "0.0.2"
13
13
  description = "Model defuser helper for HF Transformers."
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.9"
@@ -30,6 +30,9 @@ classifiers = [
30
30
  "Topic :: Text Processing :: Linguistic"
31
31
  ]
32
32
  keywords = ["Defuser", "Model", "HF", "Transformers"]
33
+ dependencies = [
34
+ "transformers",
35
+ ]
33
36
 
34
37
  [project.urls]
35
38
  Homepage = "https://github.com/ModelCloud/Defuser"
@@ -0,0 +1,18 @@
1
+ # SPDX-FileCopyrightText: 2026 ModelCloud.ai
2
+ # SPDX-FileCopyrightText: 2026 qubitium@modelcloud.ai
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ # Contact: qubitium@modelcloud.ai, x.com/qubitium
5
+ from transformers import AutoModelForCausalLM
6
+ from defuser import convert_hf_model
7
+
8
+
9
+ def test_qwen3_moe():
10
+ from defuser.modeling.unfused_moe.qwen3_moe import LinearQwen3MoeSparseMoeBlock
11
+
12
+ model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-30B-A3B")
13
+
14
+ assert model.config.model_type == "qwen3_moe"
15
+
16
+ converted = convert_hf_model(model)
17
+ assert converted
18
+ assert isinstance(model.model.layers[0].mlp, LinearQwen3MoeSparseMoeBlock)
defuser-0.0.1/README.md DELETED
@@ -1,2 +0,0 @@
1
- # Defuser
2
- Model defuser helper for HF Transformers
@@ -1 +0,0 @@
1
-
File without changes
File without changes
File without changes