Skip to content

Runtime knobs ​

Use this reference to identify TokenSpeed-specific controls and size the retraction snapshot pool. For Host, distributed, peer, and Disk cache tiers, see KV cache tiers.

TokenSpeed-specific parameters ​

The following parameters expose TokenSpeed runtime features directly:

  • --max-total-tokens
  • --max-prefill-tokens
  • --chunked-prefill-size
  • --attn-tp-size
  • --attn-head-tp-size
  • --lm-head-tp-size
  • --tp-batch-invariant
  • --head-tp-exchange-max-rows
  • --dense-tp-size
  • --moe-tp-size
  • --kvstore-*
  • --retraction-snapshot-*
  • --shared-l2-config
  • --kv-events-config
  • --mla-chunk-multiplier
  • --disaggregation-*
  • --comm-fusion-max-num-tokens
  • --enable-allreduce-fusion
  • --allreduce-quantization

Retraction snapshot pool ​

A capacity retraction suspends a resident request instead of recomputing it: the request's cache pages and its per-slot Device state are imaged to pinned Host memory, and once Device pages are free again the image is copied back and the request continues exactly where it stopped—a decoding request decodes, a mid-prompt request runs its next chunk. For more information, see Suspend and resume.

The image is split: the retraction publishes the victim's completed prefix like a finish, its partial last page and its live state block included, and those blocks go to Host L2 as a stream-ordered write-back and stay pinned there until the restore. The blocks of groups L2 never holds (a replayable sliding-window group), a state group's input block when nothing published it (an ordinary chunk end's output), and the slot-state blob go to the request-private pool. For more information, see Retraction image. The two buffers are separate allocations of one Host cache executor, and both count against its Host-memory headroom check. The pool is independent of the KVStore: with --disable-kvstore there is no L2 leg and the pool holds whole images; with L2 it holds the unpublished blocks plus the slot-state blob.

Pool sizing ​

The pool is on by default on the roles that retract and is sized like the Host KVStore, in LCM blocks of the rank's transfer layout (python/tokenspeed/runtime/cache/l2/sizing.py); the slot-state arena (--retraction-snapshot-max-requests × blob bytes) is allocated on top. The following table lists the pool-sizing rules in priority order. The first matching rule applies:

ArgumentsPool sizeRequest cap (--retraction-snapshot-max-requests when 0)
--retraction-snapshot-host-gb G (G > 0)G GB, whole LCM blocksRank-local resident capacity C (B+E on decode; B on fused)
--retraction-snapshot-ratio R (R > 0)R × this rank's Device LCM blocksSame
--retraction-snapshot-ratio 0No pool: a capacity block aborts its victim0 (an explicit cap is refused)
Neither, --disable-kvstore0.1 × this rank's Device LCM blocks (whole images)C
Neither, Host KVStore onRequest cap × one image tailC

The default snapshot request cap is the rank-local resident capacity C: B+E on decode and B on fused. B is --max-num-seqs divided by the attention-DP size, and E is --disaggregation-decode-extra-slots. An explicit positive --retraction-snapshot-max-requests overrides this default.

The cap budgets simultaneous images independently of Host KV bytes. A retraction frees a Device request row for another admission, so continued admissions can create demand for more than C simultaneous images; C is a default budget, not a guarantee that all such requests can be suspended. If your workload needs more, raise the explicit cap and provide enough Host space.

A larger cap allocates more slot-state rows. With Host KVStore enabled and neither snapshot size nor ratio specified, it also increases the derived tail pool. Without Host KVStore, the default snapshot KV pool remains 0.1 of the Device KV block count; raising the row cap does not increase that ratio. Explicit snapshot sizes and ratios remain unchanged. In every case, both image rows and Host storage must fit.

One image tail, per cache group, is one block for a group that publishes to Host L2 (a state group's unpublished input block; a history group's margin for a published page L2 could not take) and a request's worst-case pages at the context limit for a group that never publishes (a replayable sliding-window group), folded to LCM blocks by the scheduler's CapacityModel, so the pool is counted the way the scheduler later claims it.

Without the KVStore, a whole image is the request's every page, so the default is a tenth of the Device KV rather than all of it: an on-by-default pool must stay cheap to pin (the Device KV once is hundreds of gigabytes of pinned Host memory for a small model on a large GPU), and it still suspends a few residents; an image that does not fit aborts its victim. --retraction-snapshot-ratio 1 gives the snapshot KV pool the same usable LCM-block count as Device KV; enabling the KVStore moves published pages to Host L2. Neither setting raises the snapshot request cap. Suspending a larger set requires enough slot-state rows and enough space for its complete images across the snapshot pool and Host L2. A size or ratio that holds no whole LCM block is refused, not rounded down to none.

Each engine logs one line at startup with the resolved pool (GB and LCM blocks, which rule sized it), the request cap and arena, and whether Host L2 takes the hash-complete pages; without a pool the line says that capacity blocks abort. The prefill and encode roles never retract: their pool arguments are ignored with a log.

Image fit failures ​

Host accounting stays optimistic—no admission gate charges a request's worst-case image—and retraction never waits on Host capacity or falls back to recomputation. The capacity policy ranks only victims whose image fits (a free slot-state row and pool room for the tail and for the hash-complete pages Host L2 does not take: which ones it takes is planned before anything is evicted for the image, under either write policy).

When no resident fits, the scheduler aborts the newest retractable resident in the same round and grants its pages to the blocked request. The client sees the finish {"type": "abort", "err_type": 524, "message": "Request aborted by the scheduler: <detail>"} (ABORT_CODE.CapacityAbort). The detail names the shortfall—"snapshot pool cannot hold the image", "Host L2 cache cannot take the image's published pages", or "no blob slot free (max_retracted_requests=N)"—and the argument to raise. This distinguishes a capacity abort from a NaN abort (523) or a transfer failure (521). A caller that can retry—an RL rollout or a batch job—resubmits. The engine counts these aborts in tokenspeed:num_capacity_aborted_requests.

The two arguments therefore size how much work may be suspended at once (with Host L2, so does --kvstore-size, which takes the hash-complete pages), and exceeding them costs an abort of one request, never latency for everyone else. With no pool (--retraction-snapshot-ratio 0), nothing can be imaged, so a capacity-blocked round aborts the newest resident instead of imaging anyone.

A forced retraction (--debug-force-retraction-interval) whose image does not fit is refused and logged, and the request runs on; only a request whose image is refused after its pages were published is aborted as described earlier. For more information about victim selection, see Retraction: when admission fails.

Cache operations and constraints ​

The snapshot operations ride the round's DeviceHandle.execute with the L2 write-backs and load-backs (Event loop: design principles). Their acknowledgments (ACKs) use the same cache poll, and the pool arms the completion hooks like the L2 tier does. Both Host tiers are allowed under --kv-parallel-size > 1: the scheduler allocates every Host block in its Device block's residue class, and each rank copies the blocks it owns; L3 storage stays refused there. The weight-update cache flush is refused while a request is suspended with an image, so an image of old-weight KV is never restored under new weights. --debug-force-retraction-interval exercises the path without pressure in tests. For more information, see the scheduler parameter reference.

Lone request no-progress aborts ​

On the fused role, the scheduler's no-progress abort fails a request like the image-fit abort described earlier (524), with the detail "no progress for 4096 consecutive plans ...". The engine counts the abort in tokenspeed:num_capacity_aborted_requests too.

The scheduler aborts a lone request after 4096 consecutive scheduler plans without progress, instead of waiting indefinitely, when either of the following conditions applies:

  • No other request holds KV pages beside it, and its admission needs Device pages that neither eviction nor lone-request compaction can free.
  • Its restore does not fit even when it claims no cached page. For more information, see What bounds a single request.

The scheduler warns about such a stall from its 1024th plan on. On the prefill and decode roles of a disaggregated deployment, such a request waits behind the warning instead: a scheduler abort would not conclude the PD transfer it has registered. A prefill request past its first admission is not counted as stalled at all, as its pages stay pinned for the transfer.

TokenSpeed documentation