-
Notifications
You must be signed in to change notification settings - Fork 294
Align scale dtype with model precision in GPTQ #2403
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?
Align scale dtype with model precision in GPTQ #2403
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2403
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 7f74703 with merge base d506cc7 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@liangan1 @jerryzh168 please help to review this pr. |
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.
LGTM
a6f03f8
to
7f74703
Compare
@@ -295,7 +295,7 @@ def __torch_function__( | |||
SQNR(DQ, DQ_from_qtensor), | |||
) | |||
|
|||
qparams2 = cls.get_qparams_func(W) | |||
qparams2 = cls.get_qparams_func(W, W.dtype) |
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.
thoughts on changing https://github.com/pytorch/ao/blob/994a4ba6c869854fcaa6ca7e118fcbd75e6c28cc/torchao/quantization/utils.py#L335C5-L335C10 to use w.dtype
by default?
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.
No. For gptq algorithm, the original implement for weight scales calculation does not specify scale dtype, and use default dtype=bfloat16 of get_groupwise_affine_qparams function. And it's not suitable for other model-precision. We want to align the scale data type with linear weight primitive type. Therefore, the modification passes a dtype parameter to get_groupwise_affine_qparams.
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.
you mean it's required for gptq algorithm to use hardcoded bfloat16 by default?
And it's not suitable for other model-precision.
what does this mean?
Summary:
For general usage, align the data type of scale with model precision Instead of the default use of bfloat16.