fix wrong match of ignore_layers and use warning instead of error for mismatch#1553
Merged
fix wrong match of ignore_layers and use warning instead of error for mismatch#1553
Conversation
Signed-off-by: Xin He <xin3.he@intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to fix overly-broad matching for ignore_layers (e.g., layers.1 unintentionally matching layers.1x), so that layer-exclusion behaves as users expect during quantization config expansion.
Changes:
- Normalizes
ignore_layersearlier inset_layer_config(splitting by comma and appending.for digit-suffixed names). - Changes unmatched
layer_configentries from raising an error to logging a warning. - Removes string normalization inside
get_fp_layer_names.
Comments suppressed due to low confidence (1)
auto_round/compressors/utils.py:966
get_fp_layer_namesis now iterating overignore_layerswithout normalizing when a string is passed. Since strings are iterable, callers passing the documented comma-separated string (e.g. existing tests) will iterate character-by-character and return incorrect results. Either restore string parsing inside this function (acceptstr | Sequence[str]) or update the signature/docstring and all call sites accordingly.
def get_fp_layer_names(model: torch.nn.Module, ignore_layers: str):
"""Identifies and returns layers in the model to exclude from quantization.
This function processes a comma-separated list of fully precision (FP) layers,
matches them to the names of layers in the model, and returns a list of such
layers to exclude from quantization.
Args:
model (torch.nn.Module): The model whose layers will be inspected.
ignore_layers (str): A comma-separated string of layer names to be excluded
from quantization. Whitespace is ignored in this string.
Returns:
list: A list of layer names that match the specified FP layers or are
subcomponents of those layers.
"""
from auto_round.utils import SUPPORTED_LAYER_TYPES
if not ignore_layers:
return []
all_layer_names = []
for n, m in model.named_modules():
if type(m) in SUPPORTED_LAYER_TYPES:
all_layer_names.append(n)
not_to_quantized_layers = []
for fp_layer in ignore_layers:
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Xin He <xin3.he@intel.com>
wenhuach21
reviewed
Mar 16, 2026
wenhuach21
approved these changes
Mar 16, 2026
Signed-off-by: Xin He <xin3.he@intel.com>
Signed-off-by: Xin He <xin3.he@intel.com>
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.
Description
layers.1 now matches layers.1x, which is not expected.
Type of Change
Related Issues
Fixes or relates to #
Checklist Before Submitting