vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.dsa.front_mma
¶
Fused DSA indexer front on tcgen05: the wq_b projection (N 4096, K 1536) and
DsaIndex (the FP8 indexer query, its folded head weights and the indexer key insert)
in one kernel, from MlaQuery's normalized q_c rows (serial / wait query overlap) or
(normalized=False) from the packed rows with the q_a RMSNorm in the kernel.
A CTA owns one indexer head (its 128 wq_b rows: tcgen05 M = 128, swap-AB) for one
tile of n rows (N) and one of split K slices; the K slices of a head and row
tile, times group heads, form one cluster.
- Warp 5 (TMA): the first stages' 128 x 64 weight blocks before the PDL wait (L2 evict_first, a device tensor map), then the rows' 64-column blocks (zero past the batch) and the later weight blocks into the ring; then indexer keys (DsaIndex's code), the grid's CTAs taking the tokens round robin.
- Warp 4: per block, the K16 BF16 MMAs into TMEM (FP32, column j = row j).
- Warps 0-3, from packed rows only: the RMSNorm factors (QueryNorm.tiled's packed FMA order; a cluster shares its rows' factors over DSMEM), then each block normalized in place (BF16 (x * rr) * gamma, as QueryNorm).
- Warps 0-3 (thread = channel): with
split> 1 the partial columns go to their K slice's owner (DSMEM), which adds thesplitpartials in a fixed order; each column is rounded to BF16 (the projection's output) and quantized as DsaIndex does: the head amax over the 128 channels, a power-of-two scale (exact inverse), FP8 bytes and the folded BF16 head weight.
Classes:
-
IndexFrontMma–batchrows;key/weight: the wk and wv column offsets in the packed
Functions:
-
front_tiling–(n, tiles, split, group) of
batchrows: the rows per tile (a multiple of -
load_columns–countFP32 TMEM columns of this lane fromaddress(power-of-two loads
IndexFrontMma
¶
batch rows; key/weight: the wk and wv column offsets in the packed
projection row; mx: key scales as packed UE8M0 (MX) bytes; the tiling
(n, tiles, split, group) is front_tiling's; normalized: the
rows are the normalized q_c; row_pitch: their pitch (elements).
Methods:
-
epilogue–Warps 0-3 (thread = channel): the split-K reduction of the owned columns,
-
factors–Warps 0-3: the tile's RMSNorm factors into
rr: every row here (small -
load_weights–One lane: block kb's 128 x 64 weight box on its full barrier.
-
multiply–Warp 4: per K block, the K16 MMAs; release the stage (the last block:
-
normalize–BF16 (x * rr) * gamma in place on this thread's chunks of a K block
-
reduced–Columns c..c+3 of this thread's channel, BF16-rounded: TMEM (one K
-
row_factors–QueryNorm.tiled's RMSNorm factors of a few (valid) rows, one warp:
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
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 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 | |
epilogue(args, tmem, mailbox, amax_s, wv_s, bar_red, row0, valid)
¶
Warps 0-3 (thread = channel): the split-K reduction of the owned columns, then per column BF16, the head amax, FP8 and the folded weight.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
factors(rows_in, rr, bar_rr, rank, row0, valid, eps)
¶
Warps 0-3: the tile's RMSNorm factors into rr: every row here (small
tiles, one-CTA clusters), else this CTA's share of the rows, sent to every
CTA of the cluster.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
load_weights(wring, bars, w_map, kb, k_first, head)
¶
One lane: block kb's 128 x 64 weight box on its full barrier.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
multiply(wring, xring, bars, tmem)
¶
Warp 4: per K block, the K16 MMAs; release the stage (the last block: the accumulator barrier).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
normalize(tile, valid, k0, rr, gamma_s)
¶
BF16 (x * rr) * gamma in place on this thread's chunks of a K block
(k0: the block's first column in this CTA's K slice; every chunk of a
thread is the same 8 columns).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
reduced(lane_base, mailbox, s, c)
¶
Columns c..c+3 of this thread's channel, BF16-rounded: TMEM (one K
slice) or the split partials in order.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
row_factors(x, rows, eps, lane)
¶
QueryNorm.tiled's RMSNorm factors of a few (valid) rows, one warp: every load first, then each row's packed FMA chains.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
front_tiling(batch)
¶
(n, tiles, split, group) of batch rows: the rows per tile (a multiple of
16), the row tiles, the K slices and the CTAs of a cluster along the heads. Up
to 128 CTAs: K slices while the weights dominate, row tiles from there (clusters
of at most 4: 8-CTA clusters of these ~200 KB CTAs do not all fit at once).
No tile lies past the batch (129-144 rows: 3 tiles of 48, not 4).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/dsa/front_mma.py
load_columns(address, count)
¶
count FP32 TMEM columns of this lane from address (power-of-two loads
of at most 64).