vllm.models.kimi_k3.amd.specialized_decode.mono.layer
¶
K2 layer_post: one Kimi-K3 layer from the attention's core output (the
o_proj input) to the layer's MoE output, in one launch -- K2a's o_proj, its
all-reduce and the MLP AttnRes seam, then K2b's latent MoE (moe).
As ATOM's layer_post, the two halves share the launch so that the MoE's
static weights stream while the AttnRes chain (partials -> reduce -> slice ->
gate -> mix) is still settling: the CTAs that will run the router, latent and
shared gate/up GEMVs issue their weights before they first wait.
CTAs 0 .. 55 K2a's reduce + AttnRes (slice, gate, mix -> x rows + XRDY);
then route (0 .. S-1) and the shared SiTU (8 .. 8+S-1)
CTAs 56 .. 159 o_proj (448 x 16 rows) -> partials to every rank; then
the shared gate/up (96 tasks, weights right after o_proj)
CTAs 160 .. 243 router parts (28) and latent parts (56): weights first
every CTA ug; down (0 .. 223) or the shared down (224 .. 255);
lnorm (56 .. 83), up (0 .. 55), reduce (200 .. 255)
An MLA layer's K2 runs its M1b (mla_back) first, in the same launch: every
CTA pushes, CTAs 0 .. 55 combine and write core (a flag a head and 4
tokens), and the o_proj CTAs, their weights in flight, poll the flags of a core
tile before they load it. That removes the M1b -> K2 launch boundary.
Functions:
-
extra_peer_end–The end (from the kernels' peer base) of every region the OPT_* bits
-
k2_launch–Host launcher:
core[S, 1536] (o_proj's input),prefixupdated in -
k2_sent–(OPT_SENTS) Whether build
key's all-reduces go through the sentinel -
m1b_ctok–The fused M1b's tokens a combine task (over its NA CTAs).
-
peer_layout–K2a's AR region, then K2b's: one parity's (name -> (byte offset, bytes)).
-
rlogp_half_bytes–(OPT_RLOG_PARTS) One epoch parity's RLOGP, tagged pairs
-
sent_layout–(OPT_SENTS) One layer parity's sentinel regions, name -> (byte
-
sent_offset–(OPT_SENTS) Byte offset (from the kernels' peer base) of the sentinel
-
stage_oproj–o_proj tasks gi, gi + 200, gi + 400 (< 448): every task's weights in
-
tag_layout–(OPT_TAG_X) The tagged rows' scratch region (name -> (byte offset,
-
xl_words–The int32 words of the bf16 row tile LDS
xlthe GEMV stages share:
extra_peer_end()
¶
The end (from the kernels' peer base) of every region the OPT_* bits add to the peer buffer.
k2_launch(key, *, core, w_o, prefix, blocks, ares_nw, ares_qk, in_nw, w_gate, bias, w_ld, w_sgu, w_sd, w13, w13s, w2, w2s, ln_w, w_up, out, scratch, peers, rank, epoch, layer, health, alarm, tl=None, m1b_in=None, m1c_in=None)
¶
Host launcher: core [S, 1536] (o_proj's input), prefix updated in
place, out the MoE output [S, 7168]; MoE weights as moe. With
key.m1b_qlen, m1b_in is mla_back.mla_post's (o, lse, seq_lens,
qsl, w_v, w_v_scale, gate) and this launch writes core first. With
key.m1c, m1c_in is mla_attn.mla_attn's (q, kv, pages, indptr,
scale, kv_scale), its partials M1b's o / lse (split 0's views).
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/layer.py
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | |
k2_sent(key)
¶
(OPT_SENTS) Whether build key's all-reduces go through the sentinel
regions. The one predicate the push and the reduce of every one of them
use: a push the reduce does not take would leave words neither polled nor
re-armed, and the next launch's reader would hang.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/layer.py
m1b_ctok(key)
¶
The fused M1b's tokens a combine task (over its NA CTAs).
peer_layout(s)
¶
K2a's AR region, then K2b's: one parity's (name -> (byte offset, bytes)).
rlogp_half_bytes()
¶
(OPT_RLOG_PARTS) One epoch parity's RLOGP, tagged pairs
[src rank][part][token][router row], SENT_ROWS rows.
sent_layout()
¶
(OPT_SENTS) One layer parity's sentinel regions, name -> (byte offset, bytes): a word a (rank, bf16 pair, row), SENT_ROWS rows.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/layer.py
sent_offset()
¶
(OPT_SENTS) Byte offset (from the kernels' peer base) of the sentinel regions: past K2's regions and M1's at their largest (DCP8), so no other region moves. Two layer parities.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/layer.py
stage_oproj(c, gi)
¶
o_proj tasks gi, gi + 200, gi + 400 (< 448): every task's weights in flight at once (one memory latency, not three), then the MFMAs a core tile of 16 rows at a time.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/layer.py
tag_layout()
¶
(OPT_TAG_X) The tagged rows' scratch region (name -> (byte offset,
bytes)), past every launch's layout at its largest (K1's, M1a's,
K2's: as MonoRunner sizes the scratch), so no other launch's plain
word sits where these keep tags.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/layer.py
xl_words(s)
¶
The int32 words of the bf16 row tile LDS xl the GEMV stages share:
the core tile (o_proj), the early stages' x tiles, every h row (the shared
down) and the LN tile (up).