Skip to content

[BUG] Follow-up on #4380/#4381: after quantize() with the default offload_to_disk=True, layers stay disk-offloaded and hooked (can't .to(), re-read every forward, break after gc); AWQ/QQQ keep CUDA-only kernels on CPU; FP8/GGUF hit a device mismatch #4450

Closed

Description

@Qubitium

Severity: high. Kind: incomplete fix of #4380 (3cc0492) and #4381 (1b48454). 03f778e/a427804 make one part worse. Confirmed at 489aed6 on an RTX 4090 with Qwen2.5-0.5B-Instruct.

The #4380 decode fix works. Over an 8-config matrix (gptq/gptq_v2 × sym/asym × desc_act), in-session NLL now matches the reloaded checkpoint within 3e-4. But the in-session model is still not a normal model.

1. Offload hooks and meta tensors stay on quantized layers

m = GPTQModel.load("Qwen/Qwen2.5-0.5B-Instruct", quantize_config=QuantizeConfig(bits=4, group_size=128))
m.quantize(calib, batch_size=8)
  • (a) Hooks and meta tensors remain. 168 modules still have _hf_hook and 912 meta buffers remain. Every forward re-reads the quantized weights from the safetensors bundles on disk. The offload_to_disk=False control has 0 hooks and 0 meta tensors.
  • (b) The model can't be moved. m.model.to("cuda:0") raises NotImplementedError: Cannot copy out of meta tensor. The model is left half-moved, and a later generate fails with "Expected all tensors on the same device".
  • (c) The model breaks after gc. hf = m.model; del m; gc.collect(); hf(**ids) raises FileNotFoundError: .../run-<id>/model.layers.0.self_attn.q_proj/module.safetensors. The weakref.finalize on the BaseQModel (gptqmodel/utils/offload.py:120-125, added for [BUG] Every quantize() creates a new full-size run-<uuid> directory under offload_to_disk_path, and it is never deleted (regression from 2bc2f63, #4202) #4368) deletes the run directory while the HF module still reads from it.

Where:

  • looper/module_looper.py:1872-1905: _restore_offloaded_base_modules restores only the base (non-quantized) modules.
  • utils/offload.py:~750: the hooks on quantized modules are never removed.

Expected: at loop exit, quantized layers are materialized back into memory, the same way they are with offload_to_disk=False.

2. AWQ/QQQ in-session still use CUDA-only kernels on CPU

m = GPTQModel.load(M, quantize_config=QuantizeConfig(method="awq", format="gemm", bits=4, group_size=128))
m.quantize(calib); m.model(**ids)
  • Actual: NotImplementedError: Could not run 'gptqmodel_awq::gemm_forward_fp32_reduce' ... 'CPU' backend. QQQ gives the same error from gptqmodel_qqq::qqq_gemm.
  • Cause: rehome_quantized_kernel (models/base.py ~600-660). Every qweight is on meta while offloaded, so runtime_device() skips them all, device is None, and the function returns without switching the kernel.
  • Control: with offload_to_disk=False, AWQ switches to AwqTorchLinear. In-session NLL 16.0237 vs reloaded 16.0235.

3. FP8/GGUF in-session fail with "Expected all tensors to be on the same device, cuda:0 and cpu"

  • Repro: QuantizeConfig(method="fp8") or QuantizeConfig(method="gguf", bits=4, format="q_k_m") with the default offload, call quantize(), then run a forward or generate.
  • What happens:
    • weight_only_looper._materialize_meta_base_modules puts embed_tokens, norm and rotary_emb on CPU.
    • The quantized modules are hooked with execution device CPU.
    • The per-layer input_layernorm and post_attention_layernorm are left on cuda:0.
    • RMSNorm fails at self.weight * hidden_states.
  • Control: with offload_to_disk=False both work.
    • FP8: 16.0344 in-session vs 16.034 reloaded.
    • GGUF: 16.0056 vs 16.0042.

Found during an AI-assisted review (Claude Code, round 13) of 489aed6; repros were run at that commit (A/B against def6e61 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

    A second reviewer confirmed this independently at 489aed6 on an RTX 5090, and found that RTN (weight-only) is affected the same way as FP8/GGUF:

    m = GPTQModel.load("Qwen/Qwen2.5-0.5B-Instruct", quantize_config=RTNConfig(bits=4, group_size=128))
    m.quantize(["The quick brown fox jumps over the lazy dog. " * 8 + str(i) for i in range(16)], batch_size=4)
    m.generate("The capital of France is", max_new_tokens=8)
    • Devices are mixed. embed_tokens and model.norm are on CPU, while all 48 input_layernorm / post_attention_layernorm stay on cuda:0.
    • Every input path fails:
      • generate(str) and a forward with CPU ids fail with Expected all tensors to be on the same device ... cuda:0 and cpu in RMSNorm.
      • A forward with CUDA ids fails with an index_select device error.
    • Where: gptqmodel/looper/weight_only_looper.py:1222-1226. With offload on, the layer-wide post_quantize() CPU move is skipped.
    • Behaviour at def6e61: it failed earlier, with a meta .item() error.
    • Control: with offload_to_disk=False, in-session runs and equals the reload exactly (PPL 24.8083).

    That reviewer also confirmed part 2: AWQ with default offload, then generate → gemm_forward_fp32_reduce ... 'CPU' backend.

    Default-offload GPTQ in-session on CPU is fine: it matches the reload bit-exactly (NLL 3.03941 both).

    (AI-assisted review, round 13 at 489aed6)

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions