[ROCm][Bugfix] Keep zero MiniMax MXFP8 activation blocks finite (#58089)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -113,8 +113,10 @@ def _swiglu_oai_quant_kernel(
|
||||
act = gate * tl.sigmoid(alpha * gate) * (up + beta) # [BLOCK_M, 32] fp32
|
||||
amax = tl.maximum(tl.max(tl.abs(act), axis=1), TINY) # [BLOCK_M]
|
||||
sb = tl.minimum(tl.maximum(tl.ceil(tl.log2(amax / FP8_MAX)) + 127.0, 0.0), 254.0)
|
||||
descale = tl.exp2(sb - 127.0)
|
||||
aq = (act / descale[:, None]).to(aq_ptr.dtype.element_ty)
|
||||
# Computing the E8M0 byte-0 divisor (2^-127) can flush to zero on CDNA.
|
||||
# Use its finite reciprocal so all-zero blocks do not produce 0/0.
|
||||
rescale = tl.exp2(127.0 - sb)
|
||||
aq = (act * rescale[:, None]).to(aq_ptr.dtype.element_ty)
|
||||
tl.store(
|
||||
aq_ptr + offs_m[:, None] * stride_qm + offs_c[None, :] * stride_qn,
|
||||
aq,
|
||||
|
||||
Reference in New Issue
Block a user