Description
At a54f05d, CPU, torch 2.15. Unlike #5577 (TorchFused/TorchAten), this is the ordinary TorchLinear eval path. No int4pack, warm-up, gradients or native extensions required.
import torch
from gptqmodel.nn_modules.qlinear.torch import TorchLinear, TorchQuantEmbeddings
from gptqmodel.quantization import FORMAT
for cls in [TorchLinear, TorchQuantEmbeddings]:
m = cls(bits=4, group_size=32, sym=False, desc_act=False,
in_features=32, out_features=32, bias=False, format=FORMAT.GPTQ_V2, compile=False)
m.qweight.fill_(-1); m.qzeros.zero_(); m.scales.fill_(8192)
m.post_init(); m.eval()
if cls is TorchLinear:
x = torch.zeros(1,32,dtype=torch.bfloat16); x[:,0] = .25
print(m(x)[0,0]); m.train(); print(m(x)[0,0])
else:
m.set_embedding_output_dtype(torch.bfloat16)
print(m(torch.tensor([0]))[0,0])Expected: every decoded weight is (15-0)*8192 = 122880, exactly representable in BF16, so the linear output is 30720 and the embedding value is 122880. Actual: linear NaN in eval, 30720 in train; embedding inf. All inputs, codes, scales and expected outputs are finite. The train-mode result is a control using the same packed tensors.
_dequantize_weight_cached_248 multiplies in the stored FP16 scale dtype. Converting the resulting inf to BF16 is too late. The embedding row-gather also multiplies directly in the scale dtype. Use the base decoder's range-safe multiply in these paths and keep operands wide through reduction if decoded weights do not fit the activation dtype. Check the separate streaming/Triton paths before claiming parity there. Test train/eval against the independently computed BF16 result, plus both embedding lookup routes.
Activity
Qubitium commentedon Nov 20, 2026
Agent claim: working on this — routing the GPTQ_TORCH eval decode through the range-safe base decoder so BF16 stays finite, with a NaN regression.
Qubitium commentedon Nov 20, 2026
Agent claim: released as done — the GPTQ_TORCH eval decode now uses the range-safe decoder, the embedding row gather is widened, and the regression covers BF16/FP16 linear plus both embedding routes.
fix(torch): decode eval weights in a range-safe dtype (#5606) (#5670)
fix(tritonv2): keep the range-safe decode in eval (#5738) (#5920)