-
Notifications
You must be signed in to change notification settings - Fork 344
Drop old quantization flows #3115
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/3115
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 4651e63 with merge base c96f2dd ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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.
How about inlining _int8wo_api
, _int8da_int8w_api
, _int4wo_api
? They are used only once across codebase.
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.
yeah I think that's fine if they're only used in benchmarks
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.
also cc @jainapurva, can you take a look at the benchmark changes?
print("_int8da_int8w_api") | ||
|
||
for M, N, K in all_shapes: | ||
_bench_quantized_tensor_subclass_perf( |
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.
Temporarily updated to use new APIs 2 times to fix CI, but maybe we can update _bench_quantized_tensor_subclass_perf
to compare only original vs. new quantization flows?
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 @namgyu-youn, thanks for working on this. I think it looks good overall, but seems like we removed some things outside the scope of #2745, like smoothquant. Can you please add these back?
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.
yeah I think that's fine if they're only used in benchmarks
@@ -1,266 +0,0 @@ | |||
# Copyright (c) Meta Platforms, Inc. and affiliates. |
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.
Hey @namgyu-youn I don't think we want to remove smoothquant? This wasn't part of the issue: #2745. Can you add these back?
return wrapper | ||
|
||
|
||
class SmoothquantUnitTest(unittest.TestCase): |
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.
Same here, please add the smoothquant tests back
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.
In SmoothQuant API side, they (torchao/quantization/smoothquant.py
& torchao/quantization/prototype/smoothquant/
) are just a two different implementations, so we can revert them.
But in tests side, because we dropped
from torchao.quantization.subclass import (
Int4WeightOnlyQuantizedLinearWeight,
Int8DynamicallyQuantizedLinearWeight,
Int8WeightOnlyQuantizedLinearWeight,
)
,
tests (SmoothquantUnitTest
) can't be maintained. So my suggestion is, how about dropping the old SmoothQuant API also in this PR? The new API also resolved #1639 and has better structure I think
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.
oh I see, yeah if the test uses the old APIs then maybe we can just remove the test
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.
hmm actually I misunderstood, I think we should decide what to do with smoothquant separately. Seems like it is orthogonal to the 3 files that we're deleting, and I don't think it's using any of the other deleted APIs
Int8DynamicallyQuantizedLinearWeight, | ||
Int8WeightOnlyQuantizedLinearWeight, | ||
from torchao.quantization.subclass import ( | ||
QuantizedLinearWeightBase, |
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.
didn't we remove this class in this PR? Seems we need to delete this import completely?
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.
Done, thanks for pointing it out
return y | ||
|
||
|
||
def dynamically_quantize_per_channel(x, quant_min, quant_max, target_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.
Hey @namgyu-youn I don't think this is part of the scope, can you add this function back? The issue #2745 is only referring to everything in subclass.py
, dynamic_quant.py
, and weight_only.py
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.
Reverted; it was misunderstanding while checking api structure.
Hey @namgyu-youn I see smoothquant is still being deleted in this PR. I think we should treat that as a separate issue since we have two smoothquant implementations and it's not clear how we want to reconcile these two yet. As far as I understand smoothquant is actually not related to #2745. Can we scope our changes in this PR to that issue? |
@andrewor14 Understood, addressing it separately looks better I feel, so reverted SmoothQuant api at 6ef8503 . |
return wrapper | ||
|
||
|
||
class SmoothquantUnitTest(unittest.TestCase): |
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.
@namgyu-youn Thanks for adding back smoothquant. I think now we can add back this test too?
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.
Please check #3115 (comment) again. We should drop this test or reproduce with new quantization APIs.
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.
Can you explain which part of the smoothquant test touches the removed API? I took a quick look and didn't find any references to the removed APIs
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.
It's because we drop functions in torchao/quantization/subclass.py
: Int4WeightOnlyQuantizedLinearWeight
, Int8DynamicallyQuantizedLinearWeight
, Int8WeightOnlyQuantizedLinearWeight
and SmoothquantUnitTest
depend on those functions
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 searched the uses of these 3 classes:
Int4WeightOnlyQuantizedLinearWeight
Int8DynamicallyQuantizedLinearWeight
Int8WeightOnlyQuantizedLinearWeight
None of them seem to show up in SmoothquantUnitTest
. Seems like they're only used in TestSubclass
. E.g. this smoothquant test doesn't use it, so we shouldn't delete it:
https://github.com/pytorch/ao/blob/main/test/integration/test_integration.py#L216-L232
Can you verify again?
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.
Oh sorry, you are right, the smoothquant test is unrelated. Reverted at 4651e63; sorry for that again.
Summary:
This PR drops old quantization flows:
Applies corresponding change in other parts for removing old quantization flows:
torchao/quantization/quant_api.py torchao/quantization/utils.py torchao/quantization/autoquant.py # Remove old test cases test/integration/test_integration.py
Test plan: test/integration/test_integration.py