init commit to refactor dit quant#90
Merged
Merged
Conversation
yghstill
reviewed
Oct 14, 2025
| print("scale1 shape: ", scale1.shape) | ||
|
|
||
| x = torch.randn(1024, 1024).cpu() | ||
| import pdb |
| """ | ||
| if x.numel() == 0: | ||
| min_val, max_val = ( | ||
| torch.tensor(-16.0, dtype=x.dtype), |
Contributor
Author
There was a problem hiding this comment.
这里是针对元素数量为0的情况,以满足对empty MoE expert的支持,16只是一个常规的fp8易于表示的数字
| __all__ = ["quantize_model_to_fp8"] | ||
|
|
||
|
|
||
| def quantize_model_to_fp8( |
Collaborator
There was a problem hiding this comment.
是否能以PTQ类的形式组织,初始化超参放入类成员变量,self.quantize函数执行具体量化逻辑,可走进fp8分支
Contributor
Author
There was a problem hiding this comment.
好的,将会在新的commit中体现
|
|
||
|
|
||
| # modified from https://github.com/neuralmagic/AutoFP8/blob/main/auto_fp8/quantize.py | ||
| class FP8DynamicLinear(torch.nn.Module): |
Collaborator
There was a problem hiding this comment.
FP8DynamicLinear以上的量化函数统一放入至quant_func.py,linear.py只存放量化linear类
…and wrap quantization function interfaces with classes.
yghstill
reviewed
Oct 15, 2025
|
|
||
| def _set_quantize_linear_module(self) -> torch.nn.Module: | ||
| """ | ||
| 返回用于替换nn.Linear的量化模块类型 |
yghstill
approved these changes
Oct 15, 2025
dawnranger
pushed a commit
to dawnranger/AngelSlim
that referenced
this pull request
Mar 11, 2026
Co-authored-by: garygugong <garygugong@tencent.com>
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.
This PR aims to refactor the compressor for DiT models.
The initial commit delivers a streamlined, plug-and-play implementation of w8a8 dynamic fp8 quantization along with a straightforward example.
Reference:
https://github.com/deepseek-ai/DeepSeek-V3
https://github.com/neuralmagic/AutoFP8
https://github.com/sgl-project/sglang