-
Notifications
You must be signed in to change notification settings - Fork 55
enable regex quantization config saving for mixed bits #825
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
Open
WeiweiZhang1
wants to merge
13
commits into
main
Choose a base branch
from
enable_dynamic_quantization_config_saving
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+493
−10
Open
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2b1577b
enable dynamic quantization config saving
WeiweiZhang1 56a2218
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] db99785
fixtypo
WeiweiZhang1 81e8086
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d5b9a46
Merge branch 'main' into enable_dynamic_quantization_config_saving
WeiweiZhang1 4e58090
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c75ebdc
rebase code, refine config saving
WeiweiZhang1 ae20df7
Merge branch 'main' into enable_dynamic_quantization_config_saving
WeiweiZhang1 21ff4b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b97f3fc
refine ut
WeiweiZhang1 be7af05
Merge branch 'enable_dynamic_quantization_config_saving' of https://g…
WeiweiZhang1 b91bf20
fix UT
WeiweiZhang1 cd5c693
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2025 Intel Corporation | ||
# | ||
# 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 typing import Dict, List | ||
|
||
from auto_round.utils import matches_any_regex, to_standard_regex | ||
|
||
|
||
def generate_ignore_regex_list(regex_config: Dict[str, Dict], layer_config: Dict[str, Dict]) -> List[str]: | ||
""" | ||
Generate ignore regex list for llm_compressor based on regex_config and layer_config. | ||
|
||
Rules: | ||
1. Any layer in regex_config with bits >= 16 is ignored. | ||
2. Any layer in layer_config with bits >= 16 is ignored if not already included. | ||
3. Output regex patterns are normalized for llm_compressor ('re:...' style). | ||
|
||
Args: | ||
regex_config (Dict[str, Dict]): dynamic quantization config | ||
layer_config (Dict[str, Dict]): layer-wise quantization config | ||
|
||
Returns: | ||
List[str]: List of regex patterns to ignore during quantization. | ||
""" | ||
prefix = "re:" | ||
ignore_regex: List[str] = [] | ||
|
||
# Step 1: Add regex_config keys with bits >= 16 | ||
for key, cfg in regex_config.items(): | ||
bits = cfg.get("bits") | ||
if bits > 8: | ||
ignore_regex.append(prefix + to_standard_regex(key)) | ||
|
||
# Step 2: Add all full named layer from layer_config if bits >= 16 | ||
for key, cfg in layer_config.items(): | ||
bits = cfg.get("bits") | ||
if bits > 8: | ||
ignore_regex.append(key) | ||
|
||
return ignore_regex |
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.
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.
if its 16 bits, we could convert it to not_convert_module, I forget the name