Skip to content

[BUG] dequantize_model() on a bf16 GPTQ model now produces fp16 Linear weights, so the forward crashes on a dtype mismatch (regression from 82ab6f1 + c9fb1ed) #4370

Closed

Description

@Qubitium

Severity: medium. Status: confirmed on CPU; A/B tested against 842d666. Kind: regression from 82ab6f1 (#4184), combined with the dtype heuristic added in c9fb1ed (#4181).

Where

  • gptqmodel/utils/model.py:3207-3219 (82ab6f1) now restores every BaseQuantLinear.scales at its checkpoint dtype. GPTQ checkpoints always store fp16 scales (_scales_for_storage).
  • dequantize_model in nn_modules/qlinear/torch.py:1074-1092 takes its target dtype from scales.dtype. c9fb1ed copied the same logic into torch_fused.py and torch_aten_kernel.py.
  • Together, a bf16 model now dequantizes to fp16 dense layers, while norms and embeddings stay bf16.

Repro

import torch
from gptqmodel import GPTQModel, BACKEND
from gptqmodel.nn_modules.qlinear.torch import dequantize_model
m = GPTQModel.load("<Llama-3.2-1B-Instruct GPTQ 4bit g128 checkpoint>", backend=BACKEND.GPTQ_TORCH,
                   dtype=torch.bfloat16, device="cpu")
dequantize_model(m.model)
m.model(**m.tokenizer("Hello", return_tensors="pt"))

Found during an AI-assisted review (Claude Code, round 12) of def6e61; repros were run at that commit (A/B against 842d666 where noted) on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Activity

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

    @Qubitium
    CollaboratorAuthor

    Taking this. I'll investigate against current main, add a targeted regression test, and open a PR. Will report back here if the claim turns out to be invalid or already fixed.

  3. self-assigned this
    on Nov 16, 2026
  4. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions