vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.moe.tail
¶
Clustered MoE tail (TP8 B1..4, TP16 B1..8): routed finalization/publication, all-reduce, RMS tree, K-split up projection, shared reduce-scatter and output multicast. TMA weight loads overlap the mailbox wait. The caller owns the three rotating mailboxes and must use different parities on successive calls. TP8 B5+ and TP16 B9+ run the one-wave WaveMoeTail over latent rows published by the routed experts and shards pushed by WaveMoeTail.push.
Classes:
-
MoeTail–One MoE tail launch over caller-owned persistent buffers.
front_pollinputs -
WaveMoeTail–One-wave tail over published inputs (TP8 B5+, TP16 B9+): seven 16-CTA clusters
Functions:
-
gather_sums–Every lane's copy of
scatter_sums' firstcounttotals. -
pow2_spans–(start, count) spans of n columns, power-of-two counts, largest first.
-
scatter_sums–warp_sum(values[g], width)of every g (4 or 8 values) as a reduce-scatter:
MoeTail
¶
One MoE tail launch over caller-owned persistent buffers. front_poll inputs
have three parity slots armed with 0xffff BF16; latent/shared mailboxes [3, TP,
capacity, 3584 or 7168/TP] are armed with 0x80000000. Only complete chains may use
the early B1 trigger, which waits for the predecessor before releasing
successors.
Methods:
-
rearm–Re-arms
parity's firstbatchtokens (and WaveMoeTail's reduced
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
95 96 97 98 99 100 101 102 103 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 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 | |
rearm(io, capacity, parity, batch, block, tid, reduced=None)
¶
Re-arms parity's first batch tokens (and WaveMoeTail's reduced
rows).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
WaveMoeTail
¶
Bases: MoeTail
One-wave tail over published inputs (TP8 B5+, TP16 B9+): seven 16-CTA clusters
split K into 224-column slices of a 128-row (TP16: 64-row) tile. Weight fragments
stay in registers through the latent poll, RMS all-gather and normalization; row
warps (TP16: two sets taking alternate groups) run two seven-step BF16 MMA chains
per 8-token group, and each 64-row output line has one owner CTA and one multicast
writer. Past one group (and at TP16) each cluster instead all-reduces every seventh
token of its slices once and shares them as BF16 rows through reduced, so all
112 CTAs must be co-resident; RS lines spread over warp pairs, every group's RMS
sums travel as one vector per peer, all groups normalize before any MMA, the
groups' MMA chains interleave per K step, and the previous layer's rows are
re-armed after the output multicast. twoshot (B9+): the latent
mailbox is this rank's common.twoshot receive slots [3, TP, capacity, 3584/TP]
(pushed by the experts), the CTAs of its owned slices reduce them like TP16 but
multicast the rows into every rank's reduced (the gather; its multicast
address replaces the latent one), so each GPU receives 2 x B x 7 KB of latent
instead of TP x B x 7 KB.
Methods:
-
column_sums–sum_sources(same order and rounding) as one BF16 FMA by 1.0 per term. -
exchange_squares–Past one group: every group's warp sum for the warp's token; lane p < 16
-
group_smem–Group g's x (BF16 pointer) and MMA partials.
-
latent_words–BF16 latent words of a lane's eight columns; returns their square sum.
-
line_smem–Owned line s's partials [16 slices, 64] and RS rows.
-
load_sources–Issue the TP source loads of a lane's 16-byte column without waiting.
-
mma_group–Group g's MMA chains; each 4-row partial goes to its 64-row line's owner.
-
mma_groups–mma_groupover this warp's groups g = sets j + set (TP16: two warp -
normalize–One group: RMS-normalize the warp's token into
xs. -
normalize_groups–Past one group: every group's RMS (the 16 slices' sums,
square_total's -
poll_inputs–Phase 1 and the RS lines in one convergent pass (every round's loads issued
-
poll_rows–Lamport-poll the first
count16-byte rows base + r stride. -
push–WaveMoeTail's shared inputs: peer-store this rank's shared-expert rows [B,
-
push_squares–One group: the warp's token's 28 lane sums of every slice to every peer.
-
read_reduced–Phase 2: the lane's words of tokens 8 g + warp and their squares.
-
rearm_rows–Division-free
rearm: each source's latent and RS rows, then the reduced -
scale_words–(x * inverse) * gamma per column, as packed FP32x2 multiplies.
-
settle–Re-poll loaded sources until no word is the 0x80000000 sentinel.
-
umma_partials–D [M, N] = W x^T on tcgen05 (warp 0 issues 4 K tiles), staged [token, row]
-
write_line–Owned line s: sum the 16 slices' partials, add the RS rows and multicast the
-
x_chunk–16-byte chunk
chunk(K columns 8 chunk ..) of rowrowin 128B-
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
column_sums(values)
¶
sum_sources (same order and rounding) as one BF16 FMA by 1.0 per term.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
exchange_squares(squares, s2, bar, ids)
¶
Past one group: every group's warp sum for the warp's token; lane p < 16 pushes them to peer p's (warp, slice) row as v4 words.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
group_smem(sm, g)
¶
Group g's x (BF16 pointer) and MMA partials.
latent_words(sums, words)
¶
BF16 latent words of a lane's eight columns; returns their square sum.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
line_smem(sm, s)
¶
Owned line s's partials [16 slices, 64] and RS rows.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
load_sources(values, ptr, stride)
¶
Issue the TP source loads of a lane's 16-byte column without waiting.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
mma_group(a, group, owned, bar, g, ids)
¶
Group g's MMA chains; each 4-row partial goes to its 64-row line's owner.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
mma_groups(a, xs, products, owned, bar, ids)
¶
mma_group over this warp's groups g = sets j + set (TP16: two warp
sets): every MMA chain (the groups' chains interleaved per K step), one warp
sync, then the owners' pushes (slot j).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
normalize(squares, row, xs, ids)
¶
One group: RMS-normalize the warp's token into xs.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
normalize_groups(squares, row, xs, ids)
¶
Past one group: every group's RMS (the 16 slices' sums, square_total's
order) first, then the scaled latent words (padding tokens too).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
poll_inputs(boxes, ring, ids, places, gather=None)
¶
Phase 1 and the RS lines in one convergent pass (every round's loads issued
first). Lanes 0..27 all-reduce the cluster's tokens tile + 7 j of the CTA's
slice once into BF16 reduced rows (gather (multicast address, rank):
only the CTAs of owned slices, from the receive slots into every rank's);
lanes 28..31 of warps 2 p and 2 p + 1 sum owned lines p, p + 4's RS shard
(line 16 i + q: token (16 i + q) / lines).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
poll_rows(base, stride, count)
¶
Lamport-poll the first count 16-byte rows base + r stride.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
push(*args)
¶
WaveMoeTail's shared inputs: peer-store this rank's shared-expert rows [B, 7168] into the RS mailboxes (-0 made +0); an ordinary launch after the down GEMM.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
push_squares(squares, s2, bar, ids)
¶
One group: the warp's token's 28 lane sums of every slice to every peer.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
read_reduced(reduced, slot, xwords, s2, ids)
¶
Phase 2: the lane's words of tokens 8 g + warp and their squares.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
rearm_rows(boxes, capacity, parity, batch, block, tid, reduced)
¶
Division-free rearm: each source's latent and RS rows, then the reduced
rows, of the previous layer (complete before this launch).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
scale_words(words, gx, inverse, xs, warp, lane)
¶
(x * inverse) * gamma per column, as packed FP32x2 multiplies.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
settle(values, ptr, stride)
¶
Re-poll loaded sources until no word is the 0x80000000 sentinel.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
umma_partials(sm, tmem, bar, ids)
¶
D [M, N] = W x^T on tcgen05 (warp 0 issues 4 K tiles), staged [token, row] in the W tiles, then the 4-row partials pushed to their lines' owners.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
write_line(line, bar, output_mc, ids, s)
¶
Owned line s: sum the 16 slices' partials, add the RS rows and multicast the 64 output rows.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
x_chunk(tile, row, chunk)
¶
16-byte chunk chunk (K columns 8 chunk ..) of row row in 128B-
swizzled [rows, 64] K tiles of self.n rows (tile: the 8-row block).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
gather_sums(total, count, width, padded)
¶
Every lane's copy of scatter_sums' first count totals.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
pow2_spans(n)
¶
(start, count) spans of n columns, power-of-two counts, largest first.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/tail.py
scatter_sums(values, lane, width)
¶
warp_sum(values[g], width) of every g (4 or 8 values) as a reduce-scatter:
each butterfly level keeps half of the values and receives the partner's other
half, so every partial sum (and the total) is the butterfly's. Returns the lane's
total; value g's sits in lanes g << (log2(width) - log2(len(values))).