Skip to content

[BUG] MACaQ MXFP4's 1e-12 amplitude floor flushes exactly representable nonzero weight and activation blocks #5627

Closed

Description

@devin-ai-integration

Reproduced on main 751f33fd, Torch 2.15 CPU. A nonzero block with peak 2^-50 is comfortably inside BF16 and E8M0 scale range. It is exactly representable as E2M1 value 4 × scale 2^-52 (E8M0 byte 75).

import torch
from gptqmodel.quantization.macaq import macaq_quantize_weight, dequantize_mxfp4
from gptqmodel.nn_modules.qlinear.macaq import MacaqLinear
w = torch.full((1,32), 2.**-50)
r = macaq_quantize_weight(w,torch.eye(32),32,rotation="none",pre_mode="none",
                         exp_screen=False,do_flip=False)
print(r.W_scales.view(torch.uint8), dequantize_mxfp4(r.W_packed,r.W_scales,32)[0,0])
m = MacaqLinear(bits=4,group_size=32,in_features=32,out_features=1,had_block=32,
                rotation="none",pre_mode="none",activation_precision="w4a4",dtype=torch.bfloat16)
m.W_packed.fill_(0x22); m.W_scales.fill_(177)  # all weights 1 * 2^50
x = torch.zeros(1,32,dtype=torch.bfloat16); x[:,0] = 2.**-50
print(m(x))

Actual weight scale byte 85, decoded weight 0; actual W4A4 forward 0, expected 1. Both sides of the dot product can be encoded exactly; the loss is not intrinsic to FP4.

mxfp4_rtn_signed_index clamps the peak to 1e-12 before logarithm, conflating a genuine small block with a zero block. Special-case exact zero; for nonzero peaks select/clamp the exponent to E8M0’s actual finite range before computing the codes. Regress scale covariance and W4A4 output. Check accelerated implementations separately; only Torch CPU was executed here.

Activity

  1. added
    scanned
    safe
    on Nov 20, 2026
  2. Qubitium commented on Nov 20, 2026

    @Qubitium
    Collaborator

    Agent claim: working on this — replacing the 1e-12 amplitude floor with a subnormal-safe floor so exactly representable nonzero MXFP4 weights survive, with a pack/dequant regression.

  3. Qubitium commented on Nov 20, 2026

    @Qubitium
    Collaborator

    Agent claim: released as done.

    The 1e-12 floor is now applied only to exact-zero blocks; nonzero peaks use
    floor(log2(amax)) - 2 clamped to E8M0's -127..127 range before the codes
    are computed, and the Torch/Triton activation quantizers got the same
    zero-only floor. The issue's weight repro now packs byte 75 and decodes
    2**-50; the W4A4 forward returns 1.0. Regression coverage is in
    tests/test_macaq_amplitude_floor_5627.py (14 passed), with
    tests/test_macaq*.py at 171 passed / 1 skipped and ruff clean.

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

    safescanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions