Skip to content

[BUG] Checkpoint interop: AutoAWQ modules_to_not_convert loads as NaN, format-change re-save writes stale qzeros, HF save_pretrained writes kernel runtime layout, Marlin ignores g_idx, is_marlin_format:false rejected, export broken #4053

Closed

Description

@Qubitium

Interop and checkpoint-format audit, done at e6b19c5 and re-checked on main @ 39cd57a. I inventoried the 199 quantized checkpoints on local disk and load-tested about 30 of them, with greedy generation and 512-token wikitext PPL on the auto and torch backends. Producers covered:

  • AutoGPTQ / TheBloke (6 TinyLlama branches, Llama-2-7B)
  • optimum (GPTQ v2, 2-bit)
  • AutoAWQ (Llama-3.2-1B, R1-distill-Qwen-7B)
  • Intel auto-round
  • QQQ
  • GPTQModel 0.9 → 7.x

Most load with auto and torch agreeing within bf16 noise, and unsupported formats (compressed-tensors, hqq, quark, torchao, aqlm, eetq, mlx, W4A8, …) fail early with clear errors. reshard and dequantize_model match GPTQModel PPL on every producer tested. The exceptions follow.

1. Third-party checkpoints with unquantized in-layer modules: AutoAWQ loads silently as NaN, optimum GPTQ refuses to load (high for AWQ)

The loader decides what to quantize only from the module tree plus dynamic (models/loader.py:2223-2266). It never reads modules_to_not_convert (AutoAWQ / HF AwqConfig) or modules_in_block_to_quantize (optimum GPTQ). AWQConfig.modules_to_not_convert is used only on write (config.py:5303-5314), and validate_checkpoint_qweights (utils/model.py:2592) returns early for non-GPTQ formats, so never-loaded AWQ placeholders stay zero.

HF-valid checkpoints with every down_proj left dense:

checkpoint plain transformers GPTQModel auto GPTQModel torch
AutoAWQ + modules_to_not_convert: ["down_proj"] PPL 12.48 AwqMarlin, PPL NaN, output '!!!!!!!!!!!!', no error RuntimeError: Cannot restore checkpoint buffers missing...
GPTQ + modules_in_block_to_quantize PPL 12.36 ValueError: Missing required quantized weights same

Fix: turn both keys (and llm-compressor ignore) into -: dynamic exclusions when parsing the config, and run the missing-tensor validation for the AWQ formats too.

2. Re-saving with a different format writes the old qzeros under the new label: silent garbage (high)

model.quantize_config.format = X; model.save() is exactly what tests/test_serialization.py:56 does, though it only checks the JSON. get_model_with_quantize (models/writer.py:2269-2351, called from :1990) reloads the raw source tensors and writes them unchanged. It never calls convert_gptq_v1_to_v2_format / convert_gptq_v2_to_v1_format (utils/model.py:925 / 1043).

saved qzeros are byte-identical to the source: asym v1 0x76687666... now labelled gptq_v2; sym 0x88888888 labelled gptq
asym v1 -> v2 (Llama-3.2-1B ...-symFasle): reloaded rel. max logit diff 1.06 in GPTQModel and 1.06 in HF
sym  v2 -> v1 (HF-GPTQV2):                 GPTQModel 0.98; HF 0.016 (its Marlin path ignores sym zeros)
same-format re-save: exact (0.0 GPTQModel, <= 0.02 HF) on 7 checkpoints

Fix: record the on-disk format at load and convert qzeros in get_model_with_quantize when the target differs, or refuse the change.

3. HF from_pretrained → save_pretrained writes the kernels' runtime layout as a v1 checkpoint: the reload is NaN, garbage or a crash (high)

After AutoModelForCausalLM.from_pretrained(gptq_ckpt) (optimum → GPTQModel kernels), save_pretrained writes, while checkpoint_format stays "gptq" (v1):

  • in-memory v2 qzeros
  • Marlin's repacked qweight [56, 1792] with empty g_idx / qzeros
  • ExLlamaV2's shuffled qweight (exllamav2.py:189 records the shuffle only in torch _metadata, which safetensors drops)
HF reload GPTQModel reload
real Qwen2.5-0.5B-GPTQ-Int4, Triton NaN logits correct (Marlin ignores sym zeros)
real Qwen2.5-0.5B-GPTQ-Int4, ExLlamaV2 NaN logits rel 1.29
tiny asym, ExLlamaV2 rel 1.44 (vs 0.0016) rel 1.44
tiny, default Marlin crash: Shape mismatch: b_q_weight.size(0) = 56
AWQ via Marlin crash: qweight shape mismatch

hf_convert_gptq_v2_to_v1_format (utils/model.py:1032) is only called from optimum's own save_model, and only for sym + gptq_v2. The same applies to m.model.save_pretrained(...). Fix: add a state-dict post-hook on the quant linears that emits checkpoint-layout tensors (v1 qzeros, un-shuffled / un-repacked qweight, real g_idx), or raise for kernels whose layout can't be reversed. tests/test_integration.py covers quantize → save, but never load → save.

4. After save(), m.model is replaced by a model that returns garbage (raises the severity of #3985 item 3)

models/writer.py:1990 still does self.model = self.get_model_with_quantize(...). #3985 described this as "inference silently moves to CPU". In fact the swapped-in model is an fp16 TorchCpuAvx512Linear model (a bf16-only kernel, with no post_init), and after m.save() on a Marlin model its logits are rel 1.47 off. Fix: don't replace self.model.

5. Marlin silently ignores a non-trivial g_idx when desc_act=False (medium, silent)

nn_modules/qlinear/marlin.py:413-419 replaces g_idx with an empty tensor unless desc_act is set, so it assumes contiguous groups. Qwen2-1.5B-Instruct-GPTQ-4bits-gp32 (GPTQModel 5.4.2, act_group_aware=True) stores desc_act: false with a block-permuted g_idx. Matching scale rows to the base weights shows the stored g_idx is right for 100% of groups.

layer-0 q_proj rel err:   Marlin 0.136 vs g_idx decode / 0.0019 vs contiguous decode;   Torch/ExLlamaV2/TritonV2: 0.0019 / 0.134
whole model: auto (Marlin) PPL 48.3 vs torch 141.8 (base 8.07); top-1 agreement 39%

This is the only such checkpoint on disk, and current GAR writes a contiguous g_idx, so new checkpoints aren't affected. Fix: detect a non-monotonic g_idx in post_init, then take the act-order path or exclude Marlin.

6. is_marlin_format: false is rejected, which blocks popular AutoGPTQ checkpoints (medium)

config.py:4633-4636 / :4045 reject the field whatever its value (tests/test_q4_marlin.py:52 asserts this for gemma). That blocks gemma-1.1-2b-it-GPTQ, hugging-quants Meta-Llama-3.1-8B-Instruct-GPTQ-INT4 and neuralmagic Meta-Llama-3.1-8B/70B-Instruct-quantized.w4a16. Plain HF loads the hugging-quants checkpoint through GPTQModel's own MarlinLinear at PPL 6.526. With only that field stripped, GPTQModel gives 6.526 auto / 6.528 torch (base 6.08), and gemma gives 27.95 / 27.95. Fix: accept false silently and reject only true.

7. GPTQModel.export(path, out, "hf") fails for most non-trivial checkpoints (medium-low)

  • AWQ: export picks AWQ_TORCH (models/auto.py:1068), but nn_modules/qlinear/torch.py:1062 accepts only TorchLinear, so it fails with ValueError: Only models loaded using TorchLinear....
  • Quantized embeddings: TorchQuantEmbeddings subclasses TorchLinear, so the embedding becomes an nn.Linear and the forward fails with mm: mat1 and mat2 shapes cannot be multiplied (1x4 and 151936x4096).
  • Checkpoints with only quantize_config.json (bloom-560m-gptqmodel-4bit): auto.py:1058 raises AttributeError: no attribute 'quantization_config'.

No test covers export; the plain GPTQ path works. torch.py:1075-1078 also hard-codes fp16 for the dequantized weights and biases. Fix: route export through utils/model_dequant.dequantize_model.

8. dequantize_model ignores per-module dynamic bits for GPTQ (low-medium, crashes)

utils/model_dequant.py:1815 uses bits = config.get("bits", 4) for every module; #4031 added per-module bits for AWQ only:

3-bit main + 4-bit lm_head: ValueError: 3-bit GPTQ qzeros expects columns divisible by 3
4-bit main + 8-bit lm_head: RuntimeError: size of tensor a (256) must match ... (512)

Minor:

  • backend="torch" has no mapping for QQQ / GGUF / BnB (utils/backend.py _LEGACY_BACKEND_BY_METHOD), so QQQ fails with Unsupported backend: BACKEND.TORCH while qqq_torch works.
  • "bits": "4" as a string fails with an unclear TypeError: '<=' not supported.
  • sym: null stays None after parsing.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 14, 2026
  2. Qubitium commented on Nov 14, 2026

    @Qubitium
    CollaboratorAuthor

    Resolved by #4061 (items 1-3: modules_to_not_convert / modules_in_block_to_quantize / ignore parsed into -: exclusions plus missing-tensor validation for AWQ formats, exact qzeros conversion or refusal on a format-changing re-save, and checkpoint-layout save_pretrained with Marlin/ExLlamaV2 failing closed) and #4059 (items 4-8: save() keeps the live model, Marlin decodes a non-contiguous g_idx, is_marlin_format: false accepted, export(..., "hf") routed through the checkpoint dequantizer, per-module dynamic bits for GPTQ).

  3. Qubitium commented on Nov 14, 2026

    @Qubitium
    CollaboratorAuthor

    Follow-up: #4061 introduced a regression. state_dict() now emits v1 qzeros, but _load_from_state_dict keeps them as v1 on v2 kernels, so a load_state_dict(state_dict()) round trip takes Llama-1B from PPL 9.8 to 1.9e6. Partial loads (PEFT) also flip the format flag, which makes the next save write garbage. Details in the new follow-up issue (items 1-2).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions