-
Notifications
You must be signed in to change notification settings - Fork 390
Separately control the activation quantization granularity #3524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Cui, Lily <[email protected]>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3524
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torchao/prototype/smoothquant/api.py
Outdated
| else: | ||
| raise ValueError(f"Unexpected step: {step}") | ||
|
|
||
| if isinstance(base_config, Int8StaticActivationInt8WeightConfig): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think smoothquant should not mention specific configs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment, updated.
torchao/quantization/quant_api.py
Outdated
|
|
||
| scale: torch.Tensor | ||
| granularity: Granularity = PerRow() | ||
| act_granularity: Granularity = PerTensor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we just use tuple, like this:
ao/torchao/quantization/quant_api.py
Line 1592 in 428bbcf
| granularity: Optional[Union[FP8Granularity, List[FP8Granularity]]] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment, updated.
Signed-off-by: Cui, Lily <[email protected]>
torchao/quantization/quant_api.py
Outdated
| ): | ||
| assert config.granularity in {PerRow(), PerTensor()}, ( | ||
| "Only PerRow and PerTensor is supported currently" | ||
| assert isinstance(config.granularity, (tuple, list)) and len(config.granularity) == 2, ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the code above, it can only be a list, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment, updated.
| if isinstance(base_config, Int8StaticActivationInt8WeightConfig): | ||
| quantize_( | ||
| basic_model, | ||
| Int8DynamicActivationInt8WeightConfig( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dynamic or static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing static, It uses dynamic as the basic model. Otherwise, directly quantizing the static config as the basic config will result in errors due to missing act_scale computed by static_scale.
Signed-off-by: Cui, Lily <[email protected]>
Signed-off-by: Cui, Lily <[email protected]>
Based on #3468
Separately control the activation quantization granularity and weight quantization granularity