vllm.models.kimi_k3.amd.specialized_decode.runtime.mla
¶
An MLA layer's decode, split where the mono kernels split it (vLLM's ops, the reference M1a / M1b reproduce):
pre: qkv_a, the q / kv norms, q_b, W_UK (fp4), the query's fp8 quant, this rank's KV-cache rows, the DCP query all-gather (DCP8), the output gate.attend: AITER's MLA decode on the (gathered) query (forward_mqa), on M1a's padded query as is. At DCP1 with qlen 4 / 8 K2 runs the decode itself (M1c,m1c_inputs).post: the DCP LSE combine (DCP8), W_UV (fp4), the gate: o_proj's input.
Pure decode only (every row a decode row), as the mono step is.
Functions:
-
attend–The partial (this rank's KV) attention:
o[S, heads * dcp, 512] and -
context–(metadata, MLAAttention, kv_cache, slot_mapping)of the step. -
m1c_inputs–K2's
m1c_infor M1a's bf16 queryq[S, 12, 576] and its new -
post–o_proj's input [S, heads * 128] bf16.
-
pre–hidden: input_layernorm's output [S, 7168]. Returns the gathered fp8 -
qkv_gate_weights–fused_qkv_a's [2112, 7168] and g_proj's [1536, 7168] weights: row
attend(wrapper, q8, kv_cache, md)
¶
The partial (this rank's KV) attention: o [S, heads * dcp, 512] and
its LSE [S, heads * dcp] (None at DCP1), both possibly strided views.
q8 may carry more heads than the layer: AITER's cprr pad (e.g. 96 ->
128, M1a writes it). forward_mqa gets the real heads, a view whose row
stride spans the pad, and AITER's get_mla_padded_q widens it back to
q8 instead of copying.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/mla.py
context(wrapper)
¶
m1c_inputs(wrapper, q, kv_cache, md)
¶
K2's m1c_in for M1a's bf16 query q [S, 12, 576] and its new
partials, o [splits, S, 12, 512] bf16 and LSE [splits, S, 12] f32 (M1b
merges the splits).
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/mla.py
post(wrapper, o, lse, md, gate)
¶
o_proj's input [S, heads * 128] bf16.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/mla.py
pre(wrapper, hidden, kv_cache, slots, bf16=False)
¶
hidden: input_layernorm's output [S, 7168]. Returns the gathered fp8
query [S, heads * dcp, 576] (bf16, DCP1: bf16, unquantized) and the
gate sigmoid(g_proj) [S, 1536]; writes the rows whose slot is this
rank's.
Source code in vllm/models/kimi_k3/amd/specialized_decode/runtime/mla.py
qkv_gate_weights(wrapper)
¶
fused_qkv_a's [2112, 7168] and g_proj's [1536, 7168] weights: row
slices of one [q_a | kv_a | gate] weight where vLLM merges the gate in
(KimiK3MergedQKVGateLinear); the gate None without one.