-
Notifications
You must be signed in to change notification settings - Fork 33
[Multi-Modifier] Scoped apply quantization config #432
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
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
df873fb
squashed/rebased
brian-dellabetta 2a58648
cleanup
brian-dellabetta 7cdd1cd
remove TODO
brian-dellabetta 78d274d
more clenaup
brian-dellabetta 606f177
cleanup
brian-dellabetta 829b7cb
formatting
brian-dellabetta 7f2c5de
formatting
brian-dellabetta 712a731
merge main
brian-dellabetta b515c1b
resolve redundant merge code
brian-dellabetta 0e11f93
style fixes
brian-dellabetta 80844ea
cleanup / test fixes
brian-dellabetta cbac9f2
Merge branch 'main' into bdellabe/scoped-quant-status
brian-dellabetta f62b70c
test fixes
brian-dellabetta ac1ce1c
formatting/touchups
brian-dellabetta 0da8730
stylefix
brian-dellabetta 5744d73
stylefixes
brian-dellabetta 304615e
stylefixes
brian-dellabetta 76f81b9
remaining test fixes
brian-dellabetta 5bf957f
revert extraneous test change
brian-dellabetta 360a9fb
remove test running code
brian-dellabetta cc27568
remove infer_quantization_status
brian-dellabetta fc2e102
lifecycle updates for overwriting config
brian-dellabetta 14a359f
remove compress_quantized_weight, test fixes, remove sparseml references
brian-dellabetta dd87f23
merge main
brian-dellabetta 595228c
drop frozen scale_dtype post-merge
brian-dellabetta 49e4e92
formatting
brian-dellabetta fb32778
Merge branch 'main' into bdellabe/scoped-quant-status
brian-dellabetta 6ba47e5
clear previously initialized qparams
brian-dellabetta 72e5f3d
remove apply_quantization_status
brian-dellabetta 88b8865
stylefix
brian-dellabetta fb6aa9a
add ALL_QPARAM_KEYS var
brian-dellabetta d2903a1
multi-apply quantization config test
brian-dellabetta 5776c86
multi-apply test cleanup
brian-dellabetta 5e5ffb5
Merge branch 'main' into bdellabe/scoped-quant-status
brian-dellabetta 98a97e5
ALL_QPARAM_NAMES
brian-dellabetta 02d5e78
stylefixes
brian-dellabetta 7d8c5a4
exclude sparsity param names
brian-dellabetta 01af659
QuantizationMetadata class
brian-dellabetta 3fdd125
stylefix
brian-dellabetta b789adf
llm-compressor test fix
brian-dellabetta 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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from enum import Enum | ||
|
||
from compressed_tensors.utils import delete_offload_parameter | ||
from torch.nn import Module | ||
|
||
|
||
__all__ = ["QuantizationMetadata", "KVCacheScaleType"] | ||
|
||
|
||
class KVCacheScaleType(Enum): | ||
KEY = "k_scale" | ||
VALUE = "v_scale" | ||
|
||
|
||
class QuantizationMetadata: | ||
""" | ||
Container class for metadata related to quantization | ||
""" | ||
|
||
@staticmethod | ||
def all_qparam_names(): | ||
""" | ||
All quantization parameter names that might be registered | ||
onto a module during lifecycle (excluding serialized parameters) | ||
""" | ||
return [KVCacheScaleType.KEY.value, KVCacheScaleType.VALUE.value] + [ | ||
f"{base_name}_{suffix}" | ||
for base_name in ("input", "weight", "output") | ||
for suffix in ( | ||
"global_scale", | ||
"scale", | ||
"zero_point", | ||
"g_idx", | ||
) | ||
] | ||
|
||
@classmethod | ||
def clear_all_qparams(cls, module: Module): | ||
""" | ||
Remove all parameters related to quantization that might have | ||
been registered onto a module previously in lifecycle (excluding | ||
serialized parameters) | ||
|
||
:param module: Module to clear | ||
""" | ||
for key in cls.all_qparam_names(): | ||
if hasattr(module, key): | ||
delete_offload_parameter(module, key) |
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
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.
Uh oh!
There was an error while loading. Please reload this page.