vllm.models.kimi_k3.amd.specialized_decode.mono.attention.back
¶
K2a attn_post: one Kimi-K3 KDA layer from the gated core output to the
MoE's input row -- o_proj, its TP all-reduce inside the kernel, and the MLP
AttnRes seam.
One launch a layer and rank, BLOCKS x THREADS:
gemv CTAs 56 .. o_proj (448 x 16 rows, K = 1536 local): bf16 GEMV of the
core rows (plain loads: the previous launch wrote them) ->
bf16 partial -> pushed to every rank's AR region (system
scope, this rank's slot)
attn CTAs 0 .. 55 per 128 columns: the 8 ranks' partials summed in rank
order (fp32 -> bf16: the custom all-reduce's result) ->
LDS delta; then K1's AttnRes stages with the MLP's weights:
prefix + delta -> prefix out, the sources' softmax mix,
post_attention_layernorm -> the MoE input x
The AR region is double-buffered by the step epoch's parity: a rank a step ahead writes the other half, so no peer's unread partials are overwritten.
Functions:
-
ar_half_pairs–One parity's AR region:
[src rank][token][column pair]. -
load_core–The core rows (S x 1536 bf16) -> LDS, rows padded.
-
o_loads–Rows 16 rg .. of o_proj, this wave's K chunks (wave, wave + 8 < 12): a lane
-
stage_o–Rows 16 rg ..: GEMV -> bf16 partials -> every rank's AR region, this
-
stage_reduce–Columns 128 task ..: the 8 ranks' partials, rank order, -> bf16 delta in
ar_half_pairs(s)
¶
load_core(c)
¶
The core rows (S x 1536 bf16) -> LDS, rows padded.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/back.py
o_loads(c, rg)
¶
Rows 16 rg .. of o_proj, this wave's K chunks (wave, wave + 8 < 12): a lane 64 B of its row a chunk.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/back.py
stage_o(c, rg, ops)
¶
Rows 16 rg ..: GEMV -> bf16 partials -> every rank's AR region, this rank's slot (thread: token, row pair; a put a peer).
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/back.py
stage_reduce(c, task)
¶
Columns 128 task ..: the 8 ranks' partials, rank order, -> bf16 delta in LDS (thread: token, column pair).