vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.moe.ep.comm
¶
Expert-parallel dispatch and combine of the latent MoE over NVLink symmetric memory (DEP: data-parallel attention at TP1, the 896 routed experts split over N ranks).
Every rank owns one symmetric buffer (EpLayout):
- receive rows, source-major (row = source x stride(T) + token): MXFP8 latent (3584
B), its E8M0 block scales (112 B, the linear layout of
flashinfer.mxfp8_quantize), the token's 16 expert ids and FP32 routing weights, and a source word (one 128-byte line per row, -1 when empty); - combine slots [T, N, 3584] BF16: the per-destination-rank partial of every own token;
- control words: arrival counters and the dispatch / combine flags (one line each).
EpDispatch (one CTA per token) quantizes the BF16 latent to MXFP8 bit-identically
to mxfp8_quantize (two threads per 32-block, 16-byte stores) and writes it, with
ids, weights and source, into its static row on every rank holding one of its
experts. Empty rows keep non-local ids (weight 0), so the expert GEMM over the N T
rows skips them. The last CTA of the rank raises its dispatch flag on every rank and
waits for all N; on completion the rank's receive rows are complete.
EpCombine (G CTAs) sends every received row's BF16 output (the routing-weighted
sum over this rank's experts) to its source's slot [token, rank] and re-arms the row;
the last CTA raises the combine flag on every rank. The CTAs with own tokens then wait
for all N flags and reduce: the FP32 sum of the destination partials in rank order,
rounded once to BF16 (the routed latent), then vLLM's RMSNorm of it (FP32 sum of
squares, rsqrt(mean + eps), x * rstd * w rounded once).
Measured on GB300 NVL72 (16 ranks over 4 nodes), these rules decide the latency: no two ranks write one 128-byte line (row blocks padded to 8 rows, one line per flag and per source word: 200 -> 40 us per dispatch + combine at T=5); a rank reaches its own buffer through its local mapping, never its peer mapping; flags are polled by one lane each (a local poll costs a round trip). Every thread that stored remotely fences at system scope before the CTA's arrival is counted (a single fence after the CTA barrier lost partials at 32 ranks), and every reader fences after the flags.
Flags are single-reader: a writer sets 1, the reader re-arms 0. No rank can raise the next layer's flag before the reader re-armed it: the next dispatch from a source needs the source's combine to finish, which needs this rank's combine flag, raised after this rank's dispatch re-armed; the next combine flag needs this rank's next dispatch, issued after its combine re-armed.
Classes:
-
EpBuffers–One rank's symmetric EP buffer, its peers' base addresses and tensor views of
-
EpCombine–(out [N T, 3584] BF16 per received row, ids [T, 16] own routing, norm weight
-
EpDispatch–(x [T, 3584] BF16, ids [T, 16] int32, weights [T, 16] FP32, peers [N] int64) ->
-
EpLayout–Byte offsets of one rank's symmetric EP buffer for
ranksranks and at most
Functions:
-
last_arrival–Warp-uniform: whether this CTA is the
total-th arrival oncounter -
raise_flags–Lane d sets this rank's flag on rank d (all ranks in parallel).
-
rms_rstd–rsqrtf(total / 3584 + eps) of vLLM's rms_norm (IEEE divide).
-
stride–Receive rows per source rank: a multiple of 8, so no 128-byte line of the
-
wait_flags–Warp: lane s polls flag s (relaxed, all in flight together) until every flag
EpBuffers
¶
One rank's symmetric EP buffer, its peers' base addresses and tensor views of the receive rows (the expert kernel's inputs).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
EpCombine
¶
(out [N T, 3584] BF16 per received row, ids [T, 16] own routing, norm weight [3584] BF16, normed [T, 3584] BF16, peers [N] int64) -> the RMS-normalized routed latent of the rank's own tokens.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
EpDispatch
¶
(x [T, 3584] BF16, ids [T, 16] int32, weights [T, 16] FP32, peers [N] int64) -> compact MXFP8 receive rows on the experts' ranks.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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 | |
EpLayout
¶
Byte offsets of one rank's symmetric EP buffer for ranks ranks and at most
tokens tokens per rank.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
last_arrival(counter, total, lane)
¶
Warp-uniform: whether this CTA is the total-th arrival on counter
(lane 0's atomic after a system fence of the CTA's stores; the last arrival
re-arms the counter). Every lane fences again so its later stores follow.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
raise_flags(peers, offset, rank, lane, ranks)
¶
Lane d sets this rank's flag on rank d (all ranks in parallel).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
rms_rstd(total, eps)
¶
rsqrtf(total / 3584 + eps) of vLLM's rms_norm (IEEE divide).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
stride(tokens)
¶
Receive rows per source rank: a multiple of 8, so no 128-byte line of the receive arrays (3584 / 112 / 64-byte rows) holds rows of two sources (two remote writers of one line serialize on the fabric).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/comm.py
wait_flags(base, lane, ranks)
¶
Warp: lane s polls flag s (relaxed, all in flight together) until every flag is set, then an acquire fence. Local polls cost a round trip each, so the ranks' flags are never polled one after another.