Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xiaowangintel
Copy link
Contributor

@xiaowangintel xiaowangintel commented Jun 18, 2025

Summary:
For general usage, align the data type of scale with model precision Instead of the default use of bfloat16.

Copy link

pytorch-bot bot commented Jun 18, 2025

🔗 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 Failures

As of commit 7f74703 with merge base d506cc7 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2025
@xiaowangintel xiaowangintel changed the title Align scale dtype with weight in GPTQ Align scale dtype with model precision in GPTQ Jun 18, 2025
@xiaowangintel
Copy link
Contributor Author

@liangan1 @jerryzh168 please help to review this pr.

Copy link
Contributor

@liangan1 liangan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xiaowangintel xiaowangintel force-pushed the xw/int4-gptq-scale-type-align branch from a6f03f8 to 7f74703 Compare June 24, 2025 06:36
@Xia-Weiwen Xia-Weiwen added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Jun 25, 2025
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@xiaowangintel xiaowangintel Jun 30, 2025

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.

Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants