For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python function
spec_decode_cache_slack
spec_decode_cache_slack()
max.nn.kv_cache.spec_decode_cache_slack(params)
Computes the extra KV positions a request may occupy past max_seq_len.
A speculative-decode step can over-speculate past the per-request
max_seq_len cap into this slack (the KV pool reserves it beyond
max_seq_len), so any per-request sizing derived from max_seq_len
– the pool’s page budget, the sparse-indexer score scratch, etc. – must
add it. Centralized here so _compute_seq_len, pool sizing, and
OverlapTextGenerationPipeline._effective_max_cache_length stay in sync.
-
Parameters:
-
params (KVCacheParamInterface) – The KV cache parameters. The speculative-decoding fields (
num_draft_tokensandnum_draft_tokens_per_step) determine the slack. -
Returns:
-
The number of extra KV positions to reserve past
max_seq_len, or0when speculative decoding is off. -
Return type:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!