Skip to content

[BUG] Regression from #5242: gptqmodel_fp8 checkpoints written by GPT-QModel (#5181..#5242) are no longer refused by transformers - they load as plain Linear with only a 'skip quantization' warning and produce NaN (legacy fp8+inverse checkpoints still unguarded) #5272

Closed

Description

@Qubitium

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

What is wrong

#5242 removed FP8_EXPORT_QUANT_METHOD = "gptqmodel_fp8" from REFUSED_HF_QUANT_METHODS (gptqmodel/_quant_methods.py). import gptqmodel therefore no longer registers a refusing quantizer for it. Checkpoints that GPT-QModel itself wrote with quant_method: "gptqmodel_fp8" still exist. Every FP8 save from #5181 up to #5242 produced one: non-block layouts since #5181, and all layouts since #5214. They are inverse-scale FP8 checkpoints.

Before #5242, AutoModelForCausalLM.from_pretrained on such a checkpoint failed with a clear, actionable error. On main, transformers logs "Unknown quantization type ... we will skip the quantization". It then loads the float8 weight tensors into plain nn.Linear with no scales, and the model returns NaN logits. Nothing is raised.

GPTQModel.load of the same checkpoints is fine on main. All three legacy checkpoints below give a 20-window wikitext PPL of 20.947, identical to the old tree. So only the transformers-side guard regressed. docs/fp8-load-only.md:81 and docs/checkpoint-interop.md:517 say gptqmodel_fp8 is "not recognized". That is not what happens on either path.

Repro

FP8 checkpoint of Qwen2.5-0.5B-Instruct written with the default FP8Config() (row/inverse) at 13674151b (the parent of #5242). config.json has "quant_method": "gptqmodel_fp8", "weight_scale_semantics": "inverse".

import gptqmodel  # installs the refusing HF quantizers
from transformers import AutoModelForCausalLM
m = AutoModelForCausalLM.from_pretrained(CKPT, device_map="cuda:0")
tree result
13674151b (pre-#5242) ValueError: GPT-QModel FP8 checkpoints cannot be loaded by transformers; load them with GPTQModel.load. (quant_method: 'gptqmodel_fp8')
main warning Unknown quantization type, got gptqmodel_fp8 ... we will skip the quantization; modules are plain Linear; wikitext PPL (20 x 512) = NaN
main, GPTQModel.load(CKPT) TorchFP8Linear, PPL 20.947 (same as pre-#5242)

Legacy checkpoints written by v7.11.2 and earlier publish plain quant_method: "fp8" with weight_scale_semantics: "inverse". These still get no refusal at all. That is the #5202 case: block layout loads as NaN through FineGrainedFP8, and row layout fails on a shape mismatch. Their config declares weight_scale_semantics: "inverse", which no production FP8 producer writes, so the guard can recognize them.

Suggested fix

  • Keep "gptqmodel_fp8" in REFUSED_HF_QUANT_METHODS / _REMEDIES as a legacy, load-only name, the same way the legacy Paro name is kept.
  • In the HF hook, also refuse a quant_method: "fp8" config that declares weight_scale_semantics: "inverse", with the same "use GPTQModel.load" remedy.
  • Fix the two doc lines that say the name is "not recognized".

Test that should have caught it

tests/test_fp8.py lost its gptqmodel_fp8 refusal assertion in #5242. Add a test with a legacy-config fixture (quant_method: gptqmodel_fp8 or fp8 + inverse) and assert that AutoModelForCausalLM.from_pretrained raises with gptqmodel imported.

Severity

Low-medium. The output is silently wrong (NaN) for GPT-QModel-written FP8 checkpoints loaded through transformers with gptqmodel installed. The gptqmodel_fp8 window was only main between #5181 and #5242. The fp8 + inverse case covers every released FP8 checkpoint up to v7.11.2.

🤖 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-18T16:25:37Z. 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 gptqmodel_fp8 checkpoints written by #5181..#5242 still load after #5242 made FP8 load-only: accept the legacy layout or migrate it, with a round-trip test

  2. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

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

    PR: #5287 — base main, head bdf6b2f82 (branch fix/5272-fp8-legacy-ckpt), 10 files, +423/−38.

    Fix

    The tensor layout never changed: #5242 removed the gptqmodel_fp8 refusal registration and the _normalize_quant_method alias, so a legacy checkpoint either failed as Unknown quantization method: gptqmodel_fp8 (alias-only configs) or — worse — was silently loaded by transformers as a plain Linear, dropping the scales. This restores a read-only compatibility path (no quantize/export comes back):

    • gptqmodel_fp8 is accepted again as an alias of fp8 on the GPT-QModel load path and normalized before kernel selection.
    • The HF refusing-quantizer registration recognizes the legacy name, so the HF path raises the actionable GPT-QModel error instead of silently loading dense weights.
    • fp8 + weight_scale_semantics="inverse" (the legacy GPT-QModel convention) is no longer mis-dispatched to FineGrainedFP8 (which produced a shape mismatch).
    • Docs updated: checkpoint-interop.md, fp8-load-only.md, hf-interop.md, quantization-guide.md, support-matrix.md.

    Evidence

    The legacy fixture was written by the pre-#5242 writer at 13674151b (0.5B, row/inverse) and is kept in .scratch/legacy_qwen25_fp8_row.

    case main 0aa2d4b48 this PR
    alias-only GPTQModel.load ValueError: Unknown quantization method: gptqmodel_fp8 loads, logits sum -1194494.875 (identical to the pre-#5242 tree)
    HF from_pretrained on gptqmodel_fp8 silently loaded as dense Linear, logits sum 1052054.125 raises the actionable ValueError
    HF fp8 + inverse RuntimeError shape mismatch from FineGrainedFP8 correct
    • New tests: 4 failed on pristine main, all green after; tests/test_fp8.py 22 passed; tests/test_fp8*.py (12 files) 117 passed / 2 skipped; FP8 kernels 127 passed / 6 skipped; HF-refusal/checkpoint-compat + docs contract 130 passed / 5 skipped; ruff clean.

    Not verified: no wikitext PPL run (evidence is fixed-prompt logits on the real 0.5B legacy checkpoint plus a dense Torch oracle on the tiny fixture); the real fixture is row/inverse only (block/inverse covered by the tiny fixture); no production fp8 + multiplier checkpoint available (a control test asserts FineGrainedFP8HfQuantizer is still selected); transformers below the repo floor not tested.

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