vllm.models.kimi_k3.amd.specialized_decode.mono.attention.mla_back
¶
M1b mla_post: one Kimi-K3 MLA layer from AITER's decode output to
o_proj's input, at TP8 + DCP8 (the DCP group the TP group) or TP8 + DCP1.
AITER leaves every rank the partial attention of its KV shard for all the
gathered heads (o [S, ranks x 12, 512] bf16 and lse [S, ranks x 12]
f32, strided views). As dcp_a2a_lse_reduce -> _v_up_proj -> the gate:
push (a wave a (token, head), over every CTA)
o / lse of rank p's heads -> rank p's CMB: the o row
untagged, then the LSE pair as its flag (an LSE of
-inf for a row with no local KV or past the batch, as
``_dcp_a2a_pack_send_kernel`` masks it)
combine (a CTA a (head, 4 tokens))
the ranks' partials in rank order, LSE-weighted in
fp32 -> bf16 latents in LDS
W_UV (a wave 16 of the head's 128 rows)
the latents -> MXFP4 (aiter's even scale), four FP4
MFMAs against W_V -> bf16, times the gate -> ``core``
At DCP1 (ranks 1) o [S, 12, 512] is already the attention's output, as
vLLM hands it to _v_up_proj: no push, no LSE; the combine stage loads it.
With splits (M1c mla_attn's partials: o / lse split 0 of dense
[splits, S, 12, 512] bf16 / [splits, S, 12] f32) the combine stage merges a
token's request's splits, LSE-weighted.
K2 (layer, K2Build.m1b_qlen) runs these stages in its own launch.
Functions:
-
combine_ranks–stage_combineat DCP8: the ranks' CMB partials, LSE-weighted. -
combine_splits–stage_combineat DCP1 over M1c's partials: token t's request's splits -
combine_tasks–The combine + W_UV tasks over CTAs 0 ..
ctas;done(task)after -
ctok–Tokens a combine task: TT, or with M1c's splits the fewest of 1, 2, 4
-
host_args–ABI's
o..gate(mla_post's, or K2's fused M1b's). -
mla_post–Host launcher.
o[S, >= ranks x 12, 512] bf16 andlse[S, >= -
sane–NaN / +inf -> -inf (
_dcp_a2a_unpack_combine_kernel). -
stage_combine–Tokens t0 .. t0 + 4 of head h: thread (token tid / 128, latents
-
stage_push–Rank p's heads of this rank's partials -> rank p's CMB: a wave a (token,
-
stage_uv–The LDS latents of tokens t0 .. t0 + 4 against W_V[h]'s 16 rows of this
-
tasks–Combine tasks: a (head,
tctokens), head-minor (task h + 12 tile). -
wv_loads–This lane's W_V operands for the wave's 16 rows: (16 B, scale) a step.
combine_ranks(c, h, t0, tt, cc, t)
¶
stage_combine at DCP8: the ranks' CMB partials, LSE-weighted.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
combine_splits(c, t0, h)
¶
stage_combine at DCP1 over M1c's partials: token t's request's splits
(splits / requests of them, request-major), LSE-weighted. Wave tt < tc
(the task's tokens) turns token t0 + tt's LSEs into weights (LDS cw);
then a token's WAVES / tc waves (parts) sum the splits part, part + parts,
.. a thread 8 latents of a token (16 B loads, CB in flight), the parts'
sums halved through cw (the upper half's handed over) to part 0.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
combine_tasks(c, ctas=BLOCKS, done=None)
¶
The combine + W_UV tasks over CTAs 0 .. ctas; done(task) after
each task's core rows are stored (K2's fused M1b: their flag).
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
ctok(s, q, splits, ctas=BLOCKS)
¶
Tokens a combine task: TT, or with M1c's splits the fewest of 1, 2, 4
whose parts (WAVES / it a token) divide a request's splits and whose tasks
fit ctas (a CTA's reads, a part's splits a thread, over more CTAs).
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
host_args(ranks, o, lse, seq_lens, qsl, w_v, w_v_scale, gate)
¶
ABI's o .. gate (mla_post's, or K2's fused M1b's).
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
mla_post(key, *, o, lse, seq_lens, qsl, w_v, w_v_scale, gate, core, peers, rank, layer, epoch, health, alarm, tl=None, scratch=None)
¶
Host launcher. o [S, >= ranks x 12, 512] bf16 and lse [S, >=
ranks x 12] f32, rows and heads strided (ranks 1: no lse, peers
may be None); seq_lens [requests] and qsl
[requests + 1] int32 (the local KV lengths, the query starts); w_v (12,
128, 256) u8 MXFP4 and w_v_scale (12, 128, 16) e8m0, any strides but
W_V's last; gate / core [S, 1536] bf16, dense.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
sane(lse)
¶
NaN / +inf -> -inf (_dcp_a2a_unpack_combine_kernel).
stage_combine(c, h, t0)
¶
Tokens t0 .. t0 + 4 of head h: thread (token tid / 128, latents 4 (tid % 128) ..) combines the ranks' partials into the LDS row.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
stage_push(c)
¶
Rank p's heads of this rank's partials -> rank p's CMB: a wave a (token, head), the waves over every CTA first. The o row goes untagged (a lane 16 B a destination, half the bytes of tagged pairs: the push is xGMI-bound), then once the wave's stores drained, the LSE pair, its tag the row's flag.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
stage_uv(c, h, t0, ops)
¶
The LDS latents of tokens t0 .. t0 + 4 against W_V[h]'s 16 rows of this
wave -> bf16, times the gate -> core.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/attention/mla_back.py
tasks(s, tc=TT)
¶
Combine tasks: a (head, tc tokens), head-minor (task h + 12 tile).
wv_loads(c, h)
¶
This lane's W_V operands for the wave's 16 rows: (16 B, scale) a step.