Skip to content

[BUG] #4554 incomplete: AWQ format=GEMV_FAST / LLM_AWQ quantize() still always raises at the end (no CPU in-session reader; #4599 fixed only GEMV), calibration lost; 2 repo tests red #4736

Closed

Description

@Qubitium

Found on main @ b225a43, RTX 4090 (CUDA 13.2, torch 2.15). The same happens on ROCm R9700, where the CUDA AWQ extension is not available. #4554 was fixed only for FORMAT.GEMV (fd8d524, #4599); FORMAT.GEMV_FAST and FORMAT.LLM_AWQ still raise.

What is wrong

At the end of quantize(), rehome_quantized_kernel() (gptqmodel/models/base.py:~631-698) moves the packed AWQ layers to a kernel that runs on the final device (cpu). #4599 added AwqGEMVTorchLinear as the CPU in-session reader for FORMAT.GEMV. There is still no CPU reader for the GEMV_FAST and LLM_AWQ layouts, so for those formats:

  1. select_in_session_quant_linear(qcfg, cpu) raises ValueError("No valid quant linear").
  2. That error is turned into a hard RuntimeError:
RuntimeError: Quantize: quantized layers use kernels that cannot run on the final device `cpu` (AwqGEMVFastLinear). The in-session model cannot run inference; save the quantized model and reload the saved checkpoint on this device (or use the portable Torch backend) before using it.

The whole calibration is lost and nothing is saved. The message tells the user to save, but quantize() raised before save() could be called. This is the same failure #4554 described for GEMV.

Repo tests that fail on main (CUDA, and ROCm via the same path)

  • tests/test_awq_gemv_fast.py::test_awq_gemv_fast_quantized_model_loads_and_generates: ValueError: No valid quant linear -> RuntimeError (above)
  • tests/test_awq_llm_awq.py::test_llm_awq_checkpoint_loads_with_gemv_fast_backend_and_generates: same error, with LLMAwqLinear

Minimal repro

Qwen2.5-0.5B-Instruct truncated to 2 layers, 16 C4 samples:

import torch
from gptqmodel import GPTQModel
from gptqmodel.quantization.config import AWQConfig, CalibrationConfig
calib = [...]  # 16 C4 texts
for fmt in ("gemv_fast", "llm-awq", "gemv", "gemm"):
    model = GPTQModel.load("Qwen/Qwen2.5-0.5B-Instruct", AWQConfig(bits=4, group_size=128, format=fmt), dtype=torch.float16)
    try:
        model.quantize(CalibrationConfig(dataset=calib))
        print(fmt, "OK", type(next(m for m in model.model.modules() if hasattr(m, "qweight"))).__name__)
    except Exception as e:
        print(fmt, "RAISED", type(e).__name__, str(e)[:120])

Output:

gemv_fast RAISED RuntimeError Quantize: quantized layers use kernels that cannot run on the final device `cpu` (AwqGEMVFastLinear). ...
llm-awq RAISED RuntimeError Quantize: quantized layers use kernels that cannot run on the final device `cpu` (LLMAwqLinear). ...
gemv OK AwqGEMVTorchLinear
gemm OK AwqTorchLinear

Suggested fix

Do what #4599 did for GEMV: give GEMV_FAST and LLM_AWQ (the same interleaved layout family) a Torch/CPU in-session reader. Alternatively, make rehome_quantized_kernel() non-fatal when no in-session kernel exists: leave the modules un-rehomed, warn, and allow save(), as #4554 suggested. In either case, quantize() must not throw away a finished calibration.

Test that should have caught it

The two repo tests above. They have been red since the #4426 rehome, and #4599 ran only the GEMV variant.

Severity

High for users of format="gemv_fast" / "llm-awq": the documented quantize -> save flow cannot complete on any device.

🤖 Generated with Claude Code

Activity

  1. n-o-t-mugen commented on Nov 17, 2026

    @n-o-t-mugen
    Contributor

    hey! i could take this up

  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Two more repo tests hit this. Both are in the long tests/test_checkpoint_method_compatibility.py file (about 30 min, so they time out in a 600 s CI slot):

    • test_format_checkpoint_recovery[awq-gemv_fast]
    • test_eora_format_checkpoint_recovery[awq-gemv_fast]
    RuntimeError: Quantize: quantized layers use kernels that cannot run on the final device `cpu` (AwqGEMVFastLinear). The in-session model cannot run inference; save the quantized model and re...
    

    (Seen on main @ b225a43, RTX 4090.)

    🤖 Generated with Claude Code

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