vllm.models.deepseek_v41.amd.mono.common.mx
¶
FP8 / MX arithmetic the mono kernels share: the E4M3 range, E8M0 scale
codes, the byte of a scale in aiter's shuffle_scale layout, an FP4 weight
tile's operand loads and the scaled MFMA that takes them.
An E8M0 code is a biased exponent; pow2(code) is the scale it stands for.
Functions:
-
clamp_fp8–vclamped to the E4M3 range. -
code_ceil–Biased exponent of the smallest power of two >=
v(v >= 0, finite), -
fp4_tile_load–A lane's 16 B of an FP4 weight's (16, 16)-shuffled 16-row group
rg -
mfma_scaled–One 16x16x128 scaled MFMA (gfx950 f8f6f4): A
a(a_fmt) with E8M0 -
rcp_pow2–1 /
pow2(code), exact (code in [1, 253]): x times it is x / scale -
scale_index–Byte of e8m0 scale (row, col) in aiter's
shuffle_scalelayout: -
udiv–x // dby a constantd > 0as a shift (da power of two, any -
umod–x % das a mask or an unsigned remainder (udiv).
clamp_fp8(v)
¶
code_ceil(v)
¶
Biased exponent of the smallest power of two >= v (v >= 0, finite),
clamped to [1, 254]: the codes a scale may take.
Source code in vllm/models/deepseek_v41/amd/mono/common/mx.py
fp4_tile_load(r_w, base, rg, k, st, at, live=None)
¶
A lane's 16 B of an FP4 weight's (16, 16)-shuffled 16-row group rg
(K = k) at 128-k step st: dword base + the group's 2 k + 256 a
step + at (lane * 4: 32 fp4, K block lane / 16 of row lane % 16).
Nontemporal: a weight a step reads once. live: oob.
Source code in vllm/models/deepseek_v41/amd/mono/common/mx.py
mfma_scaled(a, b, c, sa, sb, a_fmt=FP8, b_fmt=FP8, sa_byte=0, sb_byte=0)
¶
One 16x16x128 scaled MFMA (gfx950 f8f6f4): A a (a_fmt) with E8M0
sa (its byte sa_byte), B b (b_fmt) with E8M0 sb (its
byte sb_byte).
Source code in vllm/models/deepseek_v41/amd/mono/common/mx.py
rcp_pow2(code)
¶
1 / pow2(code), exact (code in [1, 253]): x times it is x / scale
bit for bit, a multiply where the division is a dozen instructions.
scale_index(row, col, cols, sm=False)
¶
Byte of e8m0 scale (row, col) in aiter's shuffle_scale layout:
view(rows/32, 2, 16, cols/8, 2, 4).permute(0, 3, 5, 2, 4, 1) (sm:
in shifts and masks, udiv).
Source code in vllm/models/deepseek_v41/amd/mono/common/mx.py
udiv(x, d, unsigned=True)
¶
x // d by a constant d > 0 as a shift (d a power of two, any
sign) or an unsigned division (x >= 0), where a traced // is a
signed floor division with its fix-ups. unsigned false: //.
Source code in vllm/models/deepseek_v41/amd/mono/common/mx.py
umod(x, d, unsigned=True)
¶
x % d as a mask or an unsigned remainder (udiv).