Skip to content

vllm.v1.attention.backends.rocm_rdna_attn

Attention for gfx1151 (opt-in).

Decodes of up to MAX_M query tokens per sequence run csrc/rocm/rdna_decode_attn.cu, other batches csrc/rocm/rdna_prefill_attn.cu, on TRITON_ATTN's KV cache. Anything the kernels do not support runs TRITON_ATTN.

Classes:

Functions:

  • mm_decode_ranges –

    Per request the decode kernel may serve (at most MAX_M query tokens),

  • mm_query_overlap –

    How the step's query tokens sit in its multimodal ranges.

RocmRdnaAttentionBackend

Bases: TritonAttentionBackend

TRITON_ATTN with the RDNA3.5 kernels.

RocmRdnaAttentionImpl

Bases: TritonAttentionImpl

Runs the RDNA3.5 kernels when they support the call, else Triton.

Methods:

  • forward –

    The kernels when they can serve the call, else Triton's forward.

_plan(md, block_size, win, first, q)

This step's build, plan, head group and device query starts for the sequences from first on; made by the first layer, shared by the rest.

_prepare(kv_cache, **kwargs)

The decode kernel and its scratch, or None to fall back.

_prepare_prefill(kv_cache, md, kwargs, first=0)

The prefill launch for the sequences from first on, or None.

Not under CUDA-graph capture: the launch depends on the host's M and S.

_reject(reason)

Log why this call falls back to Triton.

_serve_mixed(kv_cache, md, kwargs)

Leading decodes on the decode kernel, the rest on the prefill kernel; False if a kernel cannot take its part.

_serve_prefill(kv_cache, md, kwargs)

Run the prefill kernel; False if it cannot serve the call.

_served_tensors(kv_cache, kwargs, head_sizes)

Whether the kernels support these tensors.

_served_window(kwargs)

The sliding window in keys (0: none), or None if unsupported.

forward(layer, query, key, value, kv_cache, attn_metadata, output, output_scale=None, output_block_scale=None)

The kernels when they can serve the call, else Triton's forward.

RocmRdnaMetadata dataclass

Bases: TritonAttentionMetadata

Triton's metadata plus the host's copy of the batch for the prefill plan.

RocmRdnaMetadataBuilder

Bases: TritonAttentionMetadataBuilder

Triton's builder, decodes first and counted. CUDA graphs only for uniform decode batches: a prefill plan follows the host.

_mm_ranges_decode(md)

Write mm_decode_ranges to mm_ranges_buffer, a row per request.

mm_decode_ranges(md)

Per request the decode kernel may serve (at most MAX_M query tokens), its non-empty ranges that may hold one of its query tokens; none for the others, which run on the prefill kernel.

The kernel only bounds the mask of query tokens, so the others change nothing. On async spec-decode rows seq_lens_cpu_upper_bound may overshoot by the rejected drafts, M - 1 while the draft count holds, so the span is widened by M - 1; at most 2M - 1 disjoint ranges then remain. None if the model has no ranges.

mm_query_overlap(md)

How the step's query tokens sit in its multimodal ranges.

Returns:

  • bool –

    (whether a query token's range has later keys, which only the

  • int –

    bidirectional mask shows; how far back the farthest in-range query

  • tuple[bool, int] –

    token reaches into its range, -1 if none is in one). Ranges are

  • tuple[bool, int] –

    inclusive; start >= end is empty.