Skip to content

fix(awq): resolve regex -: exclusions to concrete modules on save - #6226

Merged
Qubitium merged 1 commit into
mainfrom
fix/6190-issue
Nov 29, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/6190-issue

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #6190

Problem

AWQ checkpoints wrote regex -: dynamic exclusions verbatim into modules_to_not_convert. vLLM (is_layer_skipped(..., match_mode="substring")) and SGLang (is_layer_skipped_awq) compare that list as plain substrings, so .*\.5\.self_attn\..* never matched. vLLM crashed at engine init; SGLang silently ran the excluded layers as uninitialized AWQ layers. The presence of the key also disabled vLLM's dense-layer autodetection.

Fix

  • AWQConfig.resolve_excluded_modules(model) walks the saved model and records every quantizable module whose dynamic rule resolves to excluded, i.e. the modules that actually stayed dense.
  • The writer calls it after any prepare_quantize_config_for_save hook and before writing quantize_config.json; the existing config.json patch block copies the same resolved list there.
  • dynamic keeps the original regex rules for GPT-QModel reloads. Positive rules and non-AWQ methods are untouched.
  • Without a model, excluded_module_patterns() no longer emits regex text. If any -: rule cannot be resolved, the whole key is omitted (a partial list would still disable vLLM autodetection).

Reproduction

At pre-fix HEAD, a tiny 2-layer Llama AWQ run with dynamic={"-:.*\\.1\\.self_attn\\..*": {}} saved modules_to_not_convert: [".*\\\\.1\\\\.self_attn\\\\..*"] in both quantize_config.json and config.json.

After the fix it saves:

["model.layers.1.self_attn.q_proj", "model.layers.1.self_attn.k_proj", "model.layers.1.self_attn.v_proj", "model.layers.1.self_attn.o_proj"]

Red evidence (pre-fix source, new tests)

Command:

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=<clone>:<clone>/tests /root/venv/bin/python -m pytest \
  test_external_exclusion_translation_4196.py::test_awq_regex_dynamic_exclusion_is_not_exported_without_a_model \
  test_external_exclusion_translation_4196.py::test_awq_unresolved_regex_omits_the_whole_mirror \
  test_external_exclusion_translation_4196.py::test_non_awq_regex_dynamic_exclusion_keeps_no_awq_mirror \
  test_external_exclusion_translation_4196.py::test_awq_regex_dynamic_exclusion_resolves_to_dense_modules_on_save \
  test_checkpoint_compat.py::test_awq_dynamic_exclusions_are_written_to_modules_to_not_convert -q -rs

4 failed, 1 passed:

  • unit fallback tests: modules_to_not_convert present with the raw regex.
  • integration: assert {'.*\\\\.1\\\\.self_attn\\\\..*'} == {'model.layers...v_proj'}.
  • checkpoint compat: raw .*mlp.down_proj$ exported alongside the literal.
  • non-AWQ control passed (no key).

Green evidence (rebased on b95b4c6)

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=<clone>:<clone>/tests /root/venv/bin/python -m pytest \
  test_external_exclusion_translation_4196.py test_checkpoint_compat.py \
  test_awq_modules_to_not_convert_4195.py test_awq_modules_to_not_convert_lifecycle_4309.py \
  test_checkpoint_interop_4053.py -q -rs

66 passed, 9 skipped
Skips: 3 lm_head tests need an accelerator; 6 test_checkpoint_interop_4053 Marlin/ExLlamaV2/triton tests need CUDA.

/root/venv/bin/ruff check gptqmodel/quantization/config.py gptqmodel/models/writer.py \
  tests/test_external_exclusion_translation_4196.py tests/test_checkpoint_compat.py

All checks passed!

Unverified

Actual vLLM/SGLang engine load was not run (CPU-only environment; the installed namespace packages do not expose their runtimes). The tests mirror their substring skip check and assert the concrete names.

Tree

c1c51a4 on fix/6190-issue, based on origin/main b95b4c6; only the six listed files changed.

AWQ wrote regex `-:` dynamic exclusions verbatim into
`modules_to_not_convert`. vLLM/SGLang compare that list as plain
substrings, so the excluded modules were still built as AWQ layers (vLLM
crashes, SGLang silently loads them uninitialized). Resolve each exclusion
against the saved model and publish the concrete dense module names; keep
`dynamic` authoritative for GPT-QModel reloads. Without a model, omit the
key rather than write an unmatched regex, which also preserves vLLM's
dense-layer autodetection.
@Qubitium
Qubitium marked this pull request as ready for review November 29, 2026 02:06
@Qubitium
Qubitium merged commit 2d3261d into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/6190-issue branch November 29, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant