Skip to content

[BUG] RTN format=GEMM + default offload still crashes in AWQ pack: weight-only looper leaves counterless source Parameters (#6539 follow-up) #6595

Done

Description

@Qubitium

Summary

Follow-up to #6539 / #6564, which fixed one consumer only. RTNConfig(format=FORMAT.GEMM) (RTN exported in AWQ layout) with the default offload_to_disk=True still crashes on current main (2a87e13), in the AWQ packer:

weight_only_looper.py _finalize_quantized_module -> weight_only_processor.submodule_finalize
 -> utils/model.py pack_module -> nn_modules/qlinear/torch_awq.py pack: weight.t()
RuntimeError: Inference tensors do not track version counter.

The issue was reported in the #6564 / #6539 comments; the reproduction is below.

Repro

import torch
from gptqmodel import GPTQModel
from gptqmodel.quantization import FORMAT, RTNConfig

m = GPTQModel.load("Qwen/Qwen2.5-0.5B-Instruct", RTNConfig(bits=4, group_size=128, sym=False, format=FORMAT.GEMM),
                   device="cuda:0", dtype=torch.float16)
m.quantize()   # RuntimeError: Inference tensors do not track version counter.

tests/test_awq_variable_length_ppl.py::test_awq_beats_rtn_with_variable_length_calibration fails the same way. CPU and CUDA are both affected. offload_to_disk=False works.

Root cause (producer)

Tracing one module: after pre_quantize, the layer's q_proj.weight is an inference tensor, materialized by the lazy source under inference_mode. WeightOnlyLooper._move_named_module_to_cpu then rebinds it with .data = outside inference mode. The result is the #4572 state: is_inference() == False and no version counter. Every consumer that views the tensor raises:

Fix

Repair the producer state once, before finalize. In WeightOnlyLooper._finalize_quantized_module, call replace_inference_parameters(named.module) under inference_mode(False) before pack and offload. This is the existing #4450/#4572 helper, and it only clones parameters that lack a counter.

Environment: RTX 4090, torch 2.15.0+cu132, transformers 5.23.0.

Activity

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