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.
_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.
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).
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.