Skip to content

[BUG] With default offload_to_disk=True, using the model in-session after quantize() is broken: CPU input_ids silently generate garbage, CUDA inputs and string prompts crash #4203

Closed

Description

@Qubitium

Severity: medium (default config; one input form returns silently wrong output)
Version: 7.11.0 @ 9dad249

Summary

  • looper/module_looper.py:1904-1918 offloads base modules (embed_tokens) to disk/meta and never restores them after quantization.
  • utils/structure.py:1272-1273: LazyTurtle.materialize_submodule calls target_model.tie_weights() after every layer. That re-ties lm_head.weight to the meta embedding parameter, which has no offload hook.
  • Afterwards model.device is meta.

Reproduce (Qwen3-0.6B, tied embeddings)

from gptqmodel import GPTQModel, QuantizeConfig
cal = ["The quick brown fox jumps over the lazy dog. " * 8 + str(i) for i in range(16)]
for off in (False, True):
    m = GPTQModel.load("Qwen/Qwen3-0.6B", quantize_config=QuantizeConfig(bits=4, group_size=128, offload_to_disk=off))
    m.quantize(cal, batch_size=4, calibration_data_min_length=1)
    hf = m.model
    print(off, hf.device, hf.get_input_embeddings().weight.device, hf.get_output_embeddings().weight.device)
    print(m.generate(**m.tokenizer("Hello, my name is", return_tensors="pt"), max_new_tokens=8, do_sample=False)[0].tolist())
    m.generate("Hello, my name is", max_new_tokens=8)

Actual with offload_to_disk=True:

  • embed_tokens and lm_head are meta, and hf.device == meta.
  • CPU ids generate [..., 374, 24, 0, 0, 0, 0, 0, 0, 0] (garbage).
  • A string prompt raises Tensor.item() cannot be called on meta tensors.
  • CUDA ids raise Expected all tensors to be on the same device ... cuda:0 and cpu in RMSNorm.

Expected: output identical to offload_to_disk=False in-session and to the reloaded checkpoint ([9707, 11, 847, 829, 374, 1172, 95480, 453, ...]), or a clear error telling the user to reload the saved checkpoint.

Different path from the lm_head=True + tied + offload crash in #4184.


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run 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. self-assigned this
    on Nov 16, 2026
  3. Qubitium commented on Nov 16, 2026

    @Qubitium
    CollaboratorAuthor

    Round-11 follow-up at 842d666: the same symptom with offload_to_disk=False, for non-GPTQ methods.

    After quantize(), the quantized modules sit on CPU.

    • GPTQ: picks TorchLinear, so in-session generate() works.
    • AWQ: picks AwqGEMMLinear / AwqGEMVLinear / AwqGEMVFastLinear.
    • QQQ: picks QQQLinear.
    • GGUF q_k_m: picks GGUFTritonKernel.

    These kernels are all CUDA-only, so in-session generation crashes:

    m = GPTQModel.load("Qwen/Qwen3-0.6B", quantize_config=QuantizeConfig(method="awq", format="gemm", bits=4, group_size=128, offload_to_disk=False))
    m.quantize(cal)
    m.generate("Hello", max_new_tokens=4)
    • AWQ: NotImplementedError: Could not run 'gptqmodel_awq::gemm_forward' with arguments from the 'CPU' backend.
    • QQQ: fails inside qqq_gemm.
    • GGUF: raises "GGUFTritonKernel only supports CUDA/ROCm".
    • Expected: a usable in-session model, as with GPTQ, or a clear error telling the user to reload the saved checkpoint.

    Found by AI-assisted review (Claude Code) on RTX 4090.

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