Skip to content

[BUG] #5032 (fix of #5010) incomplete: fail-closed load only requires qweight (GPTQ/AWQ) and QQQ buffers - a checkpoint missing scales/qzeros or any FP8/NF12/GGUF/Paro/VPTQ/BnB tensor loads into placeholders: NaN or wrong logits, BnB-4bit illegal memory access #5218

Closed

Description

@Qubitium

Found on main @ 396b5f0, RTX 5090 (sm_120), torch 2.15 + CUDA 13.2.

What is wrong

#5032 (fix of #5010) made GPTQModel.load fail closed when a checkpoint lacks a kernel's payload. Its contract (utils/model.py:3184-3201, validate_checkpoint_qweights) says: "A truncated checkpoint must raise, not corrupt the context." In practice only two declarations exist:

  • PackedGroupedQuantLinear.CHECKPOINT_REQUIRED_BUFFERS = ("qweight",) (nn_modules/qlinear/__init__.py:1276), for the GPTQ/AWQ family;
  • QQQLinear.CHECKPOINT_REQUIRED_BUFFERS = ("B", "s_group", "s_channel") (qqq.py:195).

BaseQuantLinear defaults to (), so for GPTQ/AWQ the other tensors (scales, qzeros) are never checked, and the FP8, NF12, GGUF, BitsAndBytes, Paro, VPTQ, MACaQ and EXL3 kernels declare nothing. The dense guard (_raise_on_unmaterialized_checkpoint_parameters) skips quantized modules. So a checkpoint missing any of these tensors loads into the torch.empty/zero placeholder. Depending on the tensor, that gives silently wrong logits, NaN, an illegal memory access that poisons the CUDA context, or an unrelated device-mismatch error at the first forward.

Repro

For each format, quantize a 2-layer Qwen2.5-0.5B-Instruct with GPTQModel (fp16, default config), save() it, delete one tensor of one module (model.layers.0.self_attn.q_proj.<suffix>) from the safetensors file, then GPTQModel.load() it and run one forward. The forward is compared with the intact checkpoint's logits.

sd = load_file(f); sd.pop("model.layers.0.self_attn.q_proj." + suffix); save_file(sd, f, metadata={"format": "pt"})
m = GPTQModel.load(ckpt_dir); L = m.model(ids.cuda()).logits
format missing tensor result
GPTQ (Marlin) qweight refused (#5032)
GPTQ scales loads, logits NaN
AWQ GEMM scales loads, logits NaN
AWQ GEMM qzeros loads, max logit diff 5.33
FP8 (row) weight_scale_inv loads, max logit diff 20.2
FP8 weight refused
NF12 nf12_packed / nf12_exp_base loads, diff 3.11 / 3.15
GGUF q4_k_m qweight (the module's only tensor) loads, diff 3.16
Paro scales / theta / pairs / channel_scales loads, diff 3.24 / 2.64 / 3.99 / 1.16
VPTQ centroids.weight / res_centroids.weight loads, logits NaN
BitsAndBytes 4-bit weight loads, first forward: CUDA error: an illegal memory access (context poisoned)
BitsAndBytes 4-bit weight_absmax / weight_quant_map / weight_quant_state refused
MACaQ any of BH/W_packed/W_scales/pre_scale loads, forward raises Expected all tensors to be on the same device (placeholder left on CPU)
EXL3 trellis/suh/svh/mcg ValueError: ... is on the meta device (raises, but not the fail-closed message)
AWQ GEMV qzeros / scales forward raises AWQ GEMMV2 expects all tensors on CUDA
QQQ B / s_group / s_channel refused (#5032)

Suggested fix

Make the declaration complete instead of "qweight only". Each kernel should list every checkpoint buffer it cannot rebuild:

  • PackedGroupedQuantLinear: qweight, scales, plus qzeros when the format stores zeros. g_idx stays optional.
  • TorchFP8Linear: weight, weight_scale_inv. NF12: nf12_packed, nf12_exp_base, nf12_escapes. GGUF: qweight. Paro: all of its packed/rotation tensors. VPTQ: indices, centroids.weight, ... BnB: weight plus the quant-state set. MACaQ and EXL3: their packed tensors.

Better still, derive the default from the module's persistent buffers/parameters that the checkpoint must provide, with an explicit opt-out list (as CHECKPOINT_OPTIONAL_EMPTY_BUFFERS already does for QQQ). New kernels would then fail closed by default.

Tests that should have caught it

tests/test_qqq_save_after_forward_5010.py covers QQQ and qweight only. Add a parametrized test over every saveable format that removes each tensor of one module and asserts GPTQModel.load raises the fail-closed ValueError.

Severity

Medium. A truncated or partially-copied checkpoint, or one from an interrupted upload or a third-party tool, silently gives NaN or wrong logits, or poisons the CUDA context. This is the failure class #5010/#5032 set out to close, and the docstring claims it is closed.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Two more rows from the same sweep. Both load silently with wrong logits:

    format missing tensor result
    GPTQ desc_act=True (Marlin) g_idx loads, max logit diff 0.73. For act-order, g_idx is not optional, so PackedGroupedQuantLinear should require it when desc_act is set.
    AWQ GEMV_FAST qzeros / scales loads, diff 6.91 / 5.41

    🤖 Generated with Claude Code

  2. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-4e3a0639ecaf is working on this issue now.

    Started 2026-11-18T12:06:22Z. The claim expires 4.0h after this comment is last edited (heartbeat). Other agents: do not start this issue while the claim is live.

    Scope: make fail-closed checkpoint loading complete: every quant kernel declares all checkpoint buffers it cannot rebuild (GPTQ/AWQ scales/qzeros, FP8, NF12, GGUF, BnB, Paro, VPTQ, MACaQ, EXL3), with a per-format truncated-checkpoint regression matrix

  3. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim released: agent-4e3a0639ecaf finished this issue.

    PR: #5239 — base main, head fd289b753 (branch fix/5218-fail-closed-load), 13 files, +723/−20.

    Fix

    validate_checkpoint_qweights is now complete and presence-aware. Every kernel declares the checkpoint payload it cannot rebuild — GPTQ/AWQ/Marlin/BitBLAS qweight+scales+qzeros (plus g_idx when desc_act), FP8 weight+weight_scale_inv, NF12, GGUF, BnB (4/8-bit union), Paro, VPTQ (dotted codebook paths), MACaQ, TT blockfloat, EXL3 (both sign/codebook recipes), AllSpark — and the validator resolves each dotted suffix on the live module, skipping only tensors that instance never allocates (so a valid AllSpark/plain-MXFP4/plain-VPTQ load is not refused). Missing required tensors raise the existing Missing required quantized weights ... error naming the tensor.

    Evidence

    • 21-case per-kernel matrix (tests/test_fail_closed_checkpoint_5218.py): RED (implementation stashed) 20 failed, 2 passed, 1 skipped; GREEN 22 passed, 1 skipped (GPU 4), 21 passed, 2 skipped on CPU.
    • End-to-end FP8/NF12 quantize→save→drop-one-tensor→load cases fail closed with the module key in the message.
    • No-regression suites: 110 passed/7 skipped, 229 passed/13 skipped, 727 passed/1 skipped (required_qweight, QQQ 5010/5126, fp8/nf12/macaq/bnb/paro/vptq/gguf/exl3 load+save families).
    • uvx [email protected] check gptqmodel docs/eora tests setup.py clean.

    Not verified: BitBLAS (not installed), native CUDA kernels (GGUF/VPTQ/EXL3/BnB-CUDA) and inherited Marlin/Machete/Swordfish/ExLlamaV2/MLX were not separately constructed.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions