Skip to content

fix(macaq): keep the wide bias through pack and load (#5632) - #5656

Merged
Qubitium merged 1 commit into
mainfrom
fix/5632-macaq-bias
Nov 20, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/5632-macaq-bias

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

MACaQ rounded the canonical bias to the compute/activation dtype before the FP32 reduction. An FP32 bias of -257 became -256 in BF16, so the packed unit weights' 256 product no longer cancelled and the layer returned 0 instead of -1.

  • MacaqLinear.load_quant_result now keeps the source bias dtype (replacing the buffer when the dtype differs) instead of copying into a compute_dtype buffer.
  • MacaqLinear._forward_torch and the W4A16 Triton tail pass the stored bias to linear_fp32_reduce unchanged, so a wider bias is added after the FP32 reduction and only the final output is rounded.
  • MacaqLinear.MODEL_DTYPE_BUFFERS no longer lists bias: a checkpoint FP32 bias survives a BF16 load instead of being narrowed by accelerate. BH/pre_scale still follow the model dtype.
  • Updated the two MACaQ parity tests whose oracle narrowed the bias to BF16 first.

Tests

  • tests/test_macaq_wide_bias_5632.py (new): pack path for BF16 and FP32 construction dtypes, a safetensors checkpoint round trip, and the W4A16 Triton tail with an FP32 bias.
  • tests/test_macaq.py, tests/test_macaq_fp32_reduce_4221.py, tests/test_macaq_forward_dtype_4217.py, tests/test_macaq_single_output_4472.py, tests/test_macaq_rotation_serialization_4225.py, tests/test_checkpoint_quant_buffer_dtypes_4458.py: 163 passed.
  • [email protected] check gptqmodel tests: clean.

Fixes #5632.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MACaQ rounds the canonical bias to compute/activation dtype before a cancelling dot product: BF16 returns 0 instead of -1

1 participant