Add exportable coreml codebook quantization op#2443
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2443
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 8fb10b2 with merge base 5a50667 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
metascroy
reviewed
Jun 26, 2025
metascroy
reviewed
Jun 26, 2025
metascroy
reviewed
Jun 26, 2025
metascroy
reviewed
Jun 26, 2025
metascroy
reviewed
Jun 26, 2025
metascroy
reviewed
Jun 26, 2025
metascroy
approved these changes
Jun 26, 2025
| codes = codes.to(torch.int32) | ||
| return dequantize_codebook( | ||
| codes, | ||
| self.codebook, |
Contributor
There was a problem hiding this comment.
Should we have a granularity?
Contributor
Author
There was a problem hiding this comment.
we'll use block_size for now, it can be extended to other granularities
Summary: Added CoreML codebook quant (Palettization): https://apple.github.io/coremltools/docs-guides/source/opt-palettization-overview.html#palettization-overview * supports group_size `per_grouped_channel` * doesn't support vector quantization yet, but will be easy to turn on if needed * ops added: choose_qparams_and_quantize_codebook, dequantize_codebook * also enabled support for export, these two ops will be preserved after exporta * Added CodebookWeightOnlyConfig(dtype, group_size) that can be used with quantize_ to quantize the Tensor Test Plan: python test/prototype/test_coreml_codebook.py Reviewers: Subscribers: Tasks: Tags:
liangel-02
pushed a commit
that referenced
this pull request
Aug 25, 2025
Summary: Added CoreML codebook quant (Palettization): https://apple.github.io/coremltools/docs-guides/source/opt-palettization-overview.html#palettization-overview * supports group_size `per_grouped_channel` * doesn't support vector quantization yet, but will be easy to turn on if needed * ops added: choose_qparams_and_quantize_codebook, dequantize_codebook * also enabled support for export, these two ops will be preserved after exporta * Added CodebookWeightOnlyConfig(dtype, group_size) that can be used with quantize_ to quantize the Tensor Test Plan: python test/prototype/test_coreml_codebook.py Reviewers: Subscribers: Tasks: Tags:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Added CoreML codebook quant (Palettization): https://apple.github.io/coremltools/docs-guides/source/opt-palettization-overview.html#palettization-overview
per_grouped_channelTest Plan:
python test/prototype/test_coreml_codebook.py
Reviewers:
Subscribers:
Tasks:
Tags: