Skip to content

fix: compile protocol -: selectors with search semantics (#4197) - #4288

Merged
Qubitium merged 1 commit into
mainfrom
pr/4197
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
pr/4197

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Protocol -: selectors are matched with pcre.search in _pattern_matches, but _compile_negative_match_dynamic copied the selector verbatim into dynamic, where rules are evaluated with a start-anchored pcre.match. A rule such as ["*", "-:down_proj"] therefore excluded down_proj in the protocol but quantized it in the compiled QuantizeConfig. Only .*-prefixed selectors worked by accident.

What Changed

  • gptqmodel/quantization/protocol.py: _compile_negative_match_dynamic now emits -:.*(?:<selector>), which preserves search semantics under start-anchored matching. -:* compiles to -:.* (exclude everything) instead of an invalid regex.
  • tests/test_protocol_negative_search_4197.py: new regressions covering selectors that do not start with .* (down_proj, mlp\.gate$, \.self_attn\.q_proj$), the -:* case, and the AWQ compilation path. Each case asserts the compiled dynamic_get decision agrees with rule.matches.
  • tests/protocol/test_protocol.py: updated the three exact-key assertions to the new canonical -:.*(?:.*layers\.2.*) form (same behavior).

Tests

CUDA_VISIBLE_DEVICES= GPTQ_BYPASS_SAFETY_CHECKS=1 PYTHONPATH=$PWD \
  python3 -m pytest tests/test_protocol_negative_search_4197.py tests/protocol/test_protocol.py -q
# 14 passed

ruff check gptqmodel/quantization/protocol.py tests/test_protocol_negative_search_4197.py tests/protocol/test_protocol.py
# All checks passed!

Repro from the issue now reports compiled excludes: True for both model.layers.0.mlp.down_proj and model.layers.0.mlp.gate.

Fixes #4197

@Qubitium
Qubitium merged commit 1ffb9d8 into main Nov 16, 2026
8 of 9 checks passed
@Qubitium
Qubitium deleted the pr/4197 branch November 16, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant