vllm.models.deepseek_v41.nvidia.specialized_decode.attention.decode_topk_cute
¶
Decode top-k of the dense indexers straight from their BF16 logits, in CuTe DSL.
The problem. In a decode step each dense indexer layer scores every compressed
token of a row (SM100's paged MQA logits are BF16) and keeps the k largest:
the token top-512, and in the candidate source also the top-2048 of the rows'
8-token block maxima. cooperative_topk reads FP32, so the logits used to be
upcast first, and it builds a radix histogram of every value with shared-memory
atomics. Real indexer logits crowd a few histogram bins (a row of 150K logits
holds about 200 distinct BF16 values), where those atomics serialize.
What this module computes. DecodeTopK writes, for each row, the indices of
its k largest elements in any order (exact: every index whose value exceeds
the k-th largest, then enough of those equal to it), or 0 .. n-1 and -1
padding when the row has at most k elements. An element is one BF16 logit
(token mode), or the NaN-propagating maximum of an aligned group of 8 logits
(block mode, the candidate blocks), with the row's newest block pinned at +inf
and blocks scoring -inf written as -1. Values are compared through an
order-preserving 16-bit key of their BF16 bits, so ties are exact.
How. One thread block cluster of C CTAs per row: 8 CTAs of 512 threads
while every row's cluster can be resident at once, else 4 of 1024 (a second
wave of clusters would nearly double the time). Each CTA copies one
contiguous chunk of the row into shared memory, as 16-byte vectors (8 logits,
or one block); the chunks split the row's valid length, not its width. A
thread stages 8 vectors and keeps them in registers too, so a cluster holds
262,144 logits. Wider rows need more: at a 1M context the ratio-2 layers'
logits are 524,288 wide, and a second build stages 16 vectors a thread at 8
CTAs, the other 8 in shared memory only. The candidate source layer scores
every token (ratio 1), 1,048,576 at a 1M context, so a third build runs 16
CTAs a row (a non-portable cluster size, which CuTe DSL allows on every
kernel) with 16 vectors a thread. Rows of the wide builds run in waves when
they outnumber the resident clusters; the 16-CTA build takes at most two
waves (supports_decode_topk). Two ways to the answer:
-
Sampled (token rows longer than one vector a thread)::
sample the row ──► every CTA: the same cutoff (the q-th largest of the row's 2048 samples, q aiming at 3k survivors) └► keep keys > cutoff and up to k keys == cutoff, push both to CTA 0 └► CTA 0: exact k-th largest among <= 8192 survivors (two 8-bit radix passes), write k indices
-
Direct (block mode, short token rows, and a sample that misjudged the row: more than 8192 survivors, or fewer than k at or above the cutoff): the exact k-th largest key from two cluster-wide 8-bit radix histograms, then every CTA writes its own selected indices straight to the output.
Both filter the same way: a thread tests each of its vectors' maximum against the cutoff, the vectors that can hold selected keys go to a CTA queue, and the CTA's threads unpack the queued vectors evenly; a CTA scan gives each thread its output slots and one cluster atomic reserves the CTA's range, so no key costs an atomic. Whole-row histograms spread each warp's atomics over 8 copies (lane l counts into copy l mod 8), since a crowded bin serializes the atomics on its word; the radix selects over the few thousand samples or survivors count into one histogram, where the copies' zeroing and summing cost more than they save.
Synchronization. Cluster barriers separate the phases: every CTA has started and zeroed its counters before any distributed shared memory access; samples are complete before the cutoff; survivors are complete before CTA 0 reads them; histogram contributions are complete before they are read; and CTA 0 waits until every peer is done with its shared memory before it exits. The kernel waits on its predecessor grid before reading inputs and lets its dependents launch once its chunk is in shared memory (programmatic dependent launch).
Classes:
-
DecodeTopK–The decode top-k (module docstring) of rows of BF16 logits.
Functions:
-
block_key–The key of the NaN-propagating maximum of eight BF16 values.
-
cluster_add_u64–Atomic add to an 8-byte aligned cluster shared word pair; returns the
-
cluster_for–CTAs a row: 8 while every row's cluster is resident at once, else 4.
-
cluster_load–Load a cluster shared word.
-
cluster_red–Atomic add to a cluster shared word.
-
cluster_store_u16–Store the low half of a word to cluster shared memory.
-
cluster_store_u32–Store a 32-bit word to cluster shared memory.
-
decode_topk–Launch
DecodeTopKon the current stream. -
hist_add–Count each valid lane's
bin_with one shared atomic.copies: -
load_u32x4–Four 32-bit words at a 16-byte aligned global address.
-
max_nan_bf16x2–Lane-wise maximum of two BF16 pairs, NaN if either is NaN.
-
order_key–The order-preserving key of the BF16 value in the low half of
bits: -
peer_address–The cluster address of this CTA's shared
addressin CTArank. -
precompile–Compile the
DecodeTopKvariantsdecode_topklaunches on rows of -
select_bin–Warp 0: the bin
bof a 256-bin histogram holding theq-th -
shared_load_u32x4–Four 32-bit words at a 16-byte aligned shared address of this CTA.
-
shared_red–Atomic add to a shared word of this CTA.
-
shared_store_u32x4–Store four 32-bit words at a 16-byte aligned shared address of this CTA.
-
shfl_up–valueof the lanedeltabelow (own value in the lowest lanes). -
store_s32–Store a 32-bit word to global memory.
-
supports_decode_topk–Whether
decode_topktakes these BF16 logits (16-byte aligned rows -
threads_for–Threads a CTA: 1024 at 4 CTAs a row, else 512.
-
vector_choices–The 16-byte vectors a thread may stage: 8, or 16 at 512 threads (1024
-
vectors_for–The fewest staged vectors a thread whose cluster holds a row of
DecodeTopK
¶
The decode top-k (module docstring) of rows of BF16 logits.
k: 512, 1024 or 2048; cluster: 4, 8 or 16 CTAs a row (4: 1024
threads, else 512); vector_count: 16-byte vectors a thread stages (8,
or 16 at 8 or 16 CTAs: the first 8 also stay in registers), so a row
holds at most cluster * threads * vector_count vectors;
block_mode: elements are 8-logit block maxima.
Methods:
-
__call__–logits: BF16 rowsrow_bytesapart (16-byte aligned), each -
count_queued–This thread's keys above and equal to
cutoffin its share of -
count_vector–Count a staged vector (
words, its first elementfirst) into -
direct–Direct path: the exact cutoff, then every CTA writes its keys
-
emit–CTA 0, sampled path: write the row's k indices from the gathered
-
exact_cutoff–The row's exact k-th largest key and how many keys equal to it
-
gather–Sampled path: push this CTA's keys above
cutoffand up to k -
kernel–One cluster a row (module docstring).
-
queue_vectors–Queue this CTA's vectors that can hold a key >=
cutoff(by -
radix_select–The
q-th largest ofkeys[0:count](shared Uint16, q <= count) -
reserve–This thread's first slots for its
gt/eqkeys in the -
scan2–Exclusive CTA prefix sums of
aandbover the threads, and -
vector_top–The largest key of a staged vector whose first element is
-
vector_words–The four words of the chunk's vector
vectorin shared memory. -
word_key–The key of element
eof a vector'swords(element: its
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
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 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 1123 1124 1125 1126 1127 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 | |
__call__(logits_ptr, lengths_ptr, out_ptr, rows, row_bytes, width, out_stride, fallback, stream)
¶
logits: BF16 rows row_bytes apart (16-byte aligned), each
valid below lengths[r] (int32, clamped to [0, width]); out:
int32 rows out_stride apart. fallback nonzero forces the
direct path (tests).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
count_queued(data_address, queued, cutoff, start, length, pinned, tid, queue)
¶
This thread's keys above and equal to cutoff in its share of
the queued vectors (entries tid, tid + threads, ...).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
count_vector(level, words, first, start, length, pinned, high, hist_address, lane)
¶
Count a staged vector (words, its first element first) into
a whole-row histogram: level 0 the high bytes of its keys, level 1
the low bytes of those whose high byte is high.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
direct(regs, data_address, start, length, pinned, tid, out_row, ctl, hist, hist_a, hist_b, scan, queue)
¶
Direct path: the exact cutoff, then every CTA writes its keys
above it and its share of the need equal ones to the output.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
emit(total_gt, cutoff, out_row, tid, ctl, hist, hist2, scan, g_key, g_idx, g_eq)
¶
CTA 0, sampled path: write the row's k indices from the gathered survivors.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
exact_cutoff(regs, data_address, start, length, pinned, tid, ctl, hist, hist_a, hist_b)
¶
The row's exact k-th largest key and how many keys equal to it rank within the top k, from every CTA's vectors: two cluster-wide radix histograms gathered at CTA 0 (every CTA).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
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 | |
gather(regs, data_address, cutoff, start, length, pinned, tid, ctl, scan, queue, g_key, g_idx, g_eq)
¶
Sampled path: push this CTA's keys above cutoff and up to k
equal to it to CTA 0 and return the cluster's totals (every CTA).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
kernel(lengths, out, logits_address, row_bytes, width, out_stride, fallback)
¶
One cluster a row (module docstring).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
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 1123 1124 1125 1126 1127 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 | |
queue_vectors(regs, data_address, cutoff, start, length, pinned, tid, scan, queue)
¶
Queue this CTA's vectors that can hold a key >= cutoff (by
their maximum) and return how many (every thread).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
radix_select(keys, count, q, hist, hist2, ctl, tid)
¶
The q-th largest of keys[0:count] (shared Uint16, q <= count)
and how many of the keys equal to it rank within the top q. Every
thread calls it.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
reserve(gt, eq, totals, tid, ctl, scan)
¶
This thread's first slots for its gt / eq keys in the
cluster-wide lists counted at CTA 0's ctl[totals] pair: a CTA
scan, then one 64-bit cluster atomic for the CTA.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
scan2(a, b, scan, tid)
¶
Exclusive CTA prefix sums of a and b over the threads, and
their totals (every thread calls it; three barriers).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
vector_top(words, element, pinned)
¶
The largest key of a staged vector whose first element is
element (block mode: the pinned newest block ranks first).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
vector_words(data_address, vector)
¶
The four words of the chunk's vector vector in shared memory.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
word_key(words, e, element, pinned)
¶
The key of element e of a vector's words (element: its
row index, for the pinned block).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
_asm(result, operands, text, constraints, side_effects, loc, ip)
¶
One PTX inline assembly operation.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
_fake(dtype, align)
¶
A placeholder pointer for compilation.
_kernel(device_index, k, cluster, vector_count, block_mode)
cached
¶
DecodeTopK compiled for a device, k, cluster size, staged vectors
a thread and mode.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
_pointer(dtype, tensor, align)
¶
A CuTe DSL global-memory pointer to tensor's data.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
_resident_clusters(device_index, cluster)
cached
¶
Clusters of cluster CTAs the device runs at once, one CTA an SM
(the kernel's shared memory allows no more): 36 of 4, 15 of 8 and 7 of 16
on a 152-SM GB300.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
_u32x4(loaded, loc, ip)
¶
The four words of an inline-assembly struct result.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
_v(value, loc, ip)
¶
block_key(w0, w1, w2, w3)
¶
The key of the NaN-propagating maximum of eight BF16 values.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
cluster_add_u64(address, value, *, loc=None, ip=None)
¶
Atomic add to an 8-byte aligned cluster shared word pair; returns the old value.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
cluster_for(rows, width, device_index)
¶
CTAs a row: 8 while every row's cluster is resident at once, else 4. Rows wider than 4 CTAs hold (the ratio-2 layers' at a 1M context) always take 8, and rows wider than 8 CTAs hold (the candidate source's) 16, in waves when they outnumber the resident clusters.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
cluster_load(address, *, loc=None, ip=None)
¶
Load a cluster shared word.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
cluster_red(address, value, *, loc=None, ip=None)
¶
Atomic add to a cluster shared word.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
cluster_store_u16(address, value, *, loc=None, ip=None)
¶
Store the low half of a word to cluster shared memory.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
cluster_store_u32(address, value, *, loc=None, ip=None)
¶
Store a 32-bit word to cluster shared memory.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
decode_topk(logits, lengths, out, block_mode, fallback=False)
¶
Launch DecodeTopK on the current stream.
Parameters:
-
(logits¶Tensor) –[rows, width] BF16, row
rvalid belowlengths[r](seesupports_decode_topk). -
(lengths¶Tensor) –Contiguous [rows] int32 valid lengths in logits columns.
-
(out¶Tensor) –[rows, k] int32 (unit column stride) for the indices: tokens, or 8-token blocks in block mode (-1 for blocks scoring -inf).
-
(block_mode¶bool) –Select 8-token blocks (the candidate source) instead of tokens.
-
(fallback¶bool, default:False) –Force the direct path (tests).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
hist_add(hist_address, bin_, valid, copies, lane)
¶
Count each valid lane's bin_ with one shared atomic. copies:
lane l counts into copy l % COPIES of a [COPIES][256]
histogram (whole-row histograms: crowded bins would serialize the
atomics of one copy); else into a plain 256-word one.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
load_u32x4(address, *, loc=None, ip=None)
¶
Four 32-bit words at a 16-byte aligned global address.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
max_nan_bf16x2(a, b, *, loc=None, ip=None)
¶
Lane-wise maximum of two BF16 pairs, NaN if either is NaN.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
order_key(bits)
¶
The order-preserving key of the BF16 value in the low half of bits:
a larger value has a larger key, NaNs of either sign outside the
numbers.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
peer_address(address, rank, *, loc=None, ip=None)
¶
The cluster address of this CTA's shared address in CTA rank.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
precompile(device_index, width, k, block_mode)
¶
Compile the DecodeTopK variants decode_topk launches on rows of
width logits for k and block_mode, at any row count, and read
the cluster occupancy it plans with, before graph capture.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
select_bin(hist, q, ctl, lane)
¶
Warp 0: the bin b of a 256-bin histogram holding the q-th
largest entry (q >= 1), into ctl[BIN], and q minus the entries
in the bins above b into ctl[REMAIN]. Lane l scans bins
255 - 8 l down to 248 - 8 l.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
shared_load_u32x4(address, *, loc=None, ip=None)
¶
Four 32-bit words at a 16-byte aligned shared address of this CTA.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
shared_red(address, value, *, loc=None, ip=None)
¶
Atomic add to a shared word of this CTA.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
shared_store_u32x4(address, w0, w1, w2, w3, *, loc=None, ip=None)
¶
Store four 32-bit words at a 16-byte aligned shared address of this CTA.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
shfl_up(value, delta, *, loc=None, ip=None)
¶
value of the lane delta below (own value in the lowest lanes).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
store_s32(address, value, *, loc=None, ip=None)
¶
Store a 32-bit word to global memory.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
supports_decode_topk(logits, rows, k, block_mode)
¶
Whether decode_topk takes these BF16 logits (16-byte aligned rows
whose width, a multiple of 8, fits one cluster of at most 16 CTAs) for
rows rows. Rows that need 16 CTAs are taken for at most two waves of
clusters: beyond, the waves cost more than the upcast and the stock
top-k.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
threads_for(cluster)
¶
vector_choices(cluster)
¶
The 16-byte vectors a thread may stage: 8, or 16 at 512 threads (1024 threads have the shared memory for 8).
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/attention/decode_topk_cute.py
vectors_for(width, cluster)
¶
The fewest staged vectors a thread whose cluster holds a row of
width logits (a 16-byte vector: 8 logits, or one block), or None.