vllm.v1.attention.ops.flydsl_kernels.tq_decode
¶
Functions:
-
build_tq_decode_module–Build a TQ decode kernel module.
build_tq_decode_module(num_seqs, num_kv_heads, num_partitions, max_blocks_per_seq=512, softmax_scale=None, query_group_size=QUERY_GROUP_SIZE, kv_block_size=KV_BLOCK_SIZE, tile_groups_per_partition=1)
¶
Build a TQ decode kernel module.
query_group_size (= num_query_heads // num_kv_heads) selects the
GQA factor. Supported values: 6, 8 and 16. Below 16 the MFMA's 16-row
capacity is partly used; lanes QG..15 compute garbage and are gated out
of all global-memory writes by mfma_row < QG. Q load iterates
(QG + 3) // 4 chunks (= 2 for QG=6/8, 4 for QG=16).
kv_block_size is the number of tokens per vLLM cache block. Must
be a multiple of TILE_SIZE (=16). Supported values: 16 and 32. With
block_size=32, two MFMA K-tiles fit in each block; the kernel walks
block-table entries every kv_block_size // TILE_SIZE tiles and
re-uses the entry for sub-tiles within the same block. SoA metadata
region grows linearly with block_size.
V is dequantized into a row-major V[token][head_dim] LDS layout
(4 ds_write_b128 per lane) and read back into the MFMA A operand via
the CDNA4 ds_read_tr16_b64 hardware transpose.
tile_groups_per_partition (default 1) controls the FA-2 split-K
granularity. With value G each partition processes G * 16 K-tiles
= G * KV_COMPUTE_BLOCK tokens, with the existing 16-tile loop
body iterated G times. The launcher uses this to bound
num_partitions (e.g. cap at 32) for long context: at 32K /
block_size=32 / num_partitions=32, G=5 covers 325256 = 40 960
tokens of worst-case context with grid.z=32 instead of 256.
Behavior at G=1 is bit-identical to the single-partition kernel.