-
Notifications
You must be signed in to change notification settings - Fork 315
Deprecate old QAT APIs #2641
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
Deprecate old QAT APIs #2641
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c358b1b
[bc-breaking] Generalize FakeQuantizeConfig beyond intx
andrewor14 d076264
New multi-step QAT API
andrewor14 8f56651
Update on "New multi-step QAT API"
andrewor14 7a9fe90
Update on "New multi-step QAT API"
andrewor14 1e88ebf
Deprecate old QAT APIs
andrewor14 12e8c3f
Update base for Update on "Deprecate old QAT APIs"
andrewor14 2ed5e50
Update on "Deprecate old QAT APIs"
andrewor14 019b665
Update base for Update on "Deprecate old QAT APIs"
andrewor14 b0c4721
Update on "Deprecate old QAT APIs"
andrewor14 0eb0983
Update base for Update on "Deprecate old QAT APIs"
andrewor14 c91b218
Update on "Deprecate old QAT APIs"
andrewor14 affc74e
Update base for Update on "Deprecate old QAT APIs"
andrewor14 3069075
Update on "Deprecate old QAT APIs"
andrewor14 b41f4e7
Update base for Update on "Deprecate old QAT APIs"
andrewor14 12d920b
Update on "Deprecate old QAT APIs"
andrewor14 68728d7
Update base for Update on "Deprecate old QAT APIs"
andrewor14 52f72a5
Update on "Deprecate old QAT APIs"
andrewor14 56415d6
Update base for Update on "Deprecate old QAT APIs"
andrewor14 08f87af
Update on "Deprecate old QAT APIs"
andrewor14 be45ff4
Update base for Update on "Deprecate old QAT APIs"
andrewor14 28b3b41
Update on "Deprecate old QAT APIs"
andrewor14 9baae23
Update base for Update on "Deprecate old QAT APIs"
andrewor14 62cd942
Update on "Deprecate old QAT APIs"
andrewor14 1c30bbb
Update base for Update on "Deprecate old QAT APIs"
andrewor14 2fbfbb6
Update on "Deprecate old QAT APIs"
andrewor14 3f06429
Merge branch 'main' into gh/andrewor14/15/head
andrewor14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
# This source code is licensed under the license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import warnings | ||
from typing import Any | ||
|
||
import torch | ||
|
||
|
@@ -104,3 +106,33 @@ def _get_qmin_qmax(n_bit: int, symmetric: bool = True): | |
qmin = 0 | ||
qmax = 2**n_bit - 1 | ||
return (qmin, qmax) | ||
|
||
|
||
def _log_deprecation_warning(old_api_object: Any): | ||
""" | ||
Log a helpful deprecation message pointing users to the new QAT API, | ||
only once per deprecated class. | ||
""" | ||
warnings.warn( | ||
"""'%s' is deprecated and will be removed in a future release. Please use the following API instead: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a concrete time for deprecation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it's in the issue, deprecated this version (0.13.0) and removed the next (0.14.0) |
||
|
||
base_config = Int8DynamicActivationInt4WeightConfig(group_size=32) | ||
quantize_(model, QATConfig(base_config, step="prepare")) | ||
# train (not shown) | ||
quantize_(model, QATConfig(base_config, step="convert")) | ||
|
||
Alternatively, if you prefer to pass in fake quantization configs: | ||
|
||
activation_config = IntxFakeQuantizeConfig(torch.int8, "per_token", is_symmetric=False) | ||
weight_config = IntxFakeQuantizeConfig(torch.int4, group_size=32) | ||
qat_config = QATConfig( | ||
activation_config=activation_config, | ||
weight_config=weight_config, | ||
step="prepare", | ||
) | ||
quantize_(model, qat_config) | ||
|
||
Please see https://github.com/pytorch/ao/issues/2630 for more details. | ||
""" | ||
% old_api_object.__class__.__name__ | ||
) |
Oops, something went wrong.
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.
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 heard typing_extensions.deprecated is more IDE friendly: pytorch/pytorch#153892 (comment)
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 I don't think torchao has a dependency on
typing_extensions
? Do we want to add a new one for this?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 see, OK probably not worth to add deps since it looks like right now there is no deps for torchao