Skip to content

ParoQuant dense fallback overflows before a cancelling bias is added #3866

Closed

Description

@Qubitium

Reproduction (current main, daa5dae)

import torch
from gptqmodel.nn_modules.qlinear.paroquant import ParoLinear

layer = ParoLinear(
    bits=4, group_size=16, sym=True, desc_act=False,
    in_features=16, out_features=8, bias=True,
    register_buffers=True, krot=1,
).eval()
layer.qweight.fill_(0x11111111)  # Packed 4-bit code 1 in every position
layer.qzeros.zero_()
layer.scales.fill_(8)
layer.bias.fill_(-1024)
layer.post_init()
x = torch.full((1, 16), 516, dtype=torch.float16)

print(layer(x)[0, 0])
# inf
print((x.float() @ torch.full((16, 8), 8.0) + layer.bias.float()).half()[0, 0])
# 65024

The public forward uses the dense CPU fallback for this supported group size. The quantized grid calculation has a finite FP16 output after bias, but the intermediate FP16 dot overflows before bias can cancel it.

Cause

ParoLinear._forward_dense decodes the packed weight to the activation dtype, runs torch.matmul, then adds bias in that dtype. The CPU ATen path in the same class already accumulates bias in FP32 before its final cast. The CUDA AWQ path also appears to return an activation-dtype result before adding bias, though this reproduction executes only the CPU fallback.

Expected

Keep the reduction and bias epilogue in a range that can represent the finite result, then cast once to the output dtype. Add a numeric-range test for the dense fallback and verify the native path. This is the same precision class as #3863 in a separate backend.

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