Skip to content

Sparse KV offloading ​

Use this reference to configure sparse KV offload and understand its execution constraints, memory-pressure behavior, and client retry contract.

Offload configuration ​

--kv-offload-config accepts a JSON object with exactly four required fields. The following table describes the fields:

FieldTypePurpose
layersArray of nonnegative integersUnique target attention layer IDs.
hot_tokensIntegerHot-token capacity for each request, as a positive power of two.
host_gbNumberFinite positive Host budget in GiB.
overlapBooleanExplicitly enable or disable cross-layer prefetch.

Omitting --kv-offload-config disables offload.

The following example selects attention layers 1 and 3, sets a 4096-token hot capacity and a 1.5 GiB Host budget, and enables prefetch overlap. Replace the layer IDs and resource values with those supported by your model and deployment:

bash
--kv-offload-config '{"layers": [1, 3], "hot_tokens": 4096, "host_gb": 1.5, "overlap": true}'

The model cache recipe validates supported fields, selection capacity, and execution constraints. Unsupported recipes reject the configuration.

Plugin execution options ​

Plugin execution options use --extra-server-args, a flat JSON object whose fields are registered and validated by the owning plugin. For more information, see Plugin server arguments.

If a plugin supports a window ring, set kv_offload_window_ring in --extra-server-args explicitly. Do not put window_ring in the offload object; TokenSpeed rejects fields other than the four listed in the preceding table. The legacy hf_overrides.kv_offload entry neither enables offloading nor overrides --kv-offload-config.

The kv_offload_window_ring option does not implicitly enable multi-token prediction (MTP), CUDA Graph, or scheduler overlap, and does not change numerical settings.

Capacity aborts and client retries ​

Offloading uses capacity aborts instead of snapshot recovery. TokenSpeed automatically disables its snapshot pool. If you enable offloading, TokenSpeed rejects:

  • Positive --retraction-snapshot-host-gb or --retraction-snapshot-ratio values.
  • Positive --retraction-snapshot-max-requests values.
  • Nonzero --debug-force-retraction-interval values.

An explicit --retraction-snapshot-ratio 0 remains valid.

Under decode memory pressure, the scheduler releases the victim's history blocks and request slot and reports CapacityAbort to the client. To continue after a capacity abort, submit a new request.

The fixed hot allocation persists. Before another prefill/decode (PD) owner uses a request partition, TokenSpeed invalidates that partition.

TokenSpeed documentation