Skip to content

Add mixed granularity tests for smooth quant#3847

Open
cyxlily wants to merge 9 commits intopytorch:mainfrom
cyxlily:smooth_quant_test
Open

Add mixed granularity tests for smooth quant#3847
cyxlily wants to merge 9 commits intopytorch:mainfrom
cyxlily:smooth_quant_test

Conversation

@cyxlily
Copy link
Copy Markdown
Contributor

@cyxlily cyxlily commented Feb 10, 2026

Split from #3524
Test different activation and weight granularities for smooth quantization.

Signed-off-by: Cui, Lily <lily.cui@intel.com>
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 10, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3847

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

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 Feb 10, 2026
@cyxlily cyxlily marked this pull request as draft February 10, 2026 02:04
@Xia-Weiwen Xia-Weiwen requested a review from Copilot March 18, 2026 08:33
@Xia-Weiwen Xia-Weiwen requested review from jcaip and jerryzh168 March 18, 2026 08:34
@Xia-Weiwen Xia-Weiwen added the module: not user facing Use this tag if you don't want this PR to show up in release notes label Mar 18, 2026
@Xia-Weiwen Xia-Weiwen marked this pull request as ready for review March 18, 2026 08:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional SmoothQuant test coverage to validate behavior when activation and weight quantization granularities are configured independently (mixed granularity), split out from #3524.

Changes:

  • Expand test_smoothquant_accuracy parameterization to include mixed activation/weight granularities for int8 dynamic and int8 static configs.
  • Add explicit per-row/per-tensor variants for int8 dynamic configs alongside mixed-granularity cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/prototype/test_smoothquant.py Outdated
@cyxlily cyxlily requested a review from vkuzo as a code owner April 24, 2026 05:26
Comment thread test/prototype/test_smoothquant.py Outdated
Comment thread test/prototype/test_smoothquant.py Outdated
Int8StaticActivationInt8WeightConfig(granularity=PerRow()),
Int8DynamicActivationInt8WeightConfig(version=2, granularity=PerTensor()),
Int8DynamicActivationInt8WeightConfig(
version=2, granularity=[PerRow(), PerTensor()]
Copy link
Copy Markdown
Contributor

@jerryzh168 jerryzh168 Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually why is this a list?

I saw type is changed to

Union[Granularity, Tuple[Granularity, Granularity], list[Granularity]]

I feel we should not have both tuple and list, can you have a followup PR to change this to Union[Granularity, Tuple[Granularity, Granularity]] to reduce the complexity here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for comments, updated the UT.
For the followup PR, the JSON encoder explicitly raises NotImplementedError for tuples: https://github.com/pytorch/ao/blob/main/torchao/core/config.py#L146
So even though users can pass a Tuple, internally it still needs to be stored as a list for serialization.
Does it still make sense to change the API from list to tuple?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see, in that case we should remove tuple and just use List, I've seen the json error before as well

Signed-off-by: Cui, Lily <lily.cui@intel.com>
Comment thread test/prototype/test_smoothquant.py Outdated
Int8StaticActivationInt8WeightConfig(granularity=PerRow()),
Int8DynamicActivationInt8WeightConfig(),
Int8DynamicActivationInt8WeightConfig(granularity=PerTensor()),
Int8DynamicActivationInt8WeightConfig(granularity=(PerRow(), PerTensor())),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just use list and drop tuple in the next PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, created the PR to remove tuple: #4347

Signed-off-by: Cui, Lily <lily.cui@intel.com>
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. module: not user facing Use this tag if you don't want this PR to show up in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants