-
Notifications
You must be signed in to change notification settings - Fork 267
Enable Int4WeightOnlyGPTQQuantizer on Intel GPU. #2200
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2200
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. |
8ce1b8b
to
eb73883
Compare
torchao/quantization/GPTQ.py
Outdated
@@ -561,6 +582,30 @@ def linear_forward_int4( | |||
return c | |||
|
|||
|
|||
def linear_forward_int4_zero_domain( |
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.
def linear_forward_int4_zero_domain( | |
def linear_forward_int4_zero_point_domain_int( |
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.
Modify done
torchao/quantization/utils.py
Outdated
@@ -364,6 +369,13 @@ def get_groupwise_affine_qparams( | |||
).reshape(w.shape[0], -1) | |||
|
|||
|
|||
def align_tinygemm_scales_and_zeros(scales, zeros): |
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.
Only use once. Suggest to remove this function.
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.
Modify done
@@ -436,6 +448,9 @@ def groupwise_affine_quantize_tensor_from_qparams( | |||
not (check_xpu_version(int_data.device)) | |||
): | |||
int_data = (int_data[::, ::2] << 4 | int_data[::, 1::2]).to(torch.uint8) | |||
if check_xpu_version(int_data.device): | |||
int_data = (int_data[::, 1::2] << 4 | int_data[::, ::2]).to(torch.uint8) | |||
|
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.
This function is also used by RTN path, this changes may break RTN, Pls double check.
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.
align all usages
torchao/quantization/README.md
Outdated
@@ -438,6 +438,7 @@ quantizer = Int4WeightOnlyGPTQQuantizer( | |||
percdamp, | |||
groupsize, | |||
) | |||
|
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.
@jerryzh168 Can you help to review this PR? |
Following pytorch/pytorch#153019 requests, we enable int4wo-GPTQ for Intel GPU in pytorch/ao after RTN ready. Currently, the implementation of int4wo-GPTQ uses the ZeroPointDomain.FLOAT and ZeroPointDomain.INT.
How to run int4wo-GPTQ with ZeroPointDomain.INT:
How to run int4wo-GPTQ with ZeroPointDomain.FLOAT: