Skip to content

Fix missing QuantOptimizer methods #2770

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

Merged
merged 1 commit into from
Aug 14, 2025
Merged

Fix missing QuantOptimizer methods #2770

merged 1 commit into from
Aug 14, 2025

Conversation

lisjin
Copy link
Contributor

@lisjin lisjin commented Aug 14, 2025

This is a patch to yesterday's #2743.

  • Returned the overrides to state_dict and load_state_dict in QuantOptimizer, which were mistakenly removed
  • Replaced the "quant_cls" and "quant_kwargs" keys in param_group to "quantizer" so that the user can instantiate the class outside of the optimizer. Otherwise, we can't use JSON to serialize nonstandard types like torch.dtype.

@lisjin lisjin added the topic: bug fix Use this tag for PRs that fix bugs label Aug 14, 2025
Copy link

pytorch-bot bot commented Aug 14, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit f08a47c with merge base 6a2d975 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Aug 14, 2025
@@ -142,7 +142,7 @@ def quantize(


class StretchedUnifTorchaoQuantizer(UnifTorchaoQuantizer):
def __init__(self, b: int, int_shift: float = 0.5) -> None:
def __init__(self, b: int, int_shift: float = 0.5, **kwargs) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the kwargs for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It lets us customize the parent class defaults, like mapping_type or target_dtype. Thanks for looking this over, by the way

@lisjin lisjin merged commit c232c55 into main Aug 14, 2025
18 checks passed
@lisjin lisjin deleted the lvj branch August 14, 2025 22:41
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: bug fix Use this tag for PRs that fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants