Skip to content

[BUG] Staged AWQ GSQ (AWQConfig(gsq_training=...)) crashes on every GPU after layer 0: linear.weight.data = weight across inference_mode makes post_quantize view() raise #4561

Closed

Description

@Qubitium

Found on main @ 4b65923, AMD Radeon AI PRO R9700 (gfx1201, ROCm 10.1). The root cause is not ROCm-specific: it affects every GPU run, CUDA included.

What is wrong

AWQConfig(gsq_training=GSQTrainingConfig(enabled=True, initializer="awq")) crashes on any GPU right after the first layer finishes its staged fit:

File "gptqmodel/looper/stage_layer.py", line 1342, in run_layer_stage
    layers[layer_index] = looper.gptq_model.post_quantize(module)
File "gptqmodel/models/base.py", line 4378, in post_quantize
    return move_module_to_cpu_pinned(module)
File "gptqmodel/utils/model.py", line 364, in to_cpu
    source_flat = source.view(-1)
RuntimeError: Inference tensors do not track version counter.

Cause: refine_awq_staged_layer (gptqmodel/looper/gsq_training_awq.py:87) runs inside torch.inference_mode(False) and does

linear.weight.data = weight

The layer's weight Parameter was created under the looper's inference_mode, so it is an inference tensor. Swapping .data for a normal tensor gives a Parameter that reports is_inference() == False but has no version counter. Back in inference mode, any view of it raises. move_module_to_cpu_pinned takes views for every GPU tensor above pin_min_bytes (utils/model.py:364), so post_quantize always crashes on layer 0.

The CPU test tests/test_gsq_staged_public.py (AWQ, device=DEVICE.CPU) does not catch this: on CPU to_cpu returns tensor.to(CPU) and never takes a view.

Repro

Pure-torch reduction of the mechanism:

import torch
with torch.inference_mode():
    lin = torch.nn.Linear(8, 8, bias=False, device="cuda")
    with torch.inference_mode(False), torch.enable_grad():
        lin.weight.data = torch.randn(8, 8, device="cuda")   # what gsq_training_awq.py:87 does
    lin.weight.view(-1)
RuntimeError: Inference tensors do not track version counter.

End to end (Llama-3.2-1B-Instruct, fp16, eager attention, 8 C4 samples, small training budget):

from gptqmodel import GPTQModel
from gptqmodel.quantization.config import AWQConfig
from gptqmodel.quantization.gsq_training_config import GSQTrainingConfig
cfg = AWQConfig(bits=4, group_size=128,
                gsq_training=GSQTrainingConfig(enabled=True, initializer="awq", epochs=1, qk_steps=5,
                                               batch_size=4, microbatch_size=2))
m = GPTQModel.load("meta-llama/Llama-3.2-1B-Instruct", cfg, dtype=torch.float16, attn_implementation="eager")
m.quantize(calib)  # 8 x 2000-char C4 rows

Output: 4 stages of layer 0 train (GSQ stage update 2/2 loss=...), then the RuntimeError above. Nothing is saved.

Suggested fix

Do not swap .data across the inference-mode boundary. Either:

  • copy in place under inference mode: with torch.inference_mode(): linear.weight.copy_(weight) (the shape and dtype already match), or
  • replace the parameter: linear.weight = nn.Parameter(weight, requires_grad=False) created inside inference mode.

Then extend test_gsq_staged_public.py with a CUDA/ROCm case, or with a CPU case that runs move_module_to_cpu_pinned with its view path, so the inference-tensor mix is exercised.

Severity

High for this feature: staged AWQ GSQ cannot complete a single layer on any GPU. The GPTQ staged path is unaffected (it does not go through refine_awq_staged_layer).

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.

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