edgerazor 1.2.6__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.
- edgerazor-1.2.6/LICENSE +201 -0
- edgerazor-1.2.6/PKG-INFO +234 -0
- edgerazor-1.2.6/README.md +198 -0
- edgerazor-1.2.6/pyproject.toml +160 -0
- edgerazor-1.2.6/setup.cfg +4 -0
- edgerazor-1.2.6/src/edgerazor/__init__.py +57 -0
- edgerazor-1.2.6/src/edgerazor/edgerazor.py +173 -0
- edgerazor-1.2.6/src/edgerazor/edgerazor_config.py +554 -0
- edgerazor-1.2.6/src/edgerazor/kd/__init__.py +41 -0
- edgerazor-1.2.6/src/edgerazor/kd/kd.py +933 -0
- edgerazor-1.2.6/src/edgerazor/kd/util/__init__.py +29 -0
- edgerazor-1.2.6/src/edgerazor/kd/util/distill_config.py +228 -0
- edgerazor-1.2.6/src/edgerazor/kd/util/distill_function.py +459 -0
- edgerazor-1.2.6/src/edgerazor/kd/util/distill_function_config.py +47 -0
- edgerazor-1.2.6/src/edgerazor/kd/util/layer_select.py +88 -0
- edgerazor-1.2.6/src/edgerazor/kd/util/moe_loss.py +52 -0
- edgerazor-1.2.6/src/edgerazor/log.py +176 -0
- edgerazor-1.2.6/src/edgerazor/qat/__init__.py +40 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/__init__.py +31 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/qattn.py +458 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/qkv_cache_llama.py +134 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/qkv_cache_olmoe.py +449 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/qkv_cache_qwen2_5omni.py +151 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/qkv_cache_qwen3.py +142 -0
- edgerazor-1.2.6/src/edgerazor/qat/block/qkv_cache_qwen3moe.py +142 -0
- edgerazor-1.2.6/src/edgerazor/qat/map.py +606 -0
- edgerazor-1.2.6/src/edgerazor/qat/module/__init__.py +15 -0
- edgerazor-1.2.6/src/edgerazor/qat/module/qconv1d.py +157 -0
- edgerazor-1.2.6/src/edgerazor/qat/module/qconv2d.py +158 -0
- edgerazor-1.2.6/src/edgerazor/qat/module/qconv3d.py +159 -0
- edgerazor-1.2.6/src/edgerazor/qat/module/qembedding.py +112 -0
- edgerazor-1.2.6/src/edgerazor/qat/module/qlinear.py +178 -0
- edgerazor-1.2.6/src/edgerazor/qat/qat.py +643 -0
- edgerazor-1.2.6/src/edgerazor/qat/quantize.py +274 -0
- edgerazor-1.2.6/src/edgerazor/qat/util/__init__.py +5 -0
- edgerazor-1.2.6/src/edgerazor/qat/util/quant_config.py +741 -0
- edgerazor-1.2.6/src/edgerazor/qat/util/quant_function.py +1377 -0
- edgerazor-1.2.6/src/edgerazor/qat/util/quant_function_config.py +13 -0
- edgerazor-1.2.6/src/edgerazor/qat/util/quant_selector.py +159 -0
- edgerazor-1.2.6/src/edgerazor.egg-info/PKG-INFO +234 -0
- edgerazor-1.2.6/src/edgerazor.egg-info/SOURCES.txt +42 -0
- edgerazor-1.2.6/src/edgerazor.egg-info/dependency_links.txt +1 -0
- edgerazor-1.2.6/src/edgerazor.egg-info/requires.txt +15 -0
- edgerazor-1.2.6/src/edgerazor.egg-info/top_level.txt +1 -0
edgerazor-1.2.6/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 LAMDA
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
edgerazor-1.2.6/PKG-INFO
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edgerazor
|
|
3
|
+
Version: 1.2.6
|
|
4
|
+
Summary: EdgeRazor: Lightweight framework for Edge AI.
|
|
5
|
+
Author: Shu-Hao Zhang
|
|
6
|
+
Author-email: zhangsh@lamda.nju.edu.cn
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/zhangsq-nju/EdgeRazor
|
|
9
|
+
Keywords: Lightweight AI,Edge AI,Model Compression,Quantization-Aware Distillation,Quantization,Distillation,LLM,Lightweight LLM,LLM Compression,LLM Quantization,LLM Distillation
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: ==3.10.20
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: ruff>=0.13.1
|
|
24
|
+
Requires-Dist: transformers==4.57.1
|
|
25
|
+
Requires-Dist: pyyaml==6.0.3
|
|
26
|
+
Provides-Extra: cpu
|
|
27
|
+
Requires-Dist: torch==2.9.1; extra == "cpu"
|
|
28
|
+
Requires-Dist: torchvision==0.24.1; extra == "cpu"
|
|
29
|
+
Provides-Extra: cu126
|
|
30
|
+
Requires-Dist: torch==2.9.1; extra == "cu126"
|
|
31
|
+
Requires-Dist: torchvision==0.24.1; extra == "cu126"
|
|
32
|
+
Provides-Extra: cu128
|
|
33
|
+
Requires-Dist: torch==2.9.1; extra == "cu128"
|
|
34
|
+
Requires-Dist: torchvision==0.24.1; extra == "cu128"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
<div align="center">
|
|
38
|
+
<br/>
|
|
39
|
+
<img src="./asset/Logo-full.png" alt="EdgeRazor Logo" width="60%">
|
|
40
|
+
<h3>
|
|
41
|
+
Lightweight Framework for Edge AI
|
|
42
|
+
</h3>
|
|
43
|
+
|
|
44
|
+
<p>
|
|
45
|
+
<!-- <a href="https://arxiv.org/abs/2604.xxxxx" target="_blank">
|
|
46
|
+
<img src="https://img.shields.io/badge/arXiv-EdgeRazor-b31b1b?style=flat&logo=arxiv" alt="arXiv EdgeRazor">
|
|
47
|
+
</a> -->
|
|
48
|
+
<a href="https://huggingface.co/collections/zhangsq-nju/edgerazor-nbit" target="_blank">
|
|
49
|
+
<img src="https://img.shields.io/badge/HuggingFace-Collection-FFD21F?style=flat&logo=huggingface&logoColor=FFD21F" alt="Hugging Face Collection">
|
|
50
|
+
</a>
|
|
51
|
+
<a href="./README_ZH.md">
|
|
52
|
+
<img src="https://img.shields.io/badge/README-ZH-blue?style=flat&logo=readme" alt="README ZH">
|
|
53
|
+
</a>
|
|
54
|
+
<a href="https://github.com/zhangsq-nju/EdgeRazor/blob/main/LICENSE">
|
|
55
|
+
<img src="https://img.shields.io/badge/License-Apache_2.0-green?logo=opensourceinitiative&logoColor=green" alt="License: Apache 2.0">
|
|
56
|
+
</a>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
<h5>
|
|
60
|
+
✨ If you like our project, please give us a star ⭐️ for the latest update.
|
|
61
|
+
</h5>
|
|
62
|
+
|
|
63
|
+
<img src="./asset/Demo.gif" alt="EdgeRazor Demo" width="75%">
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
**EdgeRazor** is a unified and lightweight framework for edge AI, designed to train models that are smaller, faster, and deployable across diverse hardware, ranging from mobile and edge endpoints to latency-sensitive clouds. The EdgeRazor framework **seamlessly integrates** model compression techniques into existing full-precision training pipelines with **minimal code modification**, preserving promising task performance and enabling low-cost and high-efficiency computations.
|
|
69
|
+
|
|
70
|
+
EdgeRazor currently focuses on low-bit LLM compression via configurable quantization-aware distillation. In terms of **quantization**, EdgeRazor supports quantizing weights (including embedding and lm_head layers), activations, and KV cache. Quantized bit-widths include the uniform 1.58-bit and 4-bit, as well as matrix-wise mixed-precision, such as 2.79-bit (50% 4-bit + 50% 1.58-bit) and 1.88-bit (12.5% 4-bit + 87.5% 1.58-bit). In terms of **distillation**, EdgeRazor offers the logits, features, and attention distillation, all of which can be flexibly combined within a unified configuration interface.
|
|
71
|
+
|
|
72
|
+
EdgeRazor achieves the state-of-the-art performance across a range of models, including base LLMs, instruction-tuned LLMs, and multimodal LLMs. For W-A8-KV8 quantization, **Qwen3-0.6B-EdgeRazor** attains average scores of **47.80** / **44.10** / **41.76** / **39.81** at 4-bit / 2.79-bit / 1.88-bit / 1.58-bit, corresponding to compression ratios of **3.94×** / **5.05×** / **6.40×** / **7.03×**, respectively. In comparison, the best prior methods achieve <u>45.74</u> / <u>37.38</u> / <u>30.49</u> at 4-bit / 3-bit / 2-bit with compression ratios of <u>2.21×</u> / <u>2.47×</u> / <u>2.78×</u>.
|
|
73
|
+
|
|
74
|
+
<p align="center">
|
|
75
|
+
<img src="./asset/Architeacture.png" alt="EdgeRazor Architecture">
|
|
76
|
+
<br> Figure: The EdgeRazor framework with lightweight model training pipeline.
|
|
77
|
+
</p>
|
|
78
|
+
|
|
79
|
+
## News
|
|
80
|
+
|
|
81
|
+
- 🔥 **[2026-04]**: 🏆 Low-bit LLMs by EdgeRazor is released! Check our Hugging Face collection: [zhangsq-nju/edgerazor-nbit](https://huggingface.co/collections/zhangsq-nju/edgerazor-nbit).
|
|
82
|
+
- 🔥 **[2026-04]**: 🛠️ Open-sourced EdgeRazor-V1 is released! Now configurable on diverse models for seamless integration and customization!
|
|
83
|
+
- 🔥 **[2025-10]**: 📄 Paper-TernaryCLIP is available on arXiv: [2510.21879](https://arxiv.org/abs/2510.21879)!
|
|
84
|
+
<!-- - 🔥 **[2026-04]**: 📄 Paper-EdgeRazor is available on arXiv: [2604.xxxxx](https://arxiv.org/abs/2604.xxxxx)! -->
|
|
85
|
+
|
|
86
|
+
## Contents
|
|
87
|
+
|
|
88
|
+
- [News](#news)
|
|
89
|
+
- [Contents](#contents)
|
|
90
|
+
- [Getting Started](#getting-started)
|
|
91
|
+
- [Installation](#installation)
|
|
92
|
+
- [Usage](#usage)
|
|
93
|
+
- [Low-bit LLMs Serving on Docker](#low-bit-llms-serving-on-docker)
|
|
94
|
+
- [Main Techniques](#main-techniques)
|
|
95
|
+
- [Applications](#applications)
|
|
96
|
+
- [Model Zoo](#model-zoo)
|
|
97
|
+
- [LLMs](#llms)
|
|
98
|
+
- [MLLMs](#mllms)
|
|
99
|
+
- [Todo List](#todo-list)
|
|
100
|
+
- [Citation](#citation)
|
|
101
|
+
- [Contributor List](#contributor-list)
|
|
102
|
+
|
|
103
|
+
## Getting Started
|
|
104
|
+
|
|
105
|
+
### Installation
|
|
106
|
+
|
|
107
|
+
- Download from GitHub (latest version)
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
git clone https://github.com/zhangsq-nju/EdgeRazor.git && cd EdgeRazor
|
|
111
|
+
conda create -n edgerazor python=3.10.20 -y
|
|
112
|
+
conda activate edgerazor
|
|
113
|
+
pip install -e .[cu128]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Usage
|
|
117
|
+
|
|
118
|
+
After installation, you can integrate EdgeRazor into your existing training pipeline to build lightweight models.
|
|
119
|
+
|
|
120
|
+
1. Use unified configuration by [yaml](./example/configs/qad/qat_w4_a8_kd_fd.yaml), [json](./example/configs/qad/qat_w4_a8_kd_fd.json) or [dict](./example/configs/qad/qat_w4_a8_kd_fd.py).
|
|
121
|
+
|
|
122
|
+
2. Seamlessly integrate EdgeRazor into your FULL-PRECISION model training and enjoy your lightweight journey!
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
# Init EdgeRazor for lightweight model
|
|
126
|
+
edgerazor = EdgeRazor(config="/path/to/config.yaml")
|
|
127
|
+
student = edgerazor.quantize(student)
|
|
128
|
+
# Training loop
|
|
129
|
+
student_outputs = student(inputs)
|
|
130
|
+
teacher_outputs = teacher(inputs)
|
|
131
|
+
# Calculate loss
|
|
132
|
+
loss, loss_dict = edgerazor.compute_loss(student_outputs, teacher_outputs, labels)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Low-bit LLMs Serving on Docker
|
|
136
|
+
|
|
137
|
+
You can obtain lightweight models from checkpoints trained with EdgeRazor. For example, you can convert Qwen3-EdgeRazor-4bit checkpoints to Q4_0 GGUF models. We also provide ready-to-use quantized models in our [collection](https://huggingface.co/collections/zhangsq-nju/edgerazor-nbit), including [Qwen3-0.6B-EdgeRazor-GGUF](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF) and [Qwen3-1.7B-EdgeRazor-GGUF](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF).
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Serve quantized LLMs under CPU-only environments:
|
|
141
|
+
docker pull ghcr.io/ggml-org/llama.cpp:server
|
|
142
|
+
hf download zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF Qwen3-1.7B-EdgeRazor-TQ2_0.gguf --local-dir /path/to/Qwen3-1.7B-EdgeRazor-GGUF
|
|
143
|
+
cd ./docker && bash local_server_tq2_0.sh
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Main Techniques
|
|
147
|
+
|
|
148
|
+
Quantization-Aware Distillation (QAD):
|
|
149
|
+
|
|
150
|
+
- Configurable mixed-precision quantization for weights
|
|
151
|
+
- Configurable knowledge distillation pipelines between 16-bit and $n$-bit models
|
|
152
|
+
- Knowledge distillation methods: Adaptive Feature Distillation (AFD), Entropy-Aware KL Divergence (EAKLD)
|
|
153
|
+
|
|
154
|
+
## Applications
|
|
155
|
+
|
|
156
|
+
- Lightweight ViT-S/16, check [here](./example/vit/README.md).
|
|
157
|
+
- Lightweight ResNet-18, check [here](./example/resnet/README.md).
|
|
158
|
+
- Lightweight Qwen3-0.6B/1.7B, coming soon.
|
|
159
|
+
- Lightweight MobileLLM-ParetoQ-350M-BF16, coming soon.
|
|
160
|
+
- Lightweight Qwen2.5-Omni-7B, coming soon.
|
|
161
|
+
<!-- - Lightweight Qwen3-0.6B/1.7B, check [here](./example/qwen3/README.md).
|
|
162
|
+
- Lightweight MobileLLM-ParetoQ-350M-BF16, check [here](./example/mobilellm/README.md).
|
|
163
|
+
- Lightweight Qwen2.5-Omni-7B, check [here](./example/qwen2_5-omni/README.md). -->
|
|
164
|
+
|
|
165
|
+
## Model Zoo
|
|
166
|
+
|
|
167
|
+
### LLMs
|
|
168
|
+
|
|
169
|
+
- Average Performance (Avg.): average of performance scores in multiple tasks using [lm-eval v0.4.9.1](https://github.com/EleutherAI/lm-evaluation-harness/tree/v0.4.9.1) with [tasks](./src/eval/tasks/lm_eval/).
|
|
170
|
+
- Tasks for instruct LLMs: arc_easy, arc_challenge, hellaswag, boolq, social_iqa, openbookqa, piqa, winogrande, hendrycks_ethics, truthfulqa_mc2, mmlu, gsm8k, humaneval_instruct, ifeval.
|
|
171
|
+
- Tasks for base LLMs: arc_easy, arc_challenge, hellaswag, boolq, social_iqa, openbookqa, piqa, winogrande, hendrycks_ethics, truthfulqa_mc2, mmlu, gsm8k, humaneval.
|
|
172
|
+
- Except for 5-shot gsm8k, all other tasks are 0-shot.
|
|
173
|
+
|
|
174
|
+
- Hub Link: We provide the original quantized checkpoints. We also transfer the checkpoints into GGUF ([llama.cpp](https://github.com/ggml-org/llama.cpp)) and GPTQ ([GPTQModel](https://github.com/ModelCloud/GPTQModel), working in progress) formats if compatible.
|
|
175
|
+
|
|
176
|
+
| Model | W-A-KV | Group Size | Avg. | Hub Link |
|
|
177
|
+
| -------------- | ------------ | ---------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
178
|
+
| Qwen3-0.6B | W16-A16-KV16 | - | 47.35 | [Base](https://huggingface.co/Qwen/Qwen3-0.6B) |
|
|
179
|
+
| Qwen3-0.6B | W4-A8-KV8 | 256 | 47.80 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-4bit), [Q4_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF/resolve/main/Qwen3-0.6B-EdgeRazor-Q4_0.gguf) |
|
|
180
|
+
| Qwen3-0.6B | W2.79-A8-KV8 | 256 | 44.10 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-2.79bit) |
|
|
181
|
+
| Qwen3-0.6B | W1.88-A8-KV8 | 256 | 41.76 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-1.88bit) |
|
|
182
|
+
| Qwen3-0.6B | W1.58-A8-KV8 | 256 | 39.81 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-1.58bit), [TQ1_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF/resolve/main/Qwen3-0.6B-EdgeRazor-TQ1_0.gguf), [TQ2_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF/resolve/main/Qwen3-0.6B-EdgeRazor-TQ2_0.gguf) |
|
|
183
|
+
| Qwen3-1.7B | W16-A16-KV16 | - | 58.65 | [Base](https://huggingface.co/Qwen/Qwen3-1.7B) |
|
|
184
|
+
| Qwen3-1.7B | W4-A8-KV8 | 256 | 58.57 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-4bit), [Q4_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF/resolve/main/Qwen3-1.7B-EdgeRazor-Q4_0.gguf) |
|
|
185
|
+
| Qwen3-1.7B | W2.79-A8-KV8 | 256 | 53.00 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-2.79bit) |
|
|
186
|
+
| Qwen3-1.7B | W1.88-A8-KV8 | 256 | 47.14 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-1.88bit) |
|
|
187
|
+
| Qwen3-1.7B | W1.58-A8-KV8 | 256 | 43.91 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-1.58bit), [TQ1_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF/resolve/main/Qwen3-1.7B-EdgeRazor-TQ1_0.gguf), [TQ2_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF/resolve/main/Qwen3-1.7B-EdgeRazor-TQ2_0.gguf) |
|
|
188
|
+
| MobileLLM-350M | W16-A16-KV16 | - | 41.18 | [Base](https://huggingface.co/facebook/MobileLLM-ParetoQ-350M-BF16) |
|
|
189
|
+
| MobileLLM-350M | W4-A8-KV8 | 64 | 41.86 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-4bit) |
|
|
190
|
+
| MobileLLM-350M | W2.79-A8-KV8 | 64 | 40.62 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-2.79bit) |
|
|
191
|
+
| MobileLLM-350M | W1.88-A8-KV8 | 64 | 39.02 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-1.88bit) |
|
|
192
|
+
| MobileLLM-350M | W1.58-A8-KV8 | 64 | 38.12 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-1.58bit) |
|
|
193
|
+
|
|
194
|
+
### MLLMs
|
|
195
|
+
|
|
196
|
+
- Video-MME and MLVU are video understanding tasks using [lmms-eval v0.5.0](https://github.com/EvolvingLMMs-Lab/lmms-eval/tree/v0.5) with [tasks](./src/eval/tasks/lmms-eval/).
|
|
197
|
+
|
|
198
|
+
| Model | W-A-KV | Group Size | Video-MME | MLVU | Hub Link |
|
|
199
|
+
| --------------- | ------------ | ---------- | --------- | ----- | ------------------------------------------------------------------------------ |
|
|
200
|
+
| Qwen2.5-Omni-7B | W16-A16-KV16 | - | 62.81 | 48.01 | [Base](https://huggingface.co/Qwen/Qwen2.5-Omni-7B) |
|
|
201
|
+
| Qwen2.5-Omni-7B | W4-A16-KV16 | 32 | 62.22 | 48.82 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen2.5-Omni-7B-EdgeRazor-4bit) |
|
|
202
|
+
|
|
203
|
+
## Todo List
|
|
204
|
+
|
|
205
|
+
EdgeRazor is continuously evolving! Here's what's coming:
|
|
206
|
+
|
|
207
|
+
- [ ] Lightweight MobileLLM, Qwen3, and Qwen2.5-Omni: training code
|
|
208
|
+
- [ ] Support pypi installation
|
|
209
|
+
- [ ] Upgrade to support the newest dependencies
|
|
210
|
+
|
|
211
|
+
Have ideas or suggestions? We welcome and appreciate any contributions and collaborations! Please feel free to submit issues or pull requests! 🚀
|
|
212
|
+
|
|
213
|
+
## Citation
|
|
214
|
+
|
|
215
|
+
If you find our papar and code useful in your research, please consider kindly citing our papers ✏️:
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
@article{zhangsh-edgerazor,
|
|
219
|
+
title={{EdgeRazor}: A Lightweight Framework for Large Language Models via Mixed-Precision Quantization-Aware Distillation},
|
|
220
|
+
author={Shu-Hao Zhang and Le-Tong Huang and Xiang-Sheng Deng and Xin-Yi Zou and Chen Wu and Nan Li and Shao-Qun Zhang},
|
|
221
|
+
year={2026},
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@article{zhangsh-ternaryclip,
|
|
225
|
+
title={{TernaryCLIP}: Efficiently Compressing Vision-Language Models with Ternary Weights and Distilled Knowledge},
|
|
226
|
+
author={Shu-Hao Zhang and Wei-Cheng Tang and Chen Wu and Peng Hu and Nan Li and Liang-Jie Zhang and Qi Zhang and Shao-Qun Zhang},
|
|
227
|
+
year={2025},
|
|
228
|
+
journal={arXiv preprint arXiv:2510.21879}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Contributor List
|
|
233
|
+
|
|
234
|
+
This project was supported by [LAMDA Lab](https://www.lamda.nju.edu.cn) and Assistant Professor [Shao-Qun Zhang](https://www.lamda.nju.edu.cn/zhangsq). [Shu-Hao Zhang](https://github.com/zhsh9) is the core developer and maintainer of EdgeRazor-V1. [Xiang-Sheng Deng](https://github.com/deng-xiangsheng) and [Le-Tong Huang](https://github.com/LT1923) jointly participated in the development of this project.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<br/>
|
|
3
|
+
<img src="./asset/Logo-full.png" alt="EdgeRazor Logo" width="60%">
|
|
4
|
+
<h3>
|
|
5
|
+
Lightweight Framework for Edge AI
|
|
6
|
+
</h3>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<!-- <a href="https://arxiv.org/abs/2604.xxxxx" target="_blank">
|
|
10
|
+
<img src="https://img.shields.io/badge/arXiv-EdgeRazor-b31b1b?style=flat&logo=arxiv" alt="arXiv EdgeRazor">
|
|
11
|
+
</a> -->
|
|
12
|
+
<a href="https://huggingface.co/collections/zhangsq-nju/edgerazor-nbit" target="_blank">
|
|
13
|
+
<img src="https://img.shields.io/badge/HuggingFace-Collection-FFD21F?style=flat&logo=huggingface&logoColor=FFD21F" alt="Hugging Face Collection">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="./README_ZH.md">
|
|
16
|
+
<img src="https://img.shields.io/badge/README-ZH-blue?style=flat&logo=readme" alt="README ZH">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://github.com/zhangsq-nju/EdgeRazor/blob/main/LICENSE">
|
|
19
|
+
<img src="https://img.shields.io/badge/License-Apache_2.0-green?logo=opensourceinitiative&logoColor=green" alt="License: Apache 2.0">
|
|
20
|
+
</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<h5>
|
|
24
|
+
✨ If you like our project, please give us a star ⭐️ for the latest update.
|
|
25
|
+
</h5>
|
|
26
|
+
|
|
27
|
+
<img src="./asset/Demo.gif" alt="EdgeRazor Demo" width="75%">
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
**EdgeRazor** is a unified and lightweight framework for edge AI, designed to train models that are smaller, faster, and deployable across diverse hardware, ranging from mobile and edge endpoints to latency-sensitive clouds. The EdgeRazor framework **seamlessly integrates** model compression techniques into existing full-precision training pipelines with **minimal code modification**, preserving promising task performance and enabling low-cost and high-efficiency computations.
|
|
33
|
+
|
|
34
|
+
EdgeRazor currently focuses on low-bit LLM compression via configurable quantization-aware distillation. In terms of **quantization**, EdgeRazor supports quantizing weights (including embedding and lm_head layers), activations, and KV cache. Quantized bit-widths include the uniform 1.58-bit and 4-bit, as well as matrix-wise mixed-precision, such as 2.79-bit (50% 4-bit + 50% 1.58-bit) and 1.88-bit (12.5% 4-bit + 87.5% 1.58-bit). In terms of **distillation**, EdgeRazor offers the logits, features, and attention distillation, all of which can be flexibly combined within a unified configuration interface.
|
|
35
|
+
|
|
36
|
+
EdgeRazor achieves the state-of-the-art performance across a range of models, including base LLMs, instruction-tuned LLMs, and multimodal LLMs. For W-A8-KV8 quantization, **Qwen3-0.6B-EdgeRazor** attains average scores of **47.80** / **44.10** / **41.76** / **39.81** at 4-bit / 2.79-bit / 1.88-bit / 1.58-bit, corresponding to compression ratios of **3.94×** / **5.05×** / **6.40×** / **7.03×**, respectively. In comparison, the best prior methods achieve <u>45.74</u> / <u>37.38</u> / <u>30.49</u> at 4-bit / 3-bit / 2-bit with compression ratios of <u>2.21×</u> / <u>2.47×</u> / <u>2.78×</u>.
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<img src="./asset/Architeacture.png" alt="EdgeRazor Architecture">
|
|
40
|
+
<br> Figure: The EdgeRazor framework with lightweight model training pipeline.
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
## News
|
|
44
|
+
|
|
45
|
+
- 🔥 **[2026-04]**: 🏆 Low-bit LLMs by EdgeRazor is released! Check our Hugging Face collection: [zhangsq-nju/edgerazor-nbit](https://huggingface.co/collections/zhangsq-nju/edgerazor-nbit).
|
|
46
|
+
- 🔥 **[2026-04]**: 🛠️ Open-sourced EdgeRazor-V1 is released! Now configurable on diverse models for seamless integration and customization!
|
|
47
|
+
- 🔥 **[2025-10]**: 📄 Paper-TernaryCLIP is available on arXiv: [2510.21879](https://arxiv.org/abs/2510.21879)!
|
|
48
|
+
<!-- - 🔥 **[2026-04]**: 📄 Paper-EdgeRazor is available on arXiv: [2604.xxxxx](https://arxiv.org/abs/2604.xxxxx)! -->
|
|
49
|
+
|
|
50
|
+
## Contents
|
|
51
|
+
|
|
52
|
+
- [News](#news)
|
|
53
|
+
- [Contents](#contents)
|
|
54
|
+
- [Getting Started](#getting-started)
|
|
55
|
+
- [Installation](#installation)
|
|
56
|
+
- [Usage](#usage)
|
|
57
|
+
- [Low-bit LLMs Serving on Docker](#low-bit-llms-serving-on-docker)
|
|
58
|
+
- [Main Techniques](#main-techniques)
|
|
59
|
+
- [Applications](#applications)
|
|
60
|
+
- [Model Zoo](#model-zoo)
|
|
61
|
+
- [LLMs](#llms)
|
|
62
|
+
- [MLLMs](#mllms)
|
|
63
|
+
- [Todo List](#todo-list)
|
|
64
|
+
- [Citation](#citation)
|
|
65
|
+
- [Contributor List](#contributor-list)
|
|
66
|
+
|
|
67
|
+
## Getting Started
|
|
68
|
+
|
|
69
|
+
### Installation
|
|
70
|
+
|
|
71
|
+
- Download from GitHub (latest version)
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
git clone https://github.com/zhangsq-nju/EdgeRazor.git && cd EdgeRazor
|
|
75
|
+
conda create -n edgerazor python=3.10.20 -y
|
|
76
|
+
conda activate edgerazor
|
|
77
|
+
pip install -e .[cu128]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Usage
|
|
81
|
+
|
|
82
|
+
After installation, you can integrate EdgeRazor into your existing training pipeline to build lightweight models.
|
|
83
|
+
|
|
84
|
+
1. Use unified configuration by [yaml](./example/configs/qad/qat_w4_a8_kd_fd.yaml), [json](./example/configs/qad/qat_w4_a8_kd_fd.json) or [dict](./example/configs/qad/qat_w4_a8_kd_fd.py).
|
|
85
|
+
|
|
86
|
+
2. Seamlessly integrate EdgeRazor into your FULL-PRECISION model training and enjoy your lightweight journey!
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# Init EdgeRazor for lightweight model
|
|
90
|
+
edgerazor = EdgeRazor(config="/path/to/config.yaml")
|
|
91
|
+
student = edgerazor.quantize(student)
|
|
92
|
+
# Training loop
|
|
93
|
+
student_outputs = student(inputs)
|
|
94
|
+
teacher_outputs = teacher(inputs)
|
|
95
|
+
# Calculate loss
|
|
96
|
+
loss, loss_dict = edgerazor.compute_loss(student_outputs, teacher_outputs, labels)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Low-bit LLMs Serving on Docker
|
|
100
|
+
|
|
101
|
+
You can obtain lightweight models from checkpoints trained with EdgeRazor. For example, you can convert Qwen3-EdgeRazor-4bit checkpoints to Q4_0 GGUF models. We also provide ready-to-use quantized models in our [collection](https://huggingface.co/collections/zhangsq-nju/edgerazor-nbit), including [Qwen3-0.6B-EdgeRazor-GGUF](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF) and [Qwen3-1.7B-EdgeRazor-GGUF](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF).
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Serve quantized LLMs under CPU-only environments:
|
|
105
|
+
docker pull ghcr.io/ggml-org/llama.cpp:server
|
|
106
|
+
hf download zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF Qwen3-1.7B-EdgeRazor-TQ2_0.gguf --local-dir /path/to/Qwen3-1.7B-EdgeRazor-GGUF
|
|
107
|
+
cd ./docker && bash local_server_tq2_0.sh
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Main Techniques
|
|
111
|
+
|
|
112
|
+
Quantization-Aware Distillation (QAD):
|
|
113
|
+
|
|
114
|
+
- Configurable mixed-precision quantization for weights
|
|
115
|
+
- Configurable knowledge distillation pipelines between 16-bit and $n$-bit models
|
|
116
|
+
- Knowledge distillation methods: Adaptive Feature Distillation (AFD), Entropy-Aware KL Divergence (EAKLD)
|
|
117
|
+
|
|
118
|
+
## Applications
|
|
119
|
+
|
|
120
|
+
- Lightweight ViT-S/16, check [here](./example/vit/README.md).
|
|
121
|
+
- Lightweight ResNet-18, check [here](./example/resnet/README.md).
|
|
122
|
+
- Lightweight Qwen3-0.6B/1.7B, coming soon.
|
|
123
|
+
- Lightweight MobileLLM-ParetoQ-350M-BF16, coming soon.
|
|
124
|
+
- Lightweight Qwen2.5-Omni-7B, coming soon.
|
|
125
|
+
<!-- - Lightweight Qwen3-0.6B/1.7B, check [here](./example/qwen3/README.md).
|
|
126
|
+
- Lightweight MobileLLM-ParetoQ-350M-BF16, check [here](./example/mobilellm/README.md).
|
|
127
|
+
- Lightweight Qwen2.5-Omni-7B, check [here](./example/qwen2_5-omni/README.md). -->
|
|
128
|
+
|
|
129
|
+
## Model Zoo
|
|
130
|
+
|
|
131
|
+
### LLMs
|
|
132
|
+
|
|
133
|
+
- Average Performance (Avg.): average of performance scores in multiple tasks using [lm-eval v0.4.9.1](https://github.com/EleutherAI/lm-evaluation-harness/tree/v0.4.9.1) with [tasks](./src/eval/tasks/lm_eval/).
|
|
134
|
+
- Tasks for instruct LLMs: arc_easy, arc_challenge, hellaswag, boolq, social_iqa, openbookqa, piqa, winogrande, hendrycks_ethics, truthfulqa_mc2, mmlu, gsm8k, humaneval_instruct, ifeval.
|
|
135
|
+
- Tasks for base LLMs: arc_easy, arc_challenge, hellaswag, boolq, social_iqa, openbookqa, piqa, winogrande, hendrycks_ethics, truthfulqa_mc2, mmlu, gsm8k, humaneval.
|
|
136
|
+
- Except for 5-shot gsm8k, all other tasks are 0-shot.
|
|
137
|
+
|
|
138
|
+
- Hub Link: We provide the original quantized checkpoints. We also transfer the checkpoints into GGUF ([llama.cpp](https://github.com/ggml-org/llama.cpp)) and GPTQ ([GPTQModel](https://github.com/ModelCloud/GPTQModel), working in progress) formats if compatible.
|
|
139
|
+
|
|
140
|
+
| Model | W-A-KV | Group Size | Avg. | Hub Link |
|
|
141
|
+
| -------------- | ------------ | ---------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
142
|
+
| Qwen3-0.6B | W16-A16-KV16 | - | 47.35 | [Base](https://huggingface.co/Qwen/Qwen3-0.6B) |
|
|
143
|
+
| Qwen3-0.6B | W4-A8-KV8 | 256 | 47.80 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-4bit), [Q4_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF/resolve/main/Qwen3-0.6B-EdgeRazor-Q4_0.gguf) |
|
|
144
|
+
| Qwen3-0.6B | W2.79-A8-KV8 | 256 | 44.10 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-2.79bit) |
|
|
145
|
+
| Qwen3-0.6B | W1.88-A8-KV8 | 256 | 41.76 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-1.88bit) |
|
|
146
|
+
| Qwen3-0.6B | W1.58-A8-KV8 | 256 | 39.81 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-1.58bit), [TQ1_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF/resolve/main/Qwen3-0.6B-EdgeRazor-TQ1_0.gguf), [TQ2_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-0.6B-EdgeRazor-GGUF/resolve/main/Qwen3-0.6B-EdgeRazor-TQ2_0.gguf) |
|
|
147
|
+
| Qwen3-1.7B | W16-A16-KV16 | - | 58.65 | [Base](https://huggingface.co/Qwen/Qwen3-1.7B) |
|
|
148
|
+
| Qwen3-1.7B | W4-A8-KV8 | 256 | 58.57 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-4bit), [Q4_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF/resolve/main/Qwen3-1.7B-EdgeRazor-Q4_0.gguf) |
|
|
149
|
+
| Qwen3-1.7B | W2.79-A8-KV8 | 256 | 53.00 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-2.79bit) |
|
|
150
|
+
| Qwen3-1.7B | W1.88-A8-KV8 | 256 | 47.14 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-1.88bit) |
|
|
151
|
+
| Qwen3-1.7B | W1.58-A8-KV8 | 256 | 43.91 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-1.58bit), [TQ1_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF/resolve/main/Qwen3-1.7B-EdgeRazor-TQ1_0.gguf), [TQ2_0.gguf](https://huggingface.co/zhangsq-nju/Qwen3-1.7B-EdgeRazor-GGUF/resolve/main/Qwen3-1.7B-EdgeRazor-TQ2_0.gguf) |
|
|
152
|
+
| MobileLLM-350M | W16-A16-KV16 | - | 41.18 | [Base](https://huggingface.co/facebook/MobileLLM-ParetoQ-350M-BF16) |
|
|
153
|
+
| MobileLLM-350M | W4-A8-KV8 | 64 | 41.86 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-4bit) |
|
|
154
|
+
| MobileLLM-350M | W2.79-A8-KV8 | 64 | 40.62 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-2.79bit) |
|
|
155
|
+
| MobileLLM-350M | W1.88-A8-KV8 | 64 | 39.02 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-1.88bit) |
|
|
156
|
+
| MobileLLM-350M | W1.58-A8-KV8 | 64 | 38.12 | [EdgeRazor](https://huggingface.co/zhangsq-nju/MobileLLM-350M-EdgeRazor-1.58bit) |
|
|
157
|
+
|
|
158
|
+
### MLLMs
|
|
159
|
+
|
|
160
|
+
- Video-MME and MLVU are video understanding tasks using [lmms-eval v0.5.0](https://github.com/EvolvingLMMs-Lab/lmms-eval/tree/v0.5) with [tasks](./src/eval/tasks/lmms-eval/).
|
|
161
|
+
|
|
162
|
+
| Model | W-A-KV | Group Size | Video-MME | MLVU | Hub Link |
|
|
163
|
+
| --------------- | ------------ | ---------- | --------- | ----- | ------------------------------------------------------------------------------ |
|
|
164
|
+
| Qwen2.5-Omni-7B | W16-A16-KV16 | - | 62.81 | 48.01 | [Base](https://huggingface.co/Qwen/Qwen2.5-Omni-7B) |
|
|
165
|
+
| Qwen2.5-Omni-7B | W4-A16-KV16 | 32 | 62.22 | 48.82 | [EdgeRazor](https://huggingface.co/zhangsq-nju/Qwen2.5-Omni-7B-EdgeRazor-4bit) |
|
|
166
|
+
|
|
167
|
+
## Todo List
|
|
168
|
+
|
|
169
|
+
EdgeRazor is continuously evolving! Here's what's coming:
|
|
170
|
+
|
|
171
|
+
- [ ] Lightweight MobileLLM, Qwen3, and Qwen2.5-Omni: training code
|
|
172
|
+
- [ ] Support pypi installation
|
|
173
|
+
- [ ] Upgrade to support the newest dependencies
|
|
174
|
+
|
|
175
|
+
Have ideas or suggestions? We welcome and appreciate any contributions and collaborations! Please feel free to submit issues or pull requests! 🚀
|
|
176
|
+
|
|
177
|
+
## Citation
|
|
178
|
+
|
|
179
|
+
If you find our papar and code useful in your research, please consider kindly citing our papers ✏️:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
@article{zhangsh-edgerazor,
|
|
183
|
+
title={{EdgeRazor}: A Lightweight Framework for Large Language Models via Mixed-Precision Quantization-Aware Distillation},
|
|
184
|
+
author={Shu-Hao Zhang and Le-Tong Huang and Xiang-Sheng Deng and Xin-Yi Zou and Chen Wu and Nan Li and Shao-Qun Zhang},
|
|
185
|
+
year={2026},
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@article{zhangsh-ternaryclip,
|
|
189
|
+
title={{TernaryCLIP}: Efficiently Compressing Vision-Language Models with Ternary Weights and Distilled Knowledge},
|
|
190
|
+
author={Shu-Hao Zhang and Wei-Cheng Tang and Chen Wu and Peng Hu and Nan Li and Liang-Jie Zhang and Qi Zhang and Shao-Qun Zhang},
|
|
191
|
+
year={2025},
|
|
192
|
+
journal={arXiv preprint arXiv:2510.21879}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Contributor List
|
|
197
|
+
|
|
198
|
+
This project was supported by [LAMDA Lab](https://www.lamda.nju.edu.cn) and Assistant Professor [Shao-Qun Zhang](https://www.lamda.nju.edu.cn/zhangsq). [Shu-Hao Zhang](https://github.com/zhsh9) is the core developer and maintainer of EdgeRazor-V1. [Xiang-Sheng Deng](https://github.com/deng-xiangsheng) and [Le-Tong Huang](https://github.com/LT1923) jointly participated in the development of this project.
|