vllm.models.deepseek_v41.nvidia.ops.cute_dsl.all_gather
¶
A TP all-gather over NVLink multicast with a Lamport mailbox, for the specialized decode.
The specialized decode gathers small tensors across the TP group on its critical path: each dense indexer layer of a row-sharded decode step gathers its top-k rows (and the candidate source its candidate blocks), and every step gathers the vocab-parallel logits. A few hundred kilobytes at most, so the latency of the collective, not its bandwidth, is what counts.
vLLM's custom all-gather has a Lamport kernel for NVLink multicast
(mnnvl_lamport_all_gather), but it never waits for the rank's own
multicast copy: it takes its own slot from registers, and a copy that lands
after the next call has cleaned its stage stays there. A later gather of
another size lays the slots out differently and can read that word as a
peer's payload. A stress test of back-to-back gathers of alternating sizes in
CUDA graphs hits this hundreds of times in a few million gathers. This module
is a gather of the same shape that cannot leave a word behind.
The mailbox is symmetric memory with a multicast mapping, laid out as 16-byte packs::
mailbox[generation][rank][pack] 3 generations x TP ranks x capacity
A call runs one kernel, one thread a 16-byte pack of the rank's input:
- Publish: the thread stores its pack through the multicast address into
every rank's
mailbox[g][rank][pack]. A word equal to the Lamport sentinel (0x80000000: FP32 negative zero, INT32_MIN) goes out as 0. - Collect: it polls
mailbox[g][r][pack]of every rankr, its own included, until no word of it is the sentinel; writes each rank's pack to the output, rank-major as NCCL lays out a dim-0 gather; and stores the sentinel back into the slots it read. Every slot a call writes is read after it has landed and reset by the same call, so no call leaves a word for a later one, whatever the sizes. - Generation:
state[0]is the call's generation. Each CTA reads it once and counts itself instate[1]; the last CTA to arrive advances the generation and clears the count. A rank can be at most one call ahead of a peer (finishing a call needs every rank's payload), so a rank writing the next generation never touches the slots a slower peer still reads; three generations, as vLLM's and FlashInfer's Lamport kernels use, leave one more in between.
The kernel triggers its PDL dependents once it has published. The output holds the sanitized words on every rank, its own slot included, so all ranks see the same bits. The caller must issue calls in the same order on every rank and on one stream: calls on one instance must not overlap.
Classes:
-
LamportAllGather–TP all-gather along dim 0 over NVLink multicast, for inputs of up to
LamportAllGather
¶
TP all-gather along dim 0 over NVLink multicast, for inputs of up to
rank_capacity_bytes a rank (a multiple of 16 bytes).
Construction is collective over the TP group: every rank compiles the
kernel and allocates its mailbox, and it raises when NVLink multicast is
unavailable. accepts tells whether a tensor fits, from its size
alone, so every rank decides alike.
Methods:
-
__call__–Every rank's
inpconcatenated along dim 0 in rank order, on the -
accepts–Whether
inpfits: 1 torank_capacity_bytesbytes, a
Source code in vllm/models/deepseek_v41/nvidia/ops/cute_dsl/all_gather.py
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 | |
__call__(inp)
¶
Every rank's inp concatenated along dim 0 in rank order, on the
current stream. Words equal to 0x80000000 arrive as 0, on every
rank (FP32 negative zero becomes positive zero).
Source code in vllm/models/deepseek_v41/nvidia/ops/cute_dsl/all_gather.py
accepts(inp)
¶
Whether inp fits: 1 to rank_capacity_bytes bytes, a
multiple of 16.
_AllGatherKernel
¶
One thread a 16-byte pack of the rank's input, THREADS a CTA.
Methods:
-
__call__–Launch on
stream; addresses are byte addresses,packsthe
Source code in vllm/models/deepseek_v41/nvidia/ops/cute_dsl/all_gather.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
__call__(inp, out, mailbox, multicast, state, packs, stream)
¶
Launch on stream; addresses are byte addresses, packs the
rank's input size in 16-byte packs.
Source code in vllm/models/deepseek_v41/nvidia/ops/cute_dsl/all_gather.py
_arrive(address, *, loc=None, ip=None)
¶
Add 1 to the arrival count (acquire-release, GPU scope); returns the count before.
Source code in vllm/models/deepseek_v41/nvidia/ops/cute_dsl/all_gather.py
_load_u32x4(address, volatile, *, loc=None, ip=None)
¶
One 16-byte pack as four words; volatile for the Lamport polls.
Source code in vllm/models/deepseek_v41/nvidia/ops/cute_dsl/all_gather.py
_store_u32x4(address, w0, w1, w2, w3, multicast, *, loc=None, ip=None)
¶
One 16-byte pack, through a multicast address (multimem.st, which
moves the bits unchanged) or to a local one.