vllm.v1.attention.ops.segmented_attention
¶
ROCm token-major segmented attention kernels and dispatch.
Functions:
-
can_use_segmented_attention–Check tensor metadata; unsupported feature checks live in the caller.
-
compile_segmented_attention–Compile one segmented attention configuration without launching it.
-
get_segmented_attention_workspace–Keep scratch storage stable and separate for each runtime lane/ubatch.
-
get_segmented_config–Load the tuner on demand to avoid a kernel/tuner import cycle.
-
run_segmented_attention–Write eligible unified-cache attention rows; leave other requests untouched.
-
segmented_attention–Run segmented attention when eligible, otherwise use unified Triton.
-
segmented_attention_workspace_size–Size the largest selected attention workspace before graph capture.
-
segmented_query_capacity–Round a supported query length to its compiled power-of-two capacity.
-
select_segmented_config–Select the token-major cache configuration for segmented attention.
_launch_segmented_attention(q, out, kc, vc, table, starts, lengths, k_scale, v_scale, sinks, scale, cfg, partial, lse, qcap, sliding_window, causal, *, compile_only)
¶
Launch or compile the exact stage and reduction specializations.
_long_extend_splits(base_splits, batch, query_len, seq_len, hq, hk, dim, bm)
¶
Add long-prefix parallelism while bounding the extra split workspace.
can_use_segmented_attention(q, k, v, out, kc, vc, table, starts, lengths, k_scale, v_scale)
¶
Check tensor metadata; unsupported feature checks live in the caller.
compile_segmented_attention(q, out, kc, vc, table, starts, lengths, max_query_len, k_scale, v_scale, scale, config, workspace, *, sliding_window=-1, causal=True, sinks=None)
¶
Compile one segmented attention configuration without launching it.
get_segmented_attention_workspace(device, sizes)
¶
Keep scratch storage stable and separate for each runtime lane/ubatch.
get_segmented_config(*args, **kwargs)
¶
Load the tuner on demand to avoid a kernel/tuner import cycle.
run_segmented_attention(q, out, kc, vc, table, starts, lengths, max_query_len, max_seq_len, k_scale, v_scale, scale, *, sliding_window=-1, causal=True, sinks=None, config=None, workspace=None)
¶
Write eligible unified-cache attention rows; leave other requests untouched.
segmented_attention(query, key, value, output, kv_cache_dtype, key_cache, value_cache, block_table, query_start_loc, seq_lens, max_seq_len, max_query_len, k_scale, v_scale, sm_scale, *, sliding_window=-1, output_scale=None, sinks=None, causal=True, softcap=0.0, workspace=None, use_tuned_config=True)
¶
Run segmented attention when eligible, otherwise use unified Triton.
segmented_attention_workspace_size(max_batch, hq, hk, dim, max_seq_len, *, max_tokens=None, fp8=False, autotune=False)
cached
¶
Size the largest selected attention workspace before graph capture.
max_tokens bounds reachable (batch, query_len) pairs using one
longest query and one token for each remaining sequence. Omitting it keeps
the legacy reservation behavior for callers without scheduler limits.
autotune reserves additional splits for tuned D64 candidates.
segmented_query_capacity(max_query_len)
¶
Round a supported query length to its compiled power-of-two capacity.
select_segmented_config(batch, max_query_len, max_seq_len, hq, hk, dim, fp8)
cached
¶
Select the token-major cache configuration for segmented attention.