vllm.v1.attention.ops.rocm_rdna_hip
¶
Lookup of the RDNA3.5 attention kernels built into _rocm_C.
Each entry of csrc/rocm/rdna_{decode,prefill}_configs.h is one
build, with its shape and launch knobs as compile-time constants; those of
rdna_decode_batch_configs.h serve a batch.
Classes:
-
KernelVariant–One decode build: its shape and launch knobs.
-
PrefillVariant–One prefill build: its shape, smallest M and launch knobs.
Functions:
-
config_fields–The variant's DecodeConfig fields, in order.
-
expected_kv_cache_strides–Strides of (block, kv head, token) of the HND cache the kernel assumes:
-
load–The variant in _rocm_C, or None if unavailable.
-
load_prefill–The variant in _rocm_C, or None if unavailable.
-
make_prefill_scratch–Split-KV scratch (O, max/sum, counters) for any of
variants. -
make_scratch–Allocate the split-KV scratch, outside CUDA-graph capture; max_seqs
-
plan_prefill–The work list of a prefill launch over a batch.
-
prefill_batch_cell–(min_query_len, head group) of the cell a batch falls in, or None.
-
prefill_batch_features–(mean query tokens, mean keys per token) of a batch, padding left out.
-
prefill_batch_variant_for–The build and head group for a prefill batch: its cell's, else the
-
prefill_config_fields–The variant's PrefillConfig fields, in order.
-
prefill_target_workgroups–Workgroups below which the prefill kernel splits the KV (one per SIMD).
-
prefill_variant_for–The row for num_tokens query tokens, or None.
-
prefill_variants–Every row of one shape, sorted by M.
-
scratch_bytes–Scratch bytes per sequence of a batch.
-
variant_for–The build for one call, or None.
-
variants–Every decode build in _rocm_C.
KernelVariant
dataclass
¶
One decode build: its shape and launch knobs.
Methods:
-
scratch_shapes–Shapes of the split-KV partials (acc, m/l) and the counter count.
Attributes:
-
name(str) –The DecodeConfig fields joined by "_".
-
rows_padded(int) –Query rows per workgroup, padded to 16.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
name
property
¶
The DecodeConfig fields joined by "_".
rows_padded
property
¶
Query rows per workgroup, padded to 16.
scratch_shapes()
¶
Shapes of the split-KV partials (acc, m/l) and the counter count.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
PrefillVariant
dataclass
¶
One prefill build: its shape, smallest M and launch knobs.
Methods:
-
scratch_rows–Most split-KV partial rows a launch may write.
Attributes:
-
block_rows(int) –Query rows per workgroup.
-
name(str) –The PrefillConfig fields joined by "_".
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_Builtin
¶
A decode build in _rocm_C.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_BuiltinPrefill
¶
A prefill build in _rocm_C.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_builds(batched=0)
cached
¶
The decode builds in _rocm_C, by index.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_built_configs(op_name, fields)
¶
_built_fields with the dtype as a torch dtype.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_built_fields(op_name, fields)
¶
The entries of a table in _rocm_C as fields, by index.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_prefill_batch_table()
cached
¶
Per (Hq, Hkv, D, page, window), its cells (min mean M, min keys, min_query_len, head group).
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
_prefill_builds()
cached
¶
The prefill builds in _rocm_C, by index.
_prefill_table()
cached
¶
The builds by M per (Hq, Hkv, D, page, window, dtype).
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
config_fields(variant)
¶
The variant's DecodeConfig fields, in order.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
expected_kv_cache_strides(variant)
¶
Strides of (block, kv head, token) of the HND cache the kernel assumes: (NB, HKV, PAGE_SIZE, 2D).
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
load(variant)
¶
The variant in _rocm_C, or None if unavailable.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
load_prefill(variant)
¶
The variant in _rocm_C, or None if unavailable.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
make_prefill_scratch(variants, device)
¶
Split-KV scratch (O, max/sum, counters) for any of variants.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
make_scratch(variant, device, max_seqs=0)
¶
Allocate the split-KV scratch, outside CUDA-graph capture; max_seqs sequences of it for a batched build.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
plan_prefill(query_start_loc, seq_lens, variant, window, target_workgroups, head_group=0)
¶
The work list of a prefill launch over a batch.
An entry is one (sequence, tile, KV segment), run for every kv head, heaviest first. Tiles heavier than the mean load per SIMD are split.
Parameters:
-
(query_start_loc¶ndarray) –The batch's query starts.
-
(seq_lens¶ndarray) –Each sequence's length, or an upper bound.
-
(variant¶PrefillVariant) –The build that runs the launch.
-
(window¶int) –Sliding window in keys, 0 for full causal.
-
(target_workgroups¶int) –One per SIMD (prefill_target_workgroups).
-
(head_group¶int, default:0) –Kv heads to interleave (0: the build's).
Returns:
-
ndarray–The int32 [entries, 4] list {seq, tile | split tile << 16,
-
int–segment | segments << 16, first partials slot or -1}, and the head
-
tuple[ndarray, int]–group (all kv heads if a tile splits).
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
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 | |
prefill_batch_cell(num_q_heads, num_kv_heads, head_size, page_size, window, mean_m, keys)
¶
(min_query_len, head group) of the cell a batch falls in, or None.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
prefill_batch_features(query_start_loc, seq_lens, window)
¶
(mean query tokens, mean keys per token) of a batch, padding left out.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
prefill_batch_variant_for(num_q_heads, num_kv_heads, head_size, page_size, layout, window, dtype, query_start_loc, seq_lens)
¶
The build and head group for a prefill batch: its cell's, else the build of its tokens.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
prefill_config_fields(variant)
¶
The variant's PrefillConfig fields, in order.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
prefill_target_workgroups(device)
cached
¶
Workgroups below which the prefill kernel splits the KV (one per SIMD).
prefill_variant_for(num_q_heads, num_kv_heads, head_size, page_size, layout, window, dtype, num_tokens)
¶
The row for num_tokens query tokens, or None.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
prefill_variants(num_q_heads, num_kv_heads, head_size, page_size, window, dtype)
¶
Every row of one shape, sorted by M.
Source code in vllm/v1/attention/ops/rocm_rdna_hip.py
scratch_bytes(variant)
¶
Scratch bytes per sequence of a batch.
variant_for(num_q_heads, num_kv_heads, head_size, max_query_len, page_size, layout, window, dtype, batch=False)
¶
The build for one call, or None.