vllm.models.deepseek_v41.nvidia.specialized_decode.boundary.publishing_gemm
¶
DSV4.1 attention output projection that publishes into the mHC all-reduce.
At a low-batch attention boundary the output projection wo_b (FlashInfer's
cutedsl_low_latency MXFP8 GEMM) writes this rank's partial sum, then the
publish kernel of BoundaryAllReduce reads it back and multicasts it into the
Lamport mailbox before the consumer can collect the peers' contributions.
:class:PublishingMxfp8Linear runs the same GEMM, with the tactic FlashInfer's
autotuner selected for the plain call, but its epilogue also does the publish
kernel's work: every output value goes, rounded to BF16 with negative zero
cleared, into this rank's slot of the mailbox generation stage_state[0] on
all ranks (multimem.st), and one thread sets stage_state[1] to that
generation. The caller then calls the same BoundaryAllReduce instance with
the returned tensor, which launches only the consumer
(BoundaryAllReduce.mark_published). The consumer is unchanged, so its
outputs are bit-identical to the unfused path's.
GEMM structure. The kernel computes C[n, m] = sum_k W[n, k] x[m, k] with the
weight as operand A (128 output columns per CTA, N / 128 CTAs) and the at
most 8 activation rows as operand B. With split-K S (the tactic's last
field), the S CTAs of a cluster each multiply a K slice, exchange FP32
partials through distributed shared memory and each reduce 1 / S of the
register elements. The epilogue's TMEM load is 16x256b for this BF16 output
(32x32b is also handled): for one register element, the eight consecutive
output columns of one row sit in eight lanes four apart, all owned by the same
CTA. Warp shuffles pack them into one 16-byte multicast store issued by the lane
whose column is a multiple of 8, so every store is aligned like the
consumer's 16-byte mailbox fragments.
Ordering. The epilogue reads stage_state[0] after its MMA completed, hence
after the GEMM's programmatic grid wait (the B loads follow it), exactly as the
publish kernel reads it after its own grid wait; the previous consumer wrote it.
The consumer, launched as the GEMM's programmatic dependent, reads
stage_state[1] only after its grid wait, that is, after the whole GEMM grid
and its stores completed.
Addresses. The mailbox multicast address, the stage-state address, the rank,
the TP size, the mailbox capacity and the hidden size are compile-time
constants of each compiled kernel: each publisher serves one
BoundaryAllReduce, whose buffers live as long as it does. Kernels compile
per tactic, before CUDA graph capture (:meth:PublishingMxfp8Linear.precompile).
Classes:
-
PublishingLowLatencyBlockscaledGemmKernel–FlashInfer's low-latency block-scaled GEMM whose epilogue publishes C.
-
PublishingMxfp8Linear–Run a low-latency MXFP8 linear whose output a
BoundaryAllReduce
PublishingLowLatencyBlockscaledGemmKernel
¶
Bases: LowLatencyBlockscaledGemmKernel
FlashInfer's low-latency block-scaled GEMM whose epilogue publishes C.
Only epilog_warp differs from the base class (the publish is marked
there); the main loop, the split-K reduction and C are unchanged.
Methods:
-
epilog_warp–FlashInfer's epilogue (modified from FlashInfer 0.7.0.post1; see the
-
publish_value–Pack eight lanes' BF16 bits and multicast them from the lane that
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
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 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 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 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
epilog_warp(tma_epilog_full_bar, mma_epilog_full_bar, tmem_alloc_result_bar, tiled_mma, mC_mnl, mScale, mBias_mnl, tmem_base_smem_ptr, mailbox_mbar, dsmem_mailbox_ptr, epi_tid, mma_tile_coord_v, work_tile_info, split_rank, k_tile_count)
¶
FlashInfer's epilogue (modified from FlashInfer 0.7.0.post1; see the file header), plus the Lamport publish of C.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
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 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 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
publish_value(bits, column, token, in_bounds, stage, column_lanes)
¶
Pack eight lanes' BF16 bits and multicast them from the lane that holds the 8-aligned column.
Every lane of the warp calls this for the same register element. The
lanes holding columns c .. c + 7 of one token (c % 8 == 0) are
l, l + s, .., l + 7s for the TMEM load's lane stride s =
column_lanes; the store address comes from the storing lane's own
column, so it is 16-byte aligned whatever the layout.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
PublishingMxfp8Linear
¶
Run a low-latency MXFP8 linear whose output a BoundaryAllReduce
reduces next, publishing the output from the GEMM epilogue.
Call it in place of the linear; it falls back to the linear itself (and publishes nothing) for any input the low-latency backend does not take.
Methods:
-
__call__–linear(x), published intoall_reduce's mailbox whenxis -
precompile–Compile the kernel
num_tokensrows select, launching nothing: a -
supports–Whether
linearonnum_tokensrows runs the publishing GEMM.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
__call__(linear, x)
¶
linear(x), published into all_reduce's mailbox when x is
an MXFP8 activation of the low-latency backend's layout.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
_compile(tactic, device)
¶
The publishing kernel of tactic, compiled once per device.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
precompile(linear, num_tokens)
¶
Compile the kernel num_tokens rows select, launching nothing: a
publish without its consumer would desynchronize the mailbox.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
supports(linear, num_tokens)
¶
Whether linear on num_tokens rows runs the publishing GEMM.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/boundary/publishing_gemm.py
_selected_tactic(a, weight, a_scale, weight_scale, out)
¶
The tactic mm_mxfp8(backend="cutedsl_low_latency") runs for these
operands: the autotuner's cached choice, else the runner's default (the
first valid tactic), resolved as mm_mxfp8 resolves it.