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 define the same semantic JIT key as
prims_ts_batch_decode_with_kv_cache(). The query resolves policy and scratch layout but does not compile 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 an argument contributing to the semantic JIT key changes, because the internal section offsets can change with that key. 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,520so the padded 128-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.