vllm.models.minimax_m3.amd.specialized_decode.mono.ffn
¶
MiniMax-M3 FFN launch: one persistent kernel from the unreduced o_proj
partial to the reduced MoE output (MiniMaxM3DecoderLayer.forward after its
attention).
BLOCKS x THREADS, S rows, one launch per sparse layer and rank:
push (192 x 32 columns): the partial's bf16 pairs to every rank
reduce (192): the ranks' pairs in rank order, f32 -> bf16; + residual
in f32 -> residual out (bf16), the f32 sum, its sum of squares
norm (S): Gemma RMSNorm of the f32 sum -> X (bf16)
router (8 x 16 experts x 16 K parts): FP32 weight x f32(X), f32 MFMA
route (S): the parts summed in order, sigmoid, + bias for selection,
top-4, renormalized x 2.0
table (every CTA): the union of picked experts in LDS, slot 0 the shared
expert (expert 128) over all S rows
up (48 x slots): 16 gate + 16 up rows of a slot's expert, A16W4 MFMA,
SwiGLU-OAI -> bf16 MID
down (384 x 16 rows): every slot's A16W4 GEMV of MID, routed weights
and shared expert combined -> pushed to every rank
final (192): the ranks' partials in rank order -> ``out``
Classes:
-
Experts–Which expert terms the combine sums: all of them in production; one side
Experts
¶
Bases: Enum
Which expert terms the combine sums: all of them in production; one side alone for stage parity.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
await_x(c, tokens_n)
¶
XRDY of the first tokens_n tokens (thread t polls token t).
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
bf16_bits_f32(bits)
¶
block_sum(c, v, slot)
¶
v summed over the CTA: each wave's butterfly, then waves in order
(LDS red words slot * WAVES ..). Every thread gets the sum.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
epoch_end(c, epoch, tag)
¶
CTA 0, once every CTA marked this launch: the epoch moves on. A mark missing past the wait bound sets the error word instead; the epoch stays.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
finish(c, key, epoch, tag, handshake, inject, peers)
¶
Every CTA marks the launch done after its work; CTA 0 waits for the
marks, then moves the epoch on. The step's last launch (handshake)
then trades every rank's failure flag over the peers: a fault anywhere in
the step is in every rank's error word before this launch ends.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
flag_after_stores(c, addr, i, who)
¶
Pair i := 1 (thread who), released after the CTA's earlier stores.
injected_fault(c, inject)
¶
Fault injection (qualification): rank inject[0] - 1 fails after
inject[1] ticks at the end of the step's last launch.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
load_table(c)
¶
Every valid token's picks -> the slots in LDS: slot 0 the shared expert over the valid rows, slots 1 .. n_u the picked experts ascending; a slot's columns its rows ascending, each column's pick (t * 4 + k; the shared expert's 4 S + t). A padded row's picks are -1: in no slot.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
peer_half_bytes(tp)
¶
One parity's peer regions: the attention partials (triple pairs), then the MoE's (bf16-pair pairs).
put_word(c, addr, i, word)
¶
shared_slot(c)
¶
Slot 0: the shared expert over the valid rows (columns ascending; an unused column reads row 0).
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
slot_col(c, cnt)
¶
stage_down(c, tasks)
¶
Rows 16 task .. of every task in tasks: a slot a wave, round robin,
its MID columns loaded once for every task; a column's result ->
LDS CONTRIB[task][pick], then each token's routed picks (top-k order) x
their weights + the shared expert -> bf16 pairs pushed to every rank's FFN
region.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
stage_norm(c, t)
¶
Token t's Gemma RMSNorm of SRES -> XN, then XRDY.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
stage_push(c, task)
¶
Triples 16 task ..: this rank's partial as triple pairs to every rank's ATTN.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
stage_reduce(c, task)
¶
Triples 16 task ..: the ranks' values summed in rank order (the all-reduce's bf16), + residual in f32 -> residual out, the f32 sum (SRES) and the task's sum of squares (SSQ, a pair a token).
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
stage_route(c, t)
¶
Token t: a thread sums 4 of an expert's 16 logit parts, wave 0 the 4 sums in order (two experts a lane); top-4 of sigmoid + bias (ties to the lower expert), weights the selected sigmoids x (2.0 / their sum).
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
stage_router(c, task)
¶
Experts 16 tile .. over K part part (384 columns, 48 a wave) for
every token: FP32 weight x f32(X) on f32 MFMAs, the waves summed in order
-> LOGIT[token][expert][part]. A lane's float4 of weights and four bf16 of
X feed four MFMAs (K slot = its lane group), the same K order on both.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
stage_up(c, u, j, weights=None)
¶
Slot u's tile pair j: gate rows 16 j .., up rows 768 + 16 j .. of its
expert over this wave's K steps; waves summed in order; SwiGLU-OAI ->
bf16 MID[u][column][16 j ..], then UPF.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
triple_bits(buf, t, triple)
¶
Row t's bf16 at columns 3 triple .. of a [*, HIDDEN] bf16 buffer: one 8-byte load from the dword holding the first, shifted to bits 0 .. 47.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
valid_mask(c)
¶
The step's real rows (a padded row's slot is -1), a bit a row: every wave's lane t < S reads row t's slot.
Source code in vllm/models/minimax_m3/amd/specialized_decode/mono/ffn.py
x_operands(c, base, row, k_dwords, st0, steps)
¶
The lane's B operands of steps st0 ..: row row of a bf16 [*, K]
scratch (k_dwords a row), 8 K values an MFMA.