Pre-size the shared workspace for the decode split-KV attn logits.
Reserving at the worst case (max_model_len -> max num_kv_splits, max_num_seqs decode tokens) before warmup/cudagraph capture means the per-call get_simultaneous in forward_mqa never has to grow the buffer at runtime (which would raise once the workspace is locked).
Source code in vllm/v1/attention/backends/mla/triton_mla.py
| def _reserve_attn_logits_workspace(self) -> None:
"""Pre-size the shared workspace for the decode split-KV attn logits.
Reserving at the worst case (max_model_len -> max num_kv_splits,
max_num_seqs decode tokens) before warmup/cudagraph capture means the
per-call ``get_simultaneous`` in ``forward_mqa`` never has to grow the
buffer at runtime (which would raise once the workspace is locked).
"""
if not is_workspace_manager_initialized():
return
# Decode reorder threshold is 1, so decode tokens <= max_num_seqs.
B = self.vllm_config.scheduler_config.max_num_seqs
# Non-causal DSpark draft flattens each request's block to query_len
# decode rows; cover max_num_seqs * block_len rows.
if getattr(self, "non_causal_multi_token_decode", False):
B *= self.reorder_batch_threshold
# DCP all-gathers the query heads before forward_mqa.
q_num_heads = self.num_heads * self.dcp_world_size
max_splits = _compute_num_kv_splits(
self.model_config.max_model_len,
current_platform.num_compute_units(),
)
lse_dim = self.mla_dims.kv_lora_rank + 1
current_workspace_manager().get_simultaneous(
((B, q_num_heads, max_splits, lse_dim), torch.float32),
)
|