Skip to content

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:

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.

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.

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

block_rows property

Query rows per workgroup.

name property

The PrefillConfig fields joined by "_".

scratch_rows(device)

Most split-KV partial rows a launch may write.

_Builtin

A decode build in _rocm_C.

_BuiltinPrefill

A prefill build in _rocm_C.

_builds(batched=0) cached

The decode builds in _rocm_C, by index.

_built_configs(op_name, fields)

_built_fields with the dtype as a torch dtype.

_built_fields(op_name, fields)

The entries of a table in _rocm_C as fields, by index.

_prefill_batch_table() cached

Per (Hq, Hkv, D, page, window), its cells (min mean M, min keys, min_query_len, head group).

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

config_fields(variant)

The variant's DecodeConfig fields, in order.

expected_kv_cache_strides(variant)

Strides of (block, kv head, token) of the HND cache the kernel assumes: (NB, HKV, PAGE_SIZE, 2D).

load(variant)

The variant in _rocm_C, or None if unavailable.

load_prefill(variant)

The variant in _rocm_C, or None if unavailable.

make_prefill_scratch(variants, device)

Split-KV scratch (O, max/sum, counters) for any of variants.

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.

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

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.

prefill_batch_features(query_start_loc, seq_lens, window)

(mean query tokens, mean keys per token) of a batch, padding left out.

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.

prefill_config_fields(variant)

The variant's PrefillConfig fields, in order.

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.

prefill_variants(num_q_heads, num_kv_heads, head_size, page_size, window, dtype)

Every row of one shape, sorted by M.

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.

variants()

Every decode build in _rocm_C.