Skip to content

[BUG] Regression from #5247 (fix of #5194): gptqmodel_post_init now calls _post_init_offloaded for every BaseQuantLinear, which reads module.qweight - every NF12 / QQQ / VPTQ (and other qweight-less kernel) checkpoint fails to load with AttributeError, even on a single GPU #5261

Closed

Description

@Qubitium

Found on main @ c1807f8, RTX 4090, torch 2.15 + CUDA 13.2, transformers 5.22.

What is wrong

#5247 (fix of #5194, e247431) changed the generic branch of gptqmodel_post_init (gptqmodel/utils/model.py:2273-2274). It now calls _post_init_offloaded(submodule) for every BaseQuantLinear, and that helper starts with:

def _post_init_offloaded(module) -> None:
    if not module.qweight.is_meta:      # model.py:2061
        module.post_init()
        return

Many kernels have no qweight attribute. Their payload lives under other names: NF12 (weight_*), QQQ (B/s_*), VPTQ (indices/centroids), FP8 (weight/weight_scale*), BitsAndBytes (weight), and likely MacaQ, FP4 and the W4A* kernels. Their post_init is never reached. Every GPTQModel.load() of such a checkpoint now raises AttributeError: '<Kernel>' object has no attribute 'qweight'. This happens on a plain single-GPU load (device="cuda:0"), which has no offload at all.

Repro

2-layer Qwen2.5-0.5B-Instruct quantized with each method on main (quantize + save work), then:

from gptqmodel import GPTQModel
for ck in ["qwen2l-nf12", "qwen2l-qqq", "qwen2l-vptq"]:
    m = GPTQModel.load(ck, device="cuda:0")

main @ c1807f8:

FAIL nf12  AttributeError 'NF12Linear' object has no attribute 'qweight'
FAIL qqq   AttributeError 'QQQLinear' object has no attribute 'qweight'
FAIL vptq  AttributeError 'VPTQCudaLinear' object has no attribute 'qweight'
  File "gptqmodel/models/loader.py", line 3845, in from_quantized
    model = gptqmodel_post_init(model, use_act_order=qcfg.desc_act, quantize_config=qcfg)
  File "gptqmodel/utils/model.py", line 2275, in gptqmodel_post_init
    _post_init_offloaded(submodule)
  File "gptqmodel/utils/model.py", line 2061, in _post_init_offloaded
    if not module.qweight.is_meta:

At e247431^ (before #5247), the same three checkpoints load, and a forward returns finite logits:

OK nf12 ['NF12Linear'] finite True
OK qqq ['QQQLinear'] finite True
OK vptq ['VPTQCudaLinear'] finite True

GPTQ (Marlin), EXL3 and Paro checkpoints still load, because they have a qweight.

Suggested fix

Do not key the meta check on qweight. Check whether any persistent tensor of the module is on meta, e.g. any(t.is_meta for t in itertools.chain(module.parameters(recurse=False), module.buffers(recurse=False))). Better still, only take the offload branch when the layer actually has an Accelerate offload hook, and call module.post_init() unchanged otherwise.

Test that should have caught it

The #5247 tests only cover GPTQ/AWQ-GEMM modules (which have qweight). A load smoke test over one checkpoint per kernel family (NF12, QQQ, VPTQ, FP8, BnB) would have caught this. Every family has a save -> load test in tests/ that should now be red on a GPU host.

Severity

High. This is a regression that stops every NF12, QQQ, VPTQ (and by the same code path FP8 / BitsAndBytes / MacaQ / FP4) checkpoint from loading with GPTQModel.load.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

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

    Started 2026-11-18T15:45:01Z. 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: fix the #5247 regression: gptqmodel_post_init must not assume every BaseQuantLinear owns a qweight; route each kernel through its own meta/offload probe so NF12/QQQ/VPTQ/FP8/BnB checkpoints load again on a plain single-GPU load, with a per-kernel load regression matrix

  2. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Additional data from the round-22 quality sweep (main @ c1807f8, RTX 4090 and R9700/ROCm), loading checkpoints with BACKEND.AUTO:

    checkpoint family kernel picked by AUTO GPTQModel.load on main
    MacaQ (Llama-3.2-1B-Instruct, Qwen2.5-0.5B-Instruct) MacaqTritonLinear AttributeError: 'MacaqTritonLinear' object has no attribute 'qweight'
    NF12 (both models) NF12Linear AttributeError (same path)
    QQQ (both models) QQQLinear (CUDA) / QQQTorchLinear (ROCm) AttributeError (same path)
    FP8 (both models, legacy weight_scale_semantics="inverse") TorchFP8Linear loads; first-window logits are bitwise equal to 396b5f0
    EXL3, GGUF, Paro, GPTQ/AWQ (Marlin, ExllamaV2, Torch, AWQ GEMM Triton) - load fine

    So MacaQ is confirmed affected. FP8 is not affected, because TorchFP8Linear exposes a qweight property (#4948). The same crash also hits the in-session quantize -> save() -> GPTQModel.load() round trip for NF12 and QQQ on ROCm, not only older checkpoints.

    When _post_init_offloaded calls plain module.post_init() for modules without qweight (the pre-#5247 behaviour), every one of these checkpoints loads again with unchanged PPL.

    🤖 Generated with Claude Code

  3. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

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

    PR: #5276 — base main, head a5a46600d (branch fix/5261-post-init-payload), 5 files, +736/−2.

    Fix

    _post_init_offloaded (and _post_init_cpu_offloaded_marlin) decided "disk-offloaded?" from module.qweight.is_meta. NF12, QQQ, VPTQ, BitsAndBytes and MacaQ never register qweight, so every plain GPTQModel.load() raised AttributeError before post_init ran.

    • BaseQuantLinear.checkpoint_payload_tensors() resolves the family's own CHECKPOINT_REQUIRED_BUFFERS (dotted submodule names included) and falls back to list_buffers() when a kernel declares nothing or its declared tensors were replaced by a derived cache.
    • BaseQuantLinear.checkpoint_payload_is_meta() is the new offload probe.
    • Both post-init paths now ask the kernel instead of assuming the GPTQ name. Resident layers still run post_init exactly once; meta layers still go materialize → post_init → restore-meta; undeclared meta kernels still fail closed.
    • docs/kernel-dispatch-cpu.md documents the contract.

    Evidence

    family main c1807f889 e24743120^ fixed
    GPTQ / FP8 OK OK OK
    NF12 / QQQ / VPTQ / BnB AttributeError OK OK
    • New tests/test_post_init_payload_5261.py: 14 failed, 2 passed on pristine main → 16 passed on the fix (the 2 pristine passes are the GPTQ/Marlin control and FP8, whose PEFT adapter exposes a qweight property).
    • test_hf_bridge_cpu_offload_5022.py + new file: 32 passed (re-verified by the parent agent).
    • Family sweep over nf12/qqq/vptq/fp8 load/save/reload/roundtrip/checkpoint: 160 passed, 4 skipped; load tests 42 passed / 7 skipped; offload tests 27 passed; BnB reload 1 passed; ruff clean.

    Not verified: MacaQ end-to-end load (payload-contract unit only; FP4 is not a BaseQuantLinear; W4A* inherits the GPTQ payload — reasoned, not loaded); device_map="disk" end-to-end for non-Marlin kernels (meta materialize/restore covered on CPU with a real NF12 layer plus fakes); tests/test_offload_files.py and tests/test_loader.py not run in full.

  4. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Fixed by #5276 (merged as 0054a03): gptqmodel_post_init now asks each kernel for its checkpoint payload (checkpoint_payload_is_meta()) instead of reading module.qweight, so NF12/QQQ/VPTQ/BnB checkpoints load on a plain single-GPU load again. Closing — the PR body did not carry the auto-close keyword.

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