vllm.models.kimi_k3.nvidia.specialized_decode.drafter.comm
¶
The DSpark drafter's TP collectives on the specialized decode's Lamport mailboxes.
The stock drafter step at TP8 / DCP8 runs eleven flashinfer one-shot all-reduces (the vocab-parallel embedding, two per draft layer fused with the following RMSNorm, the final norm: 6-9 us each, their own launch + cluster setup and a clear of the previous buffer) and two NCCL ring all-gathers (the column-parallel context projection and the vocab-parallel lm_head logits: 16-20 us each plus a [TP, M, N / TP] -> [M, N] copy). Every one of them moves a few KB to 1.3 MB.
Here they are one kernel each over symmetric Lamport buffers (common.mailbox:
a 16 B fragment is published once none of its 32-bit words is the sentinel):
ArNorm(one 8-CTA cluster per row, 112 threads x 8 columns each): the rank's partial row is multicast into slot [rank] of every rank's [TP, cap, 7168] mailbox (onemultimem.streaches every GPU), the TP slots are polled, summed in FP32 in rank order 0 .. TP-1 and rounded once to BF16 (flashinfer's deterministic one-shot order), the residual is added (one BF16 rounding) and the RMSNorm of the new residual follows (FP32 sum of squares, vllm_c'srsqrt(sum / 7168 + eps),x * rstd * wrounded once). The reader re-arms its slots. Layer parity: the call sites alternate between two mailboxes, so a rank can never write a mailbox its peer has not read yet (two uses of one mailbox are separated by a use of the other, which needs this rank's push, made after its re-arm).Gather: every rank's [M, S] shard multicast into the [cap, TP * S] row of every rank (rank r's at columns r S ..), polled;copy: copied to a dense output and re-armed, else left in place for a reader that re-arms it (the DCP query mailbox, re-armed byDcpValue).
Exactness: the reductions keep every operand at stock precision (BF16 partials, FP32 accumulation, one BF16 rounding; only the order may differ from flashinfer's cluster-tree RMS sum). The gathers move bytes: a 32-bit word equal to the BF16 sentinel pair (+0, -0) is sent as (+0, +0), the only change, and no consumer can tell a negative zero from a positive one (sums, products, comparisons, exp).
Classes:
-
ArNorm–All-reduce of BF16 rows [M, 7168] + residual + RMSNorm (arguments: partial,
-
DrafterComm–The drafter's TP all-reduces and gathers over
group(the TP device group): -
Gather–Every rank's [M, S] 32-bit-word shard -> the [cap, TP * S] mailbox rows
-
LamportRows–A sentinel-filled symmetric [*shape] int32 buffer with its multicast address.
Functions:
-
build–The drafter's collectives over the TP group (capability fallback: None when
-
clean–wordunless it is the sentinel pair (+0, -0), then (+0, +0). -
gather_ctas–CTAs per gathered row: about one fragment per thread, at most ~1.5 waves of
-
store_peer_float–DSMEM store of an FP32
valueinto cluster CTApeer'spointer.
ArNorm
¶
All-reduce of BF16 rows [M, 7168] + residual + RMSNorm (arguments: partial,
residual, gamma, out, residual out, mailbox [TP, cap, 7168], its multicast
address, rank, eps, stream). One cluster of 8 CTAs per row, CTA c owning columns
896 c .. + 895 (thread t < 112: one 16 B fragment): the pushes and polls spread
over 8 SMs, the row's sum of squares is the 8 CTA sums exchanged through
distributed shared memory, added in CTA order. residual False: the new
residual is the all-reduced row itself (the embedding: residual = AR(x)).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
DrafterComm
¶
The drafter's TP all-reduces and gathers over group (the TP device group):
two parities of the [TP, ROWS_CAP, 7168] all-reduce mailbox, the context-
projection gather row [CONTEXT_ROWS_CAP, 7168] and the lm_head logits row
[ROWS_CAP, vocab_padded] (BF16). Built at model load, before the KV-cache memory
profile and every capture. Methods return None for a shape they do not serve
(the caller runs the stock collective).
Methods:
-
ar_norm–fused_allreduce_rms_norm(x, residual, norm)(residualNone: the -
gather_context–The column-parallel context projection's [M, 7168 / TP] -> [M, 7168].
-
gather_logits–The vocab-parallel lm_head's [M, V / TP] -> [M, V] (BF16).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
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 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 | |
ar_norm(x, residual, norm, parity)
¶
fused_allreduce_rms_norm(x, residual, norm) (residual None: the
new residual is AR(x)); None when this shape is not served.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
gather_context(shard)
¶
The column-parallel context projection's [M, 7168 / TP] -> [M, 7168].
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
gather_logits(shard)
¶
The vocab-parallel lm_head's [M, V / TP] -> [M, V] (BF16).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
Gather
¶
Every rank's [M, S] 32-bit-word shard -> the [cap, TP * S] mailbox rows
(arguments: shard, out, mailbox, its multicast address, rank, stream). Grid
(CTAs per row, M): each CTA multicasts its share of the row's shard fragments,
then polls its share of the gathered row (all pushes precede every poll and the
grid is at most a few CTAs per SM, so each CTA a poll waits on is resident or
done). copy: the row is copied to out and re-armed (out is unused
otherwise).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
LamportRows
¶
A sentinel-filled symmetric [*shape] int32 buffer with its multicast address.
Methods:
-
view–(the [index] sub-buffer, its multicast address).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
view(index=None)
¶
(the [index] sub-buffer, its multicast address).
build(model, tp_group)
¶
The drafter's collectives over the TP group (capability fallback: None when the platform has no multicast symmetric memory, or at TP 1).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
clean(word)
¶
word unless it is the sentinel pair (+0, -0), then (+0, +0).
gather_ctas(rows, frags_per_row)
¶
CTAs per gathered row: about one fragment per thread, at most ~1.5 waves of 256-thread CTAs in all (every CTA of the grid must be resident or done).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/drafter/comm.py
store_peer_float(pointer, value, peer)
¶
DSMEM store of an FP32 value into cluster CTA peer's pointer.