vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.dsa.indexer
¶
Fused decode indexer of a K3.1 DSA layer. TP (every rank scores the whole context): the FP8 indexer query and head weights of the step's rows over the paged FP8 indexer cache -> the exact top-k of every row as the physical KV rows the sparse attention reads, compacted to a prefix, and their counts. Two PDL-chained kernels replace the stock chain (DeepGEMM logits, FP32 upcast, top-k, then the logical -> physical conversion on a side stream):
IndexerScore key-balanced persistent tcgen05 scorer: the 128-key tiles of
all requests are cut into equal ranges, one per SM, and one
[128 keys x q * 32] FP8 MMA per tile scores every verify row of
the request, so each key page is read once per step. The
epilogue rounds each head's relu(q . k) to BF16, sums the heads
with the BF16 head weights by BF16 FMAs (stock DeepGEMM
precision, see below), scales by the key's UE8M0 scale, and
stores the BF16 logits into a request-compact
scratch, and each 8 keys' largest (order-preserving 16-bit) key
into a scratch 1/8 its size. Requests whose rows all fit the
top-k are not scored.
IndexerSelect one CTA per row: the K-th largest of the row's 8-key maxima
bounds its K-th largest key from below, so only the keys of the
about K vectors at or above it are candidates; an exact radix
select over them (11-bit bins, then the low 5 bits) and one
ordered pass write the selected keys' physical rows in key
order. Ties at the threshold go to the lowest key indices, so
the result is deterministic. A row of at most topk keys
takes all of them without reading logits (the short-context
bypass).
Under DCP the scorer writes this rank's shard in DeepGEMM's logits layout and (FusedIndexer.packs) the select writes the #63 merge's B' rows (run_dcp).
logits[t, k] = scale[k] * sum_h bf16(relu(q[t, h] . key[k])) * w[t, h] at stock's precision (DeepGEMM SM100 paged MQA logits): each head's value rounded to BF16 and accumulated by BF16 FMAs (two BF16x2 sums, then a BF16 add), on the FP8 query with unit MX scales and the BF16 head weights that fold its scale (DsaIndex).
Classes:
-
FusedIndexer–The fused decode indexer of one DSA layer, compiled per (rows, q) for the
-
IndexerLocalTopk–DCP: the local top-
nkeys of every row (one CTA per row) of the -
IndexerScore–BF16 logits of
rowsrows (qper request) into the request-compact -
IndexerSelect–The exact top-
topkof every row (one CTA per row) ->out[rows,
Functions:
-
add_bf16x2–Return a + b on BF16x2 (__hadd2_rn).
-
bf16_bits–FP32 -> BF16 bits, round to nearest even; -0 stored as +0.
-
block_exclusive–(exclusive prefix over the CTA's threads in order, total);
scan: -
compile_indexer–The score and select kernels of one (rows, q) for an indexer cache layout
-
dummy_peers–The local select's placeholder exchange addresses (no exchange).
-
fine_bin_of–A candidate's 11-bit bin above the bound's
b0; the keys FINE - 1 or -
fma_bf16x2–Return a * b + c on BF16x2, one rounding per lane (__hfma2).
-
fp4_instruction–MXF4 instruction descriptor: E2M1 A and B (K-major), FP32 D, UE8M0 scales,
-
half–BF16 element
eof eight packed in four words. -
load_16b–16 bytes (four words) of the scratch the scorer wrote.
-
logits_scratch–One scratch per device shared by every layer (every layer prepares before
-
low_digit–Warp-wide over 32 bins (lane b holds bin b's
count): the bin where the -
mma_mxf4–One block-scaled MXF4 tcgen05 MMA (K 64, UE8M0 per 32, DeepGEMM's FP4 MQA
-
order16–Order-preserving 16-bit key of BF16
bits(a larger value, a larger -
relu_bf16x2–BF16x2 (
loin the low half) of relu(x), round to nearest even (DeepGEMM's -
request_tiles–128-key tiles of request
r; 0 when all its rows fit the top-k (its -
reserve–The fused indexer's buffers of
max_rowsrows, shared by every layer: -
scale_desc–tcgen05.cp source: 32 rows of 16 B, unswizzled (8-row groups 128 B apart).
-
select_outputs–The physical rows (DCP: B' rows) and counts, shared by every layer (each
-
static_unsupported–Why the fused indexer cannot run this layer's (rows, q), from what is known
-
stride_pages–The element offset of page
pageoftensor(mode 0), in 64 bits. -
supports–Why the fused indexer cannot run this layer (None: it can).
-
sw64_desc–K-major 64B-swizzled operand descriptor (8-row groups 512 B apart).
-
table_entry–table: (address, row stride, width) of an int32 block table. -
topdown–info[slot] = the bin where the counts summed from the top bin down reach
-
transpose_scales–In place, the 128 UE8M0 x4 words of rows 0..127 at
chunk(Int32 smem -
vector_keys–The order-preserving keys of a vector's eight BF16 logits (two per word);
-
warp_topdown–One warp over the BINS-bin
hist: (the bin where the counts summed from -
warp_totals–(sum of
scanover the warps beforewarp, sum over all): every
FusedIndexer
¶
The fused decode indexer of one DSA layer, compiled per (rows, q) for the
layer's indexer cache. TP: run -> (physical rows [B, topk] of the MLA
cache, valid counts [B]). DCP (local_topk N > 0, the top-k merge's
candidates per rank): run_dcp scores this rank's keys into DeepGEMM's
logits layout and, packed, selects each row's local top-N as the merge's
B' rows. With an exchange (topk_exchange.TopkExchange) and the #63
merge's rescue workspace, run_exchange instead pushes the B' rows to
every rank over NVLink and merges them (ExchangeMerge) at the rows
exchanges (page: the MLA cache's tokens per block).
Methods:
-
compile_exchange–(the push-variant local select, ExchangeMerge) of (rows, q).
-
exchange_args–The local select's exchange arguments (placeholders without one).
-
exchanges–DCP: whether
run_exchangeservesrowsrows (the exchange and -
packs–DCP: whether
run_dcpselects the B' rows itself: one CTA per row -
run–TP.
index_decode: the indexer's decode metadata (per-row ends and -
run_dcp–DCP -> (this rank's local top-N of every row as B' rows [rows, N + N /
-
run_exchange–DCP over the exchange (
exchanges(rows)): score this rank's keys, -
score–The scorer over the step's rows -> the per-row ends (cute).
-
write_ids–Also write the selected key indices (the logical top-k, -1 past the
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 | |
_table(t)
staticmethod
¶
(address, row pitch, width) of an int32 block table view.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
compile_exchange(rows, q, emit_ids=False)
¶
(the push-variant local select, ExchangeMerge) of (rows, q).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
exchange_args()
¶
The local select's exchange arguments (placeholders without one).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
exchanges(rows)
¶
DCP: whether run_exchange serves rows rows (the exchange and
rescue workspace hold them; the same on every rank). Also past the SM
count: there the local select's rows share SMs (~1.7x slower than one
row per SM), but the exchange still drops the NCCL all-gather, #63's
DeepSelect + pack, select and rescue kernels (GB300 HIGH hybrid decode,
310 rows at DCP8: the all-gather alone is 30-34 us per DSA layer).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
packs(rows)
¶
DCP: whether run_dcp selects the B' rows itself: one CTA per row
on its own SM (past the SM count, rows sharing an SM select about 1.7x
slower, behind DeepSelect + #63's pack; measured on GB300 at 160-320
rows).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
run(q_fp8, head_w, index_decode, block_table, block_rows, rows, q)
¶
TP. index_decode: the indexer's decode metadata (per-row ends and
index block table); block_table / block_rows: the MLA cache's.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
run_dcp(q_fp8, head_w, index_decode, rows, q)
¶
DCP -> (this rank's local top-N of every row as B' rows [rows, N + N /
32] when packs(rows), else None; the BF16 logits [rows, pitch] in
DeepGEMM's layout; the row ends [rows]). The B' rows' counts land in
valid. The exact merge takes the logits with the B' rows (a saturated
rank re-reads its row), so nothing here writes them until the next call.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
run_exchange(q_fp8, head_w, index_decode, rows, q, merge, ids=None)
¶
DCP over the exchange (exchanges(rows)): score this rank's keys,
push the local top-N B' rows to every rank, and merge every rank's
into this rank's KV rows. merge: ExchangeMerge's (req_id,
block_table, stride_rows, rows_out, valid_out, max_local_len) of the
rows rows; ids: also the global ids [rows, K] (tests).
Collective over the DCP group (every rank the same rows).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
score(q_fp8, head_w, index_decode, rows, q)
¶
The scorer over the step's rows -> the per-row ends (cute).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
write_ids(ids)
¶
Also write the selected key indices (the logical top-k, -1 past the
count) into ids [>= rows, topk] (tests; TP only).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
IndexerLocalTopk
¶
DCP: the local top-n keys of every row (one CTA per row) of the
DeepGEMM-layout logits (IndexerScore with pitch) as the DCP top-k
merge's B' rows (dcp_topk_merge): out [rows, n + n / 32] int32,
word j < n (ord16 << 16) | (0xFFFF - (l & 0xFFFF)) of a selected key l
(0: empty), bit j % 32 of word n + j // 32 bit 16 of l; valid: the
counts. The selected keys are in key order: those above the threshold, then
the ties at it (the lowest key indices). A row of at most n keys takes
all of them.
A row holds 1 / DCP of a context (a few thousand keys), so the select is
bound by its chain of dependent steps: each thread owns a contiguous run of
the row's 8-key vectors (the first LOCAL_CACHED kept in registers) and
every histogram is scanned by one warp.
0 each thread's largest key; the n-th largest of those bounds the n-th
largest key from below (n threads hold a key at least as large), so
only the keys at or above the bound's 11-bit bin are candidates (all
keys when under n threads hold keys);
1 the candidates, block-scanned into a shared list in key order (a few
n at most; past LOCAL_CANDIDATES the passes below read every key
instead, e.g. rows of many equal logits);
2 their 11-bit histogram -> the threshold's bin;
3 the low 5 bits of the candidates in it -> the threshold, the ties;
4 each thread's count of candidates above it and ties at it, block-
scanned -> their slots.
Methods:
-
__call__–peers[W] int64 /epoch[>= rows] /xrank/xrows: the -
candidate–One candidate (key >= the bound) in pass
step(2: histogram, 3: -
keys_pass–Pass
stepover this thread's keys >=low(1: count them; else -
list_pass–Pass
stepover this thread's share of the candidate list, or over -
push–The row's B' words (written by this CTA) -> every rank's exchange
-
word–Key
index(16-bitkey) into B' slotslot.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 | |
__call__(logits, row_ends, out, valid, peers, epoch, xrank, xrows, s)
¶
peers [W] int64 / epoch [>= rows] / xrank / xrows: the
TopkExchange's slot addresses, epochs, this rank and its rows (unused
without exchange).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
candidate(step, key, index, state, smem, args)
¶
One candidate (key >= the bound) in pass step (2: histogram, 3:
low histogram, 4: count, 5: write); state: (the threshold's bin, the
threshold, the ties to take, the next slot above, the next tie rank).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
keys_pass(step, vec, cached, low, state, smem, args)
¶
Pass step over this thread's keys >= low (1: count them; else
candidate's) -> (the count, the state).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
list_pass(step, ranges, vec, cached, low, state, smem, args, cand_key, cand_index)
¶
Pass step over this thread's share of the candidate list, or over
its keys >= low when the list overflowed -> (pass 4's count, the
state).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
push(out, row, tid, peers, epoch, xrank, xrows)
¶
The row's B' words (written by this CTA) -> every rank's exchange slot [epoch parity, rank, row] as LL pairs (topk_exchange.ll_push).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
word(out, row, plane, slot, index, key)
¶
Key index (16-bit key) into B' slot slot.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
IndexerScore
¶
BF16 logits of rows rows (q per request) into the request-compact
scratch: request r's rows are consecutive tiles(r) * 128-key rows starting
at element q * 128 * (tiles of the requests before r).
pitch > 0 (DCP): DeepGEMM's paged MQA logits layout instead, row t at
element t * pitch (key index = column; pitch a multiple of 512, so
1 KiB rows), no vector maxima, and every request is scored (topk 0: a
rank's share of the global top-k is unknown before the merge).
Methods:
-
__call__–FP4:
queryis E2M1 bytes [64, 32, rows] (row stride 4 KiB),keys -
mma_fp4–The MMA warp (MXFP4): per item, the query's scale words into TMEM; per
-
row_weights–Rows [lo, hi)'s BF16 head weights of Q stage
qs(16 BF16x2 words a -
rows_out–Verify rows [lo, hi) of one tile: relu, the head weights and the key
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
425 426 427 428 429 430 431 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 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | |
__call__(query, weights, keys, scales, table_address, table_pitch, table_width, row_ends, logits, tops, q_scales, s)
¶
FP4: query is E2M1 bytes [64, 32, rows] (row stride 4 KiB), keys
E2M1 bytes [64, 64, blocks] and scales the keys' UE8M0 x4 words.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
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 | |
mma_fp4(sA, sB, sSc, sQsc, tmem_ptr, bars, cursor, sStart, requests)
¶
The MMA warp (MXFP4): per item, the query's scale words into TMEM; per tile, the keys' scale words into TMEM (tcgen05.cp after an in-place smem transpose), then two K64 MXF4 MMAs into the tile's accumulator. The copies and MMAs are issued by one lane, in order.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
row_weights(sW, qs, lo, hi)
¶
Rows [lo, hi)'s BF16 head weights of Q stage qs (16 BF16x2 words a
row; nothing for an empty range).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
rows_out(lo, hi, t2r, tAll, cD, sW, sEnd, rows, bases)
¶
Verify rows [lo, hi) of one tile: relu, the head weights and the key
scale -> BF16 logits, and each 8 keys' largest (the select's bound). The
rows' accumulators are read from TMEM and packed to relu'd BF16 pairs
first (16 registers a row), then the accumulator is released
(release: its empty barrier) so the next MMA overlaps the head sums.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
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 | |
IndexerSelect
¶
The exact top-topk of every row (one CTA per row) -> out [rows,
topk]: the physical KV rows (block_rows rows per page-token block of
the MLA cache, a power of two: 64, or e.g. 2048 in hybrid models whose
attention pages match the mamba state's) of the selected keys in key order,
-1 past the row's count, and valid [rows]: the counts. ids
(logical): the key indices too.
The K-th largest of the scorer's per-8 vector maxima bounds the K-th largest key from below (each of those vectors holds a key at least as large), so only the keys at or above it, about K of them, are candidates: pass 1 histograms the maxima (a row of fewer than K vectors: its keys), pass 2 gathers the candidates in key order, and a radix select over them (11-bit bin, then the low 5 bits) finds the threshold. Rows whose candidates overflow the shared list take the exact select over every key.
Methods:
-
exact–The exact select over every key of the row (11-bit, then 5-bit
-
publish–Into
pub: the low-digit histogram and the count above its bin. -
resolve–From
pubandabove_high(keys above the threshold's bin): -
vector_top–Vector
v's largest key: pass 1 kept the first TOPS in shared -
write_selected–One warp round of the ordered output:
n(0/1) per lane of key
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 | |
exact(sm, address, length, emit_args, tid, warp, lane)
¶
The exact select over every key of the row (11-bit, then 5-bit histograms): the fallback of rows whose candidates overflow the list, e.g. rows of many equal logits.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 | |
publish(whist, wabove, pub, tid)
¶
Into pub: the low-digit histogram and the count above its bin.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
resolve(pub, info, whist, wabove, wpre, above_high, warp, lane)
¶
From pub and above_high (keys above the threshold's bin):
info[4] = the threshold's low digit, info[5] = the ties at the threshold
to take, and wpre = each warp's count of keys above the threshold and of
ties before it (in key order).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
vector_top(tops_s, tops_address, v)
¶
Vector v's largest key: pass 1 kept the first TOPS in shared
memory.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
write_selected(keys, indices, n, threshold, take, carry_a, carry_t, lane, emit_args)
¶
One warp round of the ordered output: n (0/1) per lane of key
keys at indices; returns the carries.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
_first_request(start, requests, g)
¶
The request whose tiles contain global tile g (binary search).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
_mn_layout(t)
¶
A tcgen05 accumulator as ((M), (N), stages).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
_next_item(start, requests, g, r, hi)
¶
The work item at global tile g of request r (the CTA range ends at
hi): (request, first key, tiles, next g, next r).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
add_bf16x2(a, b)
¶
bf16_bits(x)
¶
FP32 -> BF16 bits, round to nearest even; -0 stored as +0.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
block_exclusive(value, scan, warp, lane)
¶
(exclusive prefix over the CTA's threads in order, total); scan:
one word per warp.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
compile_indexer(rows, q, topk, ctas, keys, scales, logits, tops, device, ids, pitch=0, packed=False, release=True, page=PAGE, fp4=False, exchange=0)
cached
¶
The score and select kernels of one (rows, q) for an indexer cache layout
(every DSA layer's is the same). DCP (pitch): DeepGEMM-layout logits and,
packed, the local top-topk select into B' rows (else none), which
with exchange (W > 0) also pushes them to the W ranks (topk_exchange).
page: the MLA cache's tokens per block (TP select). fp4: MXFP4 keys
and query.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 | |
dummy_peers(device)
cached
¶
The local select's placeholder exchange addresses (no exchange).
fine_bin_of(key, b0)
¶
A candidate's 11-bit bin above the bound's b0; the keys FINE - 1 or
more bins above share the last.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
fma_bf16x2(a, b, c)
¶
Return a * b + c on BF16x2, one rounding per lane (__hfma2).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
fp4_instruction(n, k)
¶
MXF4 instruction descriptor: E2M1 A and B (K-major), FP32 D, UE8M0 scales,
M 128, N n; K step k of two reads scale bytes 2k, 2k + 1.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
half(words, e)
¶
load_16b(address)
¶
16 bytes (four words) of the scratch the scorer wrote.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
logits_scratch(device, elements, name='logits')
¶
One scratch per device shared by every layer (every layer prepares before any graph capture, so the last, largest allocation serves them all).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
low_digit(count, need, lane)
¶
Warp-wide over 32 bins (lane b holds bin b's count): the bin where the
counts summed from bin 31 down reach need, and the count above it.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
mma_mxf4(d, a, b, instruction, sfa, sfb, accumulate)
¶
One block-scaled MXF4 tcgen05 MMA (K 64, UE8M0 per 32, DeepGEMM's FP4 MQA
logits instruction); accumulate is a runtime flag.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
order16(bits)
¶
Order-preserving 16-bit key of BF16 bits (a larger value, a larger
key).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
relu_bf16x2(lo, hi)
¶
BF16x2 (lo in the low half) of relu(x), round to nearest even (DeepGEMM's
cvt_relu_bf16x2_f32).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
request_tiles(row_ends, r, q, topk)
¶
128-key tiles of request r; 0 when all its rows fit the top-k (its
last row sees the most keys).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
reserve(indexer, device, max_rows, local_topk=0, blocks=None)
¶
The fused indexer's buffers of max_rows rows, shared by every layer:
(logits, tops, rows, counts, ends, pitch). local_topk > 0: DCP (the
merge's candidates per rank). blocks: the indexer cache's (None: no KV
cache yet, so the longest context bounds the TP logits). PreparedDsa reserves
them when the specialized decode is built, before vLLM profiles its memory for
the KV cache; FusedIndexer (prepare_cache, after the KV cache is allocated)
then takes the same buffers and allocates nothing.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
scale_desc(address)
¶
tcgen05.cp source: 32 rows of 16 B, unswizzled (8-row groups 128 B apart).
select_outputs(device, rows, topk, fill=-1)
cached
¶
The physical rows (DCP: B' rows) and counts, shared by every layer (each layer's consumer reads them before the next layer's indexer runs), and the per-row ends of steps with fewer requests than rows.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
static_unsupported(indexer, rows, q)
¶
Why the fused indexer cannot run this layer's (rows, q), from what is known before the KV cache exists (None: it can, if its cache layout does).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
stride_pages(page, tensor)
¶
The element offset of page page of tensor (mode 0), in 64 bits.
supports(indexer, rows, q)
¶
Why the fused indexer cannot run this layer (None: it can).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
sw64_desc(address)
¶
K-major 64B-swizzled operand descriptor (8-row groups 512 B apart).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
table_entry(table, r, column)
¶
table: (address, row stride, width) of an int32 block table.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
topdown(counts, bins, need, info, slot, scan, tid, warp, lane)
¶
info[slot] = the bin where the counts summed from the top bin down reach
need, info[slot + 1] = the count above it (unchanged when they never
do).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
transpose_scales(words, chunk, lane)
¶
In place, the 128 UE8M0 x4 words of rows 0..127 at chunk (Int32 smem
tensor offset) into tcgen05.cp's 32x128b layout: lane l's 16 bytes are rows l,
32 + l, 64 + l, 96 + l (TMEM columns 0..3 of lane l: rows c * 32 + l).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
vector_keys(words, v, length)
¶
The order-preserving keys of a vector's eight BF16 logits (two per word);
keys at or past length are 0.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
warp_topdown(hist, need, lane)
¶
One warp over the BINS-bin hist: (the bin where the counts summed from
the top bin down reach need, the count above it); (0, 0) when they never
do. Lane l first sums the 64 bins [BINS - 64 (l + 1), BINS - 64 l), then the
warp splits the hit chunk two bins per lane.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/indexer.py
warp_totals(scan, warp, lane)
¶
(sum of scan over the warps before warp, sum over all): every
warp scans the per-warp words itself.