feat: add SpinQuant offline rotation and integrate with PTQ pipeline#262
Merged
Conversation
- Add angelslim/compressor/transform/ package:
- TransformBase abstract class and TransformFactory with @register decorator
- SpinQuant implementation: R1/R2/R4 offline Hadamard rotation fused into weights
- SpinQuantMapping for LLaMA/Qwen layer name resolution
- fuse_ln_linear, center_embeddings utilities; hadamard_utils
- Integrate transform into PTQ: TransformFactory.create() + run() is called
before quantization in PTQ.__init__()
- Extend config_parser: add TransformConfig, FullConfig.transform_config,
SlimConfigParser support for optional transform: YAML section
- Add Engine.prepare_compressor(transform_config=) passthrough and lm_eval()
- Add tools/run_transform_offline.py for standalone transform + save
- Add configs/qwen3/spinquant/ with SpinQuant + fp8_static / int4_awq examples
eee33f4 to
2a0d11c
Compare
added 2 commits
March 17, 2026 22:58
yghstill
reviewed
Mar 17, 2026
|
|
||
| # Step 7: Save compressed model | ||
| def find_modules_with_hooks(model: torch.nn.Module): | ||
| """查找并打印模型中所有带有 hook 的子模块""" |
| global: | ||
| save_path: ./output | ||
|
|
||
|
|
Collaborator
There was a problem hiding this comment.
qwen3-8b_int4_awq.yaml应该不用修改?
Collaborator
Author
There was a problem hiding this comment.
不用改,是因为之前改了别的路径,不小心commit了,重新改了回去
| @@ -0,0 +1,77 @@ | |||
| # coding=utf-8 | |||
Collaborator
There was a problem hiding this comment.
注意引用规范,使用Tencent的声明
参考自其他库的在下方注明
Collaborator
There was a problem hiding this comment.
hadamard_utils.py这个文件行数是否有方法精简,近10w行文件会不会过大
Collaborator
Author
There was a problem hiding this comment.
这个文件行数多是因为有些特殊的shape(非二次幂),需要单独设置hadamard核,把hadamard核函数写到文件里了,所以看起来行数比较多。精简的话可能通用性降低
yghstill
approved these changes
Mar 18, 2026
linchuanxie
reviewed
Mar 18, 2026
| embedding.weight.data = new_weight | ||
|
|
||
|
|
||
| # [TODO] check this function correct or not |
linchuanxie
reviewed
Mar 18, 2026
Collaborator
There was a problem hiding this comment.
这里面的mapping是适用于某一个模型还是都要适用,是否需要扩充
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add SpinQuant offline rotation and integrate with PTQ pipeline