-
Notifications
You must be signed in to change notification settings - Fork 273
[CPU] Enable DA8W4 on CPU #2128
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/2128
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 369000f with merge base 60d63a6 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
test/quantization/test_quant_api.py
Outdated
torch.compile(m, fullgraph=True, dynamic=True), | ||
*example_inputs, | ||
) | ||
assert "_weight_int4pack_mm_for_cpu" in code[0] |
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 remember this op is weight only quant?
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.
Yes. This op is used here because we don't have an op to compute da8w4 on CPU yet. So it will fallback to explicit dequantization and call of this op.
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 have re-implemented the path. Now we use a new layout for da8w4. Thanks.
@leslie-fang-intel This PR is updated to use a new layout. Please review again. Thanks. |
args[0].scales, | ||
args[0].qzeros, | ||
not args[0].transposed, | ||
args[0]._layout, |
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.
Could you explain more about the implementation of aten.t.default
for DA8W4CPUAQTTensorImpl
? It seems we only changes the transposed
flag here? Do we have testcase to cover it?
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. There is a comment explaining this just above. And this is a copy from the Int4CPULayout
. We have it here because Int4CPULayout
has it. And I am afraid there is not a UT for it. And it seems unused when running models. Do you want me to remove it?
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.
yean, how about we remove it at now and add it back with the UT when met the use case.
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 have removed it. Thanks.
Hi @jerryzh168 Could you please review this PR? Thanks. |
2 similar comments
Hi @jerryzh168 Could you please review this PR? Thanks. |
Hi @jerryzh168 Could you please review this PR? Thanks. |
Summary
This PR enables DA8W4 on CPU.
Int8DynamicActInt4WeightCPULayout
and its implementationda8w4_linear_prepack_cpu
for weight packing andda8w4_linear_cpu
for DA8W4 GEMM.The ops and kernels won't be available unless torchao is built from source with
USE_CPP_KERNELS=1
on Linux only.Test plan