Skip to content

[BUG] Protocol -: selectors use search semantics but compile to start-anchored dynamic rules, so excluded modules get quantized #4197

Closed

Description

@Qubitium

Severity: medium
Version: 7.11.0 @ 9dad249

Summary

  • quantization/protocol.py:1256-1259 (_pattern_matches) evaluates selectors with pcre...search.
  • _compile_negative_match_dynamic (protocol.py:1209-1213) emits -:{pattern} into dynamic, which is evaluated with start-anchored match.

So a protocol rule ["*", "-:down_proj"] excludes down_proj, but the compiled QuantizeConfig quantizes it. The repo tests only use patterns starting with .*, which hides this.

Reproduce

from gptqmodel.quantization.protocol import compile_protocol, compile_protocol_to_quantize_config
src = {"version": 2, "stages": [{"name": "ptq", "rules": [{"match": ["*", "-:down_proj", "-:mlp\\.gate$"],
       "weight": {"quantize": {"method": "gptq", "bits": 4, "group_size": 128}}}]}]}
rule = compile_protocol(src).stages[0].rules[0]
cfg = compile_protocol_to_quantize_config(src)
for n in ["model.layers.0.mlp.down_proj", "model.layers.0.mlp.gate"]:
    print(n, "protocol quantizes:", rule.matches(n), " compiled excludes:", cfg.dynamic_get(n) is False)
# model.layers.0.mlp.down_proj protocol quantizes: False  compiled excludes: False   <- mismatch
# model.layers.0.mlp.gate      protocol quantizes: False  compiled excludes: False   <- mismatch

Expected

Compile with the same semantics, e.g. emit -:.*(?:{pattern}), and add tests with patterns that don't start with .*.


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions