+
Skip to content

Conversation

namgyu-youn
Copy link
Contributor

@namgyu-youn namgyu-youn commented Oct 2, 2025

Summary:
This PR drops old quantization flows:

torchao/quantization/subclass.py
torchao/quantization/weight_only.py
torchao/quantization/dynamic_quant.py

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

Copy link

pytorch-bot bot commented Oct 2, 2025

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

As of commit 4651e63 with merge base c96f2dd (image):

NEW FAILURES - The following jobs have failed:

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

@meta-cla meta-cla 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 Oct 2, 2025
@andrewor14 andrewor14 added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Oct 2, 2025
@andrewor14 andrewor14 self-requested a review October 2, 2025 15:58
Copy link
Contributor Author

@namgyu-youn namgyu-youn Oct 2, 2025

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.

Copy link
Contributor

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

Copy link
Contributor

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(
Copy link
Contributor Author

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?

Copy link
Contributor

@andrewor14 andrewor14 left a 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?

Copy link
Contributor

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.
Copy link
Contributor

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):
Copy link
Contributor

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

Copy link
Contributor Author

@namgyu-youn namgyu-youn Oct 7, 2025

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

Copy link
Contributor

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

Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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):
Copy link
Contributor

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

Copy link
Contributor Author

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.

@andrewor14 andrewor14 requested a review from jainapurva October 7, 2025 16:13
@namgyu-youn namgyu-youn requested a review from andrewor14 October 7, 2025 16:36
@andrewor14
Copy link
Contributor

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?

@namgyu-youn
Copy link
Contributor Author

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):
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

@namgyu-youn namgyu-youn Oct 10, 2025

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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

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: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate and remove subclass.py, dynamic_quant.py, and weight_only.py

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载