flashinfer.attention.prims_ts.get_prims_ts_batch_decode_workspace_size¶
- flashinfer.attention.prims_ts.get_prims_ts_batch_decode_workspace_size(batch_size: int, num_qo_heads: int, num_kv_heads: int, head_dim: int, page_size: int, max_seq_len: int, *, seq_len_q: int = 1, qo_indptr: Tensor | None = None, max_seq_len_q: int | None = None, q_dtype: dtype = torch.float16, kv_dtype: dtype | None = None, out_dtype: dtype | None = None, mask_type: Literal['dense', 'causal'] = 'dense', window_left: int = -1, kv_layout: Literal['HND'] = 'HND', device: int | str | device | None = None) int¶
Return caller-workspace bytes for one automatic FMHA policy.
The arguments resolve the same policy and scratch layout as
prims_ts_batch_decode_with_kv_cache(), without compiling a kernel. Allocate at least the returned number of bytes as a contiguoustorch.int8ortorch.uint8CUDA tensor and zero it before its first FMHA launch. Re-zero a reused buffer whenever any workspace-layout input, includingbatch_size, changes because the internal section offsets can move even when the compiled callable is reused. Fixed-Q launches useseq_len_q. Packed-Q launches provideqo_indptrand the explicit staticmax_seq_len_qbound used for workspace geometry and JIT policy.max_seq_lenmust be no larger than2,147,483,392so the padded 256-token K/V tile endpoint remains representable as signed Int32. This sizing helper validates that every cumulative-offset delta is positive and no larger than the bound. Ifdeviceis omitted, it is inferred fromqo_indptrfor a packed launch.