vllm.v1.attention.ops.flydsl_turboquant_decode
¶
FlyDSL TurboQuant decode launcher (vLLM-side).
Drop-in replacement for triton_turboquant_decode_attention_soa for the
TQ decode profile HEAD_SIZE=128, MSE_BITS=4 K, VQB=4 V, N_CENTROIDS=16,
BLOCK_SIZE in {16, 32}, GQA group in {6, 8, 16} (one kernel, kernels.tq_decode).
Auto-selected on gfx950 when FlyDSL is importable; falls back to the SoA Triton decode otherwise (wrong arch, missing build tree).
Architecture
- Q rotation:
q_rot = (query.float() @ PiT).bfloat16()— the same launcher-side rocBLAS GEMM the SoA Triton decode uses. - FlyDSL kernel writes per-partition outputs into
[N, Hk, P, QG, D]bf16 +[N, Hk, P, QG]fp32 max/sum buffers. - A small Triton reducer combines partitions in the kernel's native layout
(no permute/cast), writing the final
[N, Hq, D]output.
Kernel module is built once per (num_kv_heads, num_partitions,
max_blocks_per_seq, scale) shape and cached.
Functions:
-
flydsl_turboquant_decode_attention–SoA-decode-compatible launcher backed by the FlyDSL decode kernel.
-
is_flydsl_available–Return True iff on gfx950 and FlyDSL imports + kernel module load.
-
is_flydsl_gqa6_available–GQA-6 runs on the same kernel; kept for the turboquant_attn.py gate.
_SegmBufPool
¶
Single-bucket buffer pool for segm_out/segm_max/segm_sum/output.
Each unique shape signature (Hk, Hq, num_partitions, QG, D, device,
dtype) is backed by ONE allocation sized at max_B (= max captured
cudagraph batch size, or env override). Per-call get(B, ...)
returns [:B] views — same data_ptr base, narrower N dim. The
kernel grid is (B, ...) so it only ever writes the first B rows
of segm_out / segm_max / segm_sum; downstream readers (Triton
reducer + caller) only consume the first B rows of output.
Why a single bucket: cudagraph records launch pointers at capture time. With per-B allocations, every captured size triggered a fresh allocation, so total VRAM scaled with the number of captured sizes. With single-bucket, the pool tops out at one max_B-sized buffer per shape, shared across ALL captured sizes and ALL eager mixed-batch calls. The data_ptr is stable from first allocation onward, so cudagraph capture is happy across all captured B's.
Eliminates per-decode-step cudaMalloc (× 4) plus the device-side
memset kernels behind torch.full(-inf) and torch.zeros.
The kernel always writes the FULL [B, Hk, P, QG, D] slice and
every (n, kv_h, p, qg) position of segm_max / segm_sum (it stores
-inf and 0 for empty partitions itself), so uninitialized
bytes from the pool are safe to reuse for any B ≤ B_bucket.
Source code in vllm/v1/attention/ops/flydsl_turboquant_decode.py
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 | |
_detect_max_capture_B()
¶
Probe vLLM compilation config for the largest cudagraph capture size.
Returns max(cudagraph_capture_sizes) if available, else falls back to
512 (vLLM's default cap). The segm-pool auto-grows if a larger batch is
seen (see _SegmBufPool.get).
Used to size the segm-pool bucket once, so that all distinct B's (whether captured in a graph, or hit eagerly in mixed batches) share a single allocation per shape — eliminating the per-B growth that previously dominated dense-capture VRAM cost.
Source code in vllm/v1/attention/ops/flydsl_turboquant_decode.py
flydsl_turboquant_decode_attention(query, kv_cache, block_table, seq_lens, Pi, centroids, scale, mse_bits, key_packed_size, value_quant_bits, value_packed_size, key_fp8=False, norm_correction=False, PiT=None, max_seq_len=0, mid_o_buf=None, output_buf=None, lse_buf=None, buf_holder=None, max_num_kv_splits=32, sinks=None)
¶
SoA-decode-compatible launcher backed by the FlyDSL decode kernel.
Constraints
- key_fp8 == False
- mse_bits == 4
- value_quant_bits == 4
- centroids.numel() == 16
- D == 128
- block_size in {16, 32}
- Hq // Hk in {6, 8, 16}
Sinks are NYI and silently ignored if set. norm_correction is honored implicitly via the pre-folded stored K-norm (see footer comment).
Source code in vllm/v1/attention/ops/flydsl_turboquant_decode.py
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 | |
is_flydsl_available()
¶
Return True iff on gfx950 and FlyDSL imports + kernel module load.