vllm.models.minimax_m3.nvidia.specialized_decode.kernels.page_topk
¶
page_topk stage: per (decode row, index head) the 16 pages the sparse decode attends to, written as physical page ids into the sparse block table.
The device code is CuTe DSL (page_topk_kernel.py, compiled for the live
device at build). Exact selection: forced
pages (the first init_blocks and the last local_blocks valid pages)
always kept, the rest by (score desc, page asc) on the fp32 bit order; output
in ascending page order, -1 tail when fewer than 16 pages are valid.
Split rows: a row of at most single_max valid (4096)
pages is one CTA of 256 threads (the unsplit select); a longer row is cut
into chunks of chunk pages, one CTA each, that write their exact local
top pages to a partial buffer, and the last chunk CTA to arrive (a per-row
counter it re-arms) merges them. The union of the per-chunk top-need
holds the row's top-need, so the table is the same, bit for bit. Grid =
(rows x heads, splits), splits from the static column count; no CTA waits for
another, so the grid needs no residency check. PDL: waits after its pre-wait
loads (n_valid, page rows), then triggers dependents.
Classes:
-
PageTopkStage–__call__(scores, n_valid, page_rows, table)
Functions:
-
max_splits–Chunk CTAs per (row, head) of a launch over
num_colsscore columns (1 = the
PageTopkStage
¶
__call__(scores, n_valid, page_rows, table)
scores float32 [nd, H, C] index page scores (C <= 8192, stride(2) == 1);
upstream unified_scores[:nd]
n_valid int32 [>= nd] valid index pages of each row's token
page_rows int32 [>= nd, >= C] logical page -> physical KV page id
table int32 [H, nd, >= 16] columns 0..15 written
Methods:
-
single_max_of–Pages up to which a launch of
rowsrows keeps one CTA per row. -
splits–CTAs per (row, head) of a launch of
rowsrows overcolsscore
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/page_topk.py
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 | |
_compiled_fn(split_mode, has_diag, pdl, device)
¶
cute.compile the launcher of (split_mode, has_diag, pdl); cached. Every argument but those is runtime.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/page_topk.py
_ext()
¶
The CuTe DSL kernel module (imported on first use; raises if the CuTe DSL is unavailable).
max_splits(num_cols, chunk, single_max)
¶
Chunk CTAs per (row, head) of a launch over num_cols score columns (1 = the
one-CTA kernel).