-
Notifications
You must be signed in to change notification settings - Fork 209
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
Consolidate ZeroPointDomain.NONE
& None
zero point domains
#1556
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/1556
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit cf90998 with merge base 47f96f1 (): NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
473c42f
to
c53a9d5
Compare
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
Thanks for reviewing, @jerryzh168! I'll fix the lint error once other CI checks would complete. |
This comment was marked as outdated.
This comment was marked as outdated.
The UTs that failed are failing because of some Inductor codegen issues that have since been fixed, but the CI jobs used PyTorch v2.4. I'll skip some of those UTs, so that they'd run with PyTorch v2.5 & beyond instead. Thanks! |
for https://github.com/pytorch/ao/actions/runs/12760810579/job/35567540271?pr=1556 you can install pre-commit
and run it:
then it will run the formatting before every |
837ee22
to
c44df1f
Compare
c83f470
to
da2e9e0
Compare
ZeroPointDomain.NONE
& None
zero point domains
@@ -199,7 +200,6 @@ def test_linear_observer_tensor(self, observe_weight: bool): | |||
input_scale.item(), | |||
max_val / max_fp8, | |||
) | |||
self.assertIsNotNone(input_zero_point) |
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.
is there a change of behavior when you change zero_point_domain for None to ZeroPointDomain.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.
Yes, input_zero_point
would now be None. So, instead of removing that line, I now added self.assertIsNone(input_zero_point)
. Thanks!
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 see, so what is the meaning of zero_point_domain
== None before?
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.
Looks like some APIs/implementations were creating/expecting a None
zero_point
when zero_point_domain
ZeroPointDomain.NONE
or None
was used, while choose_qparams_affine
was not.
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.
Hi @jerryzh168, is it possible that some torchao users' code may be expecting a non-None zero_point
with zero_point_domain ZeroPointDomain.NONE
/None, making this change BC-breaking for them? Thanks!
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 that most usages of this function are internal to torchao so that its okay to BC break, you can add the label just to be sure
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 your advice, @drisspg!
Could you please help add such a label as GitHub isn't displaying an option to me for adding it? Thanks!
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 added a bc-breaking label, please also write a bc-breaking note similar to #1049
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 again, @jerryzh168! I added a note & rebased the PR.
cd7abef
to
8116c0c
Compare
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, please rebase and land
Summary
ZeroPointDomain.NONE
&None
zero point domains were being used. The latter was being used for float8. This PR consolidates both & retainsZeroPointDomain.NONE
ZeroPointDomain.NONE
would now produceNone
for zero-pointint8_dynamic_activation_int8_weight
now usesZeroPointDomain.NONE
as weight zero point domain (as weight is quantized symmetrically to int8).Some of the older changes in this PR (such as supporting torch.compile with optional zero_point) were rendered redundant by more recent changes in the main branch, so I removed them & modified the description accordingly. Thanks!
BC-breaking note:
A
None
value forzero_point_domain
would no longer be accepted. Please useZeroPointDomain.NONE
instead.A
None
zero-point would be generated ifZeroPointDomain.NONE
would be used.Before this PR:
None
value ofzero_point_domain
was being used for quantization to float8 dtypes to indicate the absence of a zero-point.ZeroPointDomain.NONE
was being used for quantization to non-float8 dtypes to indicate the absence of a zero-point.choose_qparams_affine
returned a non-None zero-point for symmetric quantization.After this PR lands:
ZeroPointDomain.NONE
value forzero_point_domain
should be used to denote the absence of a zero-point.zero point in such cases would be
None
.APIs affected:
For the following user-facing APIs, a
None
zero_point_domain
can no longer be used with the following APIs (ZeroPointDomain.NONE should be used instead ofNone
) -torchao.quantization.quant_api.int4_weight_only
zero_point_domain
is no longer optional for the following developer-facing APIs -torchao.quantization.quant_primitives.choose_qparams_affine
torchao.quantization.quant_primitives.choose_qparams_affine_with_min_max
torchao.quantization.quant_primitives.fake_quantize_affine_cachemask
torchao.quantization.quant_primitives.quantize_affine
torchao.quantization.observer.AffineQuantizedObserverBase
torchao.dtypes.uintx.marlin_qqq_tensor.MarlinQQQTensor.from_hp_to_intx
torchao.dtypes.AffineQuantizedTensor.from_hp_to_intx
torchao.dtypes.AffineQuantizedTensor.from_hp_to_intx_static
For the following developer-facing APIs, a
None
zero_point_domain
can no longer be used with the following APIs (ZeroPointDomain.NONE should be used instead ofNone
) -torchao.quantization.quant_primitives.fake_quantize_affine
torchao.quantization.quant_primitives.dequantize_affine
torchao.quantization.qat.FakeQuantizeConfig
For the following internal APIs (whose names begin with an underscore character),
zero_point_domain
can no longer beNone
(ZeroPointDomain.NONE
should be used instead ofNone
):torchao.quantization.qat._ToAffineFakeQuantized