KV cache tiers
Use this reference to configure prefix reuse across Host L2, Mooncake Store L3, a shared L2 pool, peer replicas, and local Disk. The following sections describe allocation, consistency, and failure behavior for each tier.
Host L2 and Mooncake Store L3
Host KVStore (--kvstore-ratio / --kvstore-size) is a compact pinned buffer under GPU cache (flat KV). --kvstore-storage-backend mooncake adds Mooncake Store as L3 under that buffer:
GPU Device KV (L1)
↕ D2H / H2D
Host pinned buffer (L2 / flat KV)
↕ batch_put_from / batch_get_into
Mooncake Store (L3)Host L2 and the retraction snapshot pool pack each group's payload independently of Device strides. A shared Host parent fits the largest single group payload, and each group fits as many whole children in it as possible. When that payload is a recurrent-state checkpoint, or a replayable sliding-window page that Host L2 never stores, the KV pages of every parent leave a gap smaller than one page, so the parent may instead round up to a whole number of pages of the KV group that stores the most Host bytes per token: those pages then fill it without a gap, but every parent of the largest payload gains the same bytes as slack. The parent rounds up only when that lowers the Host bytes per cached token, assuming one State checkpoint per 8,192 cached tokens (a request publishes only a few, so a prefix cache of long prompts holds far fewer). Empty parents are available to every group, including recurrent State; no group has reserved capacity. Mirrored ranks must have the same Host packing; startup refuses local layouts that would give the same Host block ID different meanings across ranks.
Write policy
--kvstore-write-policy chooses when pages of the GPU prefix cache are copied to Host L2:
write_through(the default): on the fused and prefill roles, every page the GPU caches is also copied to the Host, which keeps it after the GPU evicts the page. The decode role copies nothing then: its Host L2 holds retraction images only.write_back: nothing is copied when a page is cached. When the GPU evicts cached pages to make room for a request, or to resume a retracted one, it copies them to the Host in the same scheduling step, and they can be reused from there once the copy completes.
write_back lets the two tiers cache more together: the GPU and the Host hold mostly different pages, up to about the sum of their capacities less pages in use or in transit, where under write_through the Host spends its room on a copy of what the GPU holds. Eviction trims a conversation from its end, so the GPU keeps its beginning and the Host the rest, and a later prompt resumes from both. The cost: a step that evicts must finish copying the evicted pages to the Host before its forward pass can write over them, so the copy adds to that step's time.
For hybrid models, --prefix-cache-evict-policy gds with explicit --prefix-cache-gds-prefill-cost D E coordinates Device and Host logical retention. It requires prefix caching after role resolution; the vision-only encode role disables that cache and rejects GDS. Enabling GDS requires an engine whose bundled scheduler supports it. Default lru and disabled checkpoint options leave optional native fields unset for older engines; explicit unsupported options fail instead of being ignored. Under write-back it reserves necessary Host copies before releasing Device addresses; this may copy additional history needed for a legal Host suffix. Pure migration and duplicate removal do not advance logical eviction watermarks. Host pressure uses the same dependency contract. Under write-through, an optional replica may be skipped to preserve another point's only recovery route; sources remain pinned until ACK. See hybrid recovery eviction. The default lru policy retains the existing retention policy. With a Disk tier, both policies reclaim safe clean Host copies before dirty entries.
GDS with Disk additionally requires --prefix-cache-gds-disk-read-cost A B, where finite A >= 0 is cost per read block and B > 0 is cost per aligned byte, in the same units as the prefill coefficients. The estimate sums unique blocks across cache groups; it does not model queue delay or SSD concurrency. Published Disk copies preserve recovery routes and lower Host placement cost; Disk itself keeps its existing LRU/retention policy and requires write-back L2. Cleaning follows current Host GDS scores, with history written before State.
See the GDS calibration tools for measuring prefill and native Disk costs, fitting D/E and A/B, and validating the coefficients before exporting configuration; native collection defaults to the eight-case cases_quick.json matrix.
write_back runs on every role. On --disaggregation-mode decode the history a decode server evicted stays reusable from its Host: a later request's remote admission loads its Host hit, and the prefill server sends only the rest (RFC 0005). Both cached and replayable sliding-window groups are supported. It requires Host L2, --pipeline-parallel-size 1, --query-context-parallel-size 1 and no --kvstore-storage-backend, and a model with at most 64 cache groups; startup refuses it otherwise, the group limit once the model's cache groups are built.
Under write_back:
- Clearing only the GPU cache, as
POST /release_memory_occupationdoes when it releaseskv_cache, loses what only the GPU holds. The Host pages that continue a prefix only the GPU held stay in Host L2: they serve hits again once a request recomputes that prefix on the GPU, and otherwise leave through Host pressure eviction./flush_cacheclears both tiers under either policy. - Not everything the GPU evicts reaches the Host: what a request releases itself, what nothing can resume from any more, and pages evicted together that the Host cannot fit as a whole are dropped.
- KV cache events keep describing the GPU cache only, so a router reading them does not see the Host's share of the reusable cache, which
write_backmakes larger. - Under attention TP, every rank copies its own part of what the engine evicts to its own Host L2 (under
--kv-parallel-size, the pages it owns), and an evicted page can be reused from the Host once every rank's copy has completed. Where every rank holds whole pages (an MLA cache without--kv-parallel-size), the ranks copy the same bytes: attention TP then multiplies the copy traffic without letting the Host hold more pages.
Elsewhere on this page, "write-back" means any copy from the GPU to Host L2, whichever policy is set, not only the copies write_back makes. How the scheduler implements the two policies is in cache concepts and, for write_back, scheduler §3.1 and, on the fused role, §3.3.
Host L2 sizing
--kvstore-size (gigabytes per rank) wins over --kvstore-ratio (a multiple of this rank's Device LCM block count, 2 by default). Host parents use compact payload geometry, so the ratio counts parents rather than allocated bytes. Use --kvstore-size to request a byte budget. A parent rounded up to whole KV pages, as described earlier, is less than one KV page larger than the largest payload, a large share when it holds few pages: with Qwen3.8-Flash-Next and FP8 KV it grows 4.3% at attention TP 1 and 2, 16% at TP 4 and 39% at TP 8, where the recurrent state keeps splitting across the ranks but the two KV heads stop at TP 2. Sizes that count parents (the ratios and the derived retraction snapshot pool) pin that much more Host memory; the gigabyte sizes keep their byte budget.
Every rank of a node pins its Host buffers at the same point of startup, so each rank checks the Host L2 and the retraction snapshot pool against an equal share of the Host memory its node has available, less --kvstore-host-headroom-gib per rank (10 GiB by default). Available means the smaller of the host's free memory and what the process's memory cgroup still allows (its limit, memory.max or memory.high on cgroup v2, less its usage with page cache counted as free; the tightest limit over its cgroup and the ones above it, found through /proc/self/mountinfo), so a container or a Slurm step is sized against its own limit; the sizing warning and the refusal name which one was used.
Each buffer counts at the size its configured pinned allocator reserves. When the CUDA/ROCm allocator supports it, the launcher sets pinned_max_round_threshold_mb:1024 as the default before starting the ranks. Allocations up to 1 GiB round to a power of two; larger buffers use their requested size. This avoids reserving 274.88 GB for a 140 GB L2 buffer. Allocators without this option keep their native defaults.
The capability probe has a 60-second timeout. Probe failures stop startup. Explicit thresholds and other allocator options are preserved. To override the default, set PYTORCH_ALLOC_CONF=pinned_max_round_threshold_mb:<MiB> before launch; the legacy PYTORCH_CUDA_ALLOC_CONF and PYTORCH_HIP_ALLOC_CONF variables take precedence, in that order. The check reads the effective allocator settings. A pinned_max_cached_size_mb limit also disables rounding above its threshold and releases those blocks when unused; it limits individual block size, not total cached bytes. Device backends without allocator snapshots retain the conservative power-of-two estimate.
On Linux, enable --kvstore-release-checkpoint-cache to ask the kernel to reclaim clean checkpoint pages before allocating the Host cache.
A ratio size larger than a rank's share is capped to the largest whole-LCM buffer that fits under those allocator settings beside its snapshot pool, with one size agreed across ranks. Each rank logs the requested and capped size. An explicit --kvstore-size may lose whole LCM blocks to keep alignment padding within its original pinned reservation, when at least one block remains. A size that still does not fit is refused at startup, as is a share without room for a single LCM block. Every rank must also resolve the same page counts: startup compares them across the ranks and refuses a difference on every rank. A size in gigabytes is a different page count wherever the ranks' LCM blocks differ in bytes, as they usually do on pipeline stages, which store different layers, so with --pipeline-parallel-size > 1 size Host L2 with --kvstore-ratio rather than --kvstore-size.
Requirements and deployment
L3 requires Host L2 (omit --disable-kvstore) and currently supports PP=1. Cyclic KV-page sharding (--kv-parallel-size) is supported when the payload is replicated within each owner subgroup; head-partitioned payloads in a sharded group are rejected at startup. Existing model and parallelism restrictions still apply. Use a scheduler built from the matching runtime source.
Deploy a Mooncake master and storage providers before starting inference. The master holds metadata; providers hold the cached bytes. Providers backed by CPU DRAM need no GPU memory. Set global_segment_size to 0 in inference workers to use those providers without mounting storage in the workers. Reuse after inference restarts requires the master and providers to retain the objects. --kvstore-size sizes each rank's Host L2, not the shared L3 capacity. Account separately for provider segments and client staging memory. A positive global_segment_size mounts storage in the inference workers; TokenSpeed divides it across attention-TP × PP ranks, using the resolved mapping.attn.tp_size, so their total matches the configured size.
Pass client settings as JSON in --kvstore-storage-backend-extra-config. For example, a client using a separate DRAM provider over RDMA:
{
"master_server_address": "store.example:50051",
"local_hostname": "10.0.0.2",
"metadata_server": "P2PHANDSHAKE",
"protocol": "rdma",
"global_segment_size": 0,
"tenant_id": "example-model",
"async": {
"max_operations": 32,
"max_keys_per_operation": 256,
"wait_timeout_ms": 2000,
"ready_timeout_ms": 1000,
"clear_cache_drain_timeout_ms": 500,
"max_prefetch_tokens": 8192,
"query_workers": 2,
"read_workers": 2,
"write_workers": 1
}
}Set local_hostname to this node's reachable address. For RDMA, validate connectivity between all clients and providers and set device_name when a specific HCA is required. The default protocol is tcp; choose rdma explicitly. Without JSON connection settings, the client reads MOONCAKE_MASTER / MOONCAKE_CLIENT and the other Mooncake environment settings. global_segment_size defaults to 4 GiB, so explicitly set 0 for clients that must not mount storage. The default tenant is default.
Asynchronous preparation before admission
Queries and GETs hold no Device pages or request-pool slots. Once a GET has retired on every owner, rows with full-length success on every owner become ordinary Host entries. The group matcher chooses the reusable prefix, which may be shorter than requested. A soft deadline permits local computation while native I/O keeps its Host references until retirement. A result detached by timeout or cancellation cannot publish data. Unknown native retirement quarantines the buffers and blocks new L3 work in that cache generation. An accepted full-clear recovery isolates those references and permits L3 in a fresh generation using remaining Host and operation capacity; it never frees the unsafe buffers merely because the clear succeeded. Valid L2 hits and ordinary computation can continue. D2H publication and Device-source release wait for replica copy agreement, independently of L3 PUT. The PD prefill role can prepare L3 hits; decode receives its missing cache from the prefill peer.
Asynchronous settings
The async object tunes this single execution path. The following table lists its defaults. Unspecified settings use these defaults, and unknown options are rejected:
| Setting | Default | Meaning |
|---|---|---|
max_operations | 32 | Outstanding operations, including undelivered completions, Ready holds, and quarantine |
max_keys_per_operation | 256 | Key limit per query, GET, or PUT |
max_host_blocks | max(1, min(256, host_blocks // 2)) | Logical Host references across operations, Ready holds, and quarantine; host_blocks is the Host pool's blocks in its densest group (the usable LCM parents times the largest packing) |
metadata_entries | max(1, host_blocks * 4) | Limit for negative-key metadata and for backup candidates |
min_prefetch_tokens | Model prefix granularity | Minimum extension beyond the local hit worth preparing |
max_prefetch_tokens | 8192 | Maximum extension beyond the local hit, rather than a prompt-length limit |
wait_timeout_ms | 2000 | Shared soft wait budget for query and GET |
ready_timeout_ms | 1000 | Hold time for completed Host results awaiting ordinary admission |
clear_cache_drain_timeout_ms | 500 | Full-clear budget for healthy outstanding L3 work to retire through normal rounds; 0 skips this wait and isolates pending work immediately |
query_workers / read_workers / write_workers | 2 / 2 / 1 | Independent executor worker counts |
failure_threshold / recovery_interval_ms | 1 / 30000 | Backend-health failure threshold and recovery-probe interval |
queue_high_operations / queue_low_operations | min(8, max_operations) / high divided by two, rounded down | Queue-count admission watermarks |
queue_high_bytes / queue_low_bytes | 268435456 / 134217728 | Queued payload-byte watermarks (256 / 128 MiB) |
operation_high_age_ms / operation_low_age_ms | 500 / 250 | Oldest queued/running operation age watermarks |
Prefetch length is also constrained by keys, Host references, and group geometry: Full history, SWA windows, and State checkpoints must fit together. Raising max_prefetch_tokens alone does not guarantee a longer restore. max_host_blocks is a logical-reference budget, not bytes or a per-worker quota, and cannot exceed host_blocks. A hybrid model's GET holds every KV page under the State checkpoint it restores, so a long prompt needs a budget of at least its KV pages up to that checkpoint, plus the checkpoint. PUTs may use at most half of the operation and Host credits, rounded down, to leave room for reads.
clear_cache_drain_timeout_ms accepts integers from 0 through (2**63 - 1) // 1000; booleans, negative values and non-integers are rejected. Use the same budget on all cooperating ranks. Clear decisions are agreed across the replica and attention-DP ranks: if any rank's budget expires, all select isolation together. An active-generation unsafe result skips healthy draining and enters recovery directly. Setting 0 changes only the wait policy; it does not claim native retirement or release unsafe references. This budget does not bound the ordinary synchronous remote namespace purge RPC.
Any high watermark closes new L3 read/write admission; all observations must reach their low watermarks before it reopens. The gate bypasses new requests' L3 preparation and drops nonowning backup candidates. Already submitted I/O keeps its lifetime and deadlines; completions, ordinary forward work, and L2 publication continue. Pressure admission and backend health are independent. See asynchronous L3 for queue and ownership invariants. The four legacy --kvstore-prefetch-* arguments are removed.
Object compatibility and maintenance
Each packed Host CacheBlock is one object, keyed as {tsl3-<sha256>}_{content_hash}|g{group}|o{page_offset}|r{object_rank}|c0. For replicated groups, object_rank is the attention-TP rank; for cyclic page groups it is tp_rank // shard_count, independent of which cyclic owner allocated the block. The literal c0 is a reserved format field. The namespace isolates loaded target/draft checkpoints, explicit weight versions, packed Host layout, parallel geometry (including ordered group shard counts for page-sharded layouts) and cache-producing runtime choices. Different compatibility epochs start cold caches. See cache concepts for the identity contract.
Host eviction leaves shared objects intact. A full clear first checks non-storage owners, then gives healthy L3 work its configured drain budget. If it retires, the normal clear purges the shared namespace. Otherwise recovery detaches old storage tickets, clears local indexes and starts a fresh cache generation while retaining every old I/O reference; this path performs no remote purge. Remaining Host and operation credits support subsequent L2, L3, and recomputation. Repeated unknown I/O can exhaust that retained capacity and still require a restart to reclaim it safely. Device/PD/tier transfers and unrelated pinned owners can still refuse clear. The normal remote purge remains a synchronous administrative RPC; neither preparation deadlines nor the healthy-drain budget bounds it, and purge failure prevents local clearing on that path. With L3 enabled, weight updates require an explicit weight_version and a successful flush; the metadata-only /update_weight_version endpoint is rejected. Independent inference jobs sharing a namespace are outside this flush agreement.
Omitting --kvstore-storage-backend creates no L3 executor, workers or SDK client. --kvstore-storage-backend memory selects an in-process test store; it is separate from Mooncake's distributed DRAM mode. The engine host loads the Mooncake store client from the Mooncake wheel's libmooncake_store.so (the store's C ABI), which tokenspeed-kernel installs; TOKENSPEED_MOONCAKE_STORE_LIBRARY names another build. CPU tests cover the scheduler, executor, and replica agreement; GPU tests cover packed-byte D2H/PUT/GET/H2D round trips. See the validation scope for native Mooncake test requirements.
Mooncake Store is the offload backend. PD KV transfer still uses the separate Mooncake TransferEngine (--disaggregation-transfer-backend). On a host whose address is IPv6, the PD transfer engine sets MC_USE_IPV6=1 (unless it is already set) so Mooncake's handshake uses IPv6. The Mooncake L3 store client reads MC_USE_IPV6 on its own when the store starts. If the L3 store runs on an IPv6 host, export MC_USE_IPV6=1 yourself.
Shared L2 pool
--shared-l2-config joins a rank to one paged pool that every rank of a deployment's prefill and fused instances uses in place of its Host L2: one cache index and one eviction policy (the Host L2's), with the bytes spread over the nodes' host memory. A prefix one rank computed is loaded by any rank on any node, straight from the pool into its GPU cache by RDMA.
Scope of the first version
Prefill and fused instances with attention TP 1 (attention DP is fine), replicated cache groups (no KV sharding: --kv-parallel-size above 1 is refused) and --pipeline-parallel-size 1. A rank passes --disable-kvstore: the pool takes the Host L2's place and the rank allocates no Host memory for it. The pool is written when a page is published, so --kvstore-write-policy stays at its default (write_back is refused). It cannot be combined with --kvstore-storage-backend or KV offloading, and --enable-memory-saver is refused: the pool's client registers the Device cache memory for RDMA once, and nothing registers it again after a memory release and resume. Peer prefix sharing (--peer-prefix-port) is refused: it needs the local Host L2 (--enable-kvstore), and the scheduler's configuration check refuses the pair as well. A DSPARK draft that needs captured-context replay is refused, as it is with the local Host L2: the Host tier cannot restore a drafter-private context. Pool ranks never retract: a fused instance runs without a retraction snapshot pool and refuses the --retraction-snapshot-* and --debug-force-retraction-interval overrides. --enable-startup-requests is refused: the flush after the startup requests clears the rank's own caches, so their prefixes would stay in the pool. Weight loads (update_weights_from_distributed, update_weights_from_disk, update_weights_from_mooncake) and forward reloads (reload_forward) are refused on a rank with a pool, with the message "a shared L2 pool holds KV of the weights and forward the server started with; restart the ranks and clear the pool instead": a rank is admitted by the checkpoint it loaded at start, and the pool would go on serving KV of the old weights or the old forward.
Owner and provider services
Two services run beside the engines (python -m tokenspeed.runtime.cache.shared_l2); nothing starts them for you. Start the owner, then the providers, then the engines.
owner: one per deployment. It serves the cache index and holds no bytes. Its service runs in the engine's host extension and logs as a rank's host does, to stderr (TS_HOST_LOGsets the level).Every flag in the following table is required:
Flag Meaning --address tcp://HOST:PORTWhere the ranks and providers reach it. There is no authentication: bind it to a cluster-internal address. --num-providers KProvider processes to wait for (a node may run several). The pool is built when all Khave joined and the first rank reports its cache geometry: the owner takes that rank's LCM block size and cuts each provider's bytes into whole blocks (a provider smaller than one block stops the pool from being built: every rank's start fails with that provider's name and both byte counts). The pool's size is fixed from then on.--headroom-lcm-blocks HWhen fewer than H/2LCM blocks are empty, a write evicts back up toHin one pass.--client-timeout-s SA rank silent for Sseconds loses its pins and reservations, and the owner answers its next request with an error, which stops the rank's engine. A rank pings the owner whenever it has had no release or touch to send for 5 seconds; a ping fails after at most the rank'srequest_timeout_ms, and the engine's loop reads the failure at the head of its next round (an idle rank runs a round about every 10 ms). A running rank that cannot reach the owner therefore stops about 5 seconds plus itsrequest_timeout_msafter the owner last heard it: keepSwell above that, so that it stops before the owner drops its pins, and well above any pause a rank process can take (the frozen rank under Known limits).--checkpoint-retention-requests R--checkpoint-retention-requestsof the scheduler, counted over the lookups of every rank together, hit or miss. A rank sends one lookup for each new prompt its own GPU cache does not cover already; a prompt it covers sends none and is not counted. A rank's own default is 16 x its batch size; for the pool use about 16 x the sum of the ranks' batch sizes.0ranks every entry by its own last use.--checkpoint-retention-leaf-distance DAs the scheduler's option of that name. provider --owner-address ADDRESS --hostname HOST --device-name NICS --bytes B: one or more per node, each a process hostingBbytes of pool memory registered for RDMA on the NICs it names. A provider announces its memory once, at start, and the owner counts every announcement as one provider: a provider that is started again counts as one more until--num-providershave joined, and is refused after that. The owner cannot tell that the earlier one's memory is gone, so restart the owner together with a provider.A provider does not bind its CPUs or memory to a NUMA node. On a node with several NUMA domains, run one provider per domain under
numactland give it the NICs of that domain (cat /sys/class/infiniband/NIC/device/numa_node), so that a provider's memory and the NICs that read and write it are in one domain.--num-providerscounts each of these processes.The following example starts one provider for each of two NUMA domains. Replace
HOST:PORTwith the owner address,NODEwith the node's reachable hostname,Bwith the provider's memory size in bytes, and the example NIC names with the NICs for each NUMA domain:bashnumactl --cpunodebind=0 --membind=0 python -m tokenspeed.runtime.cache.shared_l2 provider \ --owner-address tcp://HOST:PORT --hostname NODE --device-name mlx5_0,mlx5_1 --bytes B numactl --cpunodebind=1 --membind=1 python -m tokenspeed.runtime.cache.shared_l2 provider \ --owner-address tcp://HOST:PORT --hostname NODE --device-name mlx5_2,mlx5_3 --bytes B
The owner keeps everything in memory, and a provider announces its memory only when it starts: a restarted owner waits for new providers and knows none of the ranks that joined the owner before it. A restart of the owner is therefore a restart of the providers and of the ranks too: stop the ranks, the owner, and the providers, then start the owner, the providers, and the ranks again. A rank that is still running when its owner goes away stops by itself, at its first request the owner does not answer.
A provider that is stopped or killed stops the ranks that use it: a load whose RDMA read fails and a write whose RDMA copy fails each stop the rank's engine and, under attention DP, its whole instance.
A rank that is stopped or restarted does not release what it holds at the owner. The owner drops that client's pins and reservations once it has been silent for --client-timeout-s, which it checks every quarter of that time. Until then the pages they cover are not evicted. A restarted rank joins the pool as a new client.
Shared L2 pool flushing
The engine's cache flush clears a rank's Device cache and leaves the pool as it is. To empty the pool, send the owner clear. Replace HOST:PORT with the owner address:
python -c "from tokenspeed.runtime.cache.shared_l2.wire import OwnerConnection as C; print(C('tcp://HOST:PORT', timeout_ms=5000).request('clear'))"It answers cleared: False and changes nothing while a rank holds pins or reservations. Those of a rank that is gone count until the owner has dropped them: after stopping the ranks, clear succeeds within 1.25 x --client-timeout-s. request('stats') shows the pool's counters, its providers and how many ranks have joined.
Shared L2 pool sizing
The pool is laid out as a rank's compact Host L2: one LCM block is as large as the largest block of any cache group, a KV group packs as many pages into a block as fit, and a State checkpoint takes one LCM block for each State group. A pool therefore holds about pool bytes / (State groups x LCM block bytes) checkpoints, less the blocks its KV pages take. A rank logs the block size when it joins (shared L2 client ... joined: ... LCM blocks of N bytes). Measured on K3 with attention DP: an LCM block of about 143 MiB and about three LCM blocks (about 429 MiB) a checkpoint, so about 150 checkpoints in a 64 GiB pool.
Shared L2 pool configuration
The following JSON example shows a rank's shared L2 configuration. Replace HOST:PORT with the owner address and the example RDMA device names with the devices for your local GPUs:
{"owner_address": "tcp://HOST:PORT",
"device_names": ["mlx5_0,mlx5_1", "mlx5_0,mlx5_1"],
"request_timeout_ms": 2000, "join_timeout_s": 600,
"read_workers": 4, "write_workers": 4,
"scheduler": {"max_writes_in_flight": 4, "max_keys_per_write": 512}}The following table describes every field in the rank's JSON configuration:
| Field | Meaning |
|---|---|
owner_address | The owner's address. |
device_names | A list: the RDMA devices of each local GPU index, as Mooncake names them. Name the fastest GPU-side NICs. |
request_timeout_ms | How long a request may wait for the owner's answer, from the moment the rank sends it. A request that passes it has failed, which stops the rank's engine: set it above the longest pause the owner can have. A lookup holds the rank's scheduling until it is answered or has failed, for up to this long. |
join_timeout_s | How long a starting rank waits for the pool to be ready; the rank fails to start after it. |
read_workers | Threads reading one load's providers in parallel. A layer is read with one request for each provider that holds its pages, so more threads than providers are never busy. |
write_workers | Threads writing newly published blocks to the pool. |
scheduler.max_writes_in_flight, scheduler.max_keys_per_write | Writes in flight at once, and blocks in one write; Device blocks stay pinned only while their write is in flight. |
Before it plans a round, the engine's loop sends the owner one request with the lookup of each waiting prompt that has none yet, and waits for the answer. A prompt the pool holds no prefix of is a miss and is computed.
A write reserves pool pages for newly published blocks, copies the blocks by RDMA and commits them. A block the owner gives no page (the pool holds it, another rank is writing it, or the pool has no room) is skipped. A rank tells the owner when it is done with a hit (a release) and when it reuses blocks of its own GPU cache that the pool holds too (a touch), and pings it whenever it has had neither to send for 5 seconds.
With --kv-events-config, a pool rank reports the Host entries that stand for the pages of a hit with the Host medium (CPU_PINNED) for as long as it holds the hit, although the bytes are in the pool.
Shared L2 pool failure behavior
A starting rank repeats its hello until the pool is ready; after the join no request is sent twice, and a rank does not serve without its pool. Each of these failures stops the rank's engine, as a failed forward does; under attention DP the other ranks of the instance stop with it (they report that a rank left the mesh):
| What fails | How |
|---|---|
| A lookup | The owner does not answer within request_timeout_ms (after a restart of the owner too: the rank's next request leaves on the connection to the earlier owner and is lost), answers with an error (an owner that does not know the rank answers so: it dropped the rank after --client-timeout-s of silence), or answers with anything but one well-formed hit for each prompt. A failed lookup is never taken for a miss. |
| A write | Its reservation or its commit is not answered within request_timeout_ms or is answered with an error, or its RDMA copy fails (a dead provider included). |
| A release, a touch, or a ping | It is not answered within request_timeout_ms or is answered with an error. |
| A load of an admitted prompt | A provider died or an RDMA read failed (reported after the RDMA retries, some seconds), or a hit named a page the pool does not have (refused before any read). The forward already depends on the pages; none of its results is returned. |
The engine's loop reads a failed write, release, touch or ping at the head of its next round, before that round plans, on an idle rank as on a serving one.
Known limits
- An owner that is paused or unreachable for longer than
request_timeout_msstops every rank that uses the pool. - After a restart of the owner every rank has to be restarted.
- A rank process that is frozen for longer than the owner's
--client-timeout-sloses its pins and reservations at the owner. After it resumes, and until its next poll or request to the owner fails and stops it, a load may read pool pages that now hold another rank's blocks, and a write that was in progress may finish into pages the owner has since given to another rank. That rank's entry then serves wrong KV to every rank that hits it, until it is evicted. Nothing in the engine guards against this: keep--client-timeout-swell above any pause a rank process can take, and send the ownerclearafter a rank was frozen for that long.
The owner admits a rank by two checks: its cache geometry (prefix page, group kinds and packing, LCM block bytes) and its deployment identity, the one L3 names its objects under (checkpoint, cache layout and quantization, attention backends, and runtime compatibility). The first rank sets both; a rank that differs is refused at start.
A load reads the pool pages layer by layer, read_workers providers at a time, and the forward waits per layer as for a Host L2 load. It needs GPUDirect RDMA writes ordered for the GPU that owns the memory and CUDA stream memory operations; a rank refuses to start on a device without either.
Not in this version: a pool that survives its owner, providers joining a running pool, a quota per rank, one pool for several models, KV sharding, and attention TP above 1.
Peer prefix sharing
--peer-prefix-port PORT lets replicas reuse each other's cached prefixes (design: RFC 0004). A request the router sends with a holder (peer_holder, the holder's host:port) asks that replica for a recoverable prefix. The reader fetches missing pages into Host cache. Ordinary prefill admission allocates Device pages for load-back and the remaining prompt. Every replica serves its own cache the same way. If the holder does not answer, or a read fails, the request computes the prefix itself.
Peer prefix sharing configuration
The following table lists the peer prefix sharing flags and their defaults:
| Flag | Default | Meaning |
|---|---|---|
--peer-prefix-port | off | One public peer control port per node, shared by its attention-DP ranks. |
--peer-prefix-host | detected | The host others reach the endpoint at. Rank zero is named host:PORT and rank r > 0 is named host:PORT/r, and a holder hint must name it exactly so. |
--peer-prefix-answer-timeout-ms | 50 | How long a request waits for each of the holder's answers (lookup, pin, release). |
--peer-prefix-min-fetch-tokens | 256 | Minimum possible gain over the local prefix needed to issue a lookup. A valid reply can extend the prefix by fewer tokens. |
--peer-prefix-landing-tier | required on readers | Prefill and fused readers use host. Omit on decode-only holders. Older Decode launchers may still pass device or host. |
--peer-prefix-max-host-landing-size | half the usable Host L2 size | Maximum decimal GB per reader rank (1 GB = 10⁹ bytes). In-flight and ready landings share this budget. Values at or above the usable L2 capacity allow the full pool. Omit on decode-only holders. |
Peer prefix sharing requirements
Peer sharing requires prefix caching. Prefill and fused workers also require Host L2 (--enable-kvstore). A Decode worker receives its prompt through the PD path and offers the prompt and generated tokens to subsequent Prefill requests. With Host L2 enabled, use --kvstore-write-policy write_back to retain pages evicted from Device.
A TP1/KVP1 Decode worker can serve device-resident prefixes with --disable-kvstore and a configured --peer-prefix-port. Omit the Host write-back policy in this mode. A TP8/KVP8 Prefill worker can read the resident history, including draft cache fields. Once the Decode worker evicts those pages, it cannot serve them.
Peer sharing is refused with --kvstore-storage-backend, --pipeline-parallel-size > 1, --query-context-parallel-size > 1. KV-page sharding requires the sharded peer protocol. RDMA devices come from --disaggregation-ib-device. Replicas read each other within one namespace when their configured model and draft revisions, cache layout, and numerical settings are compatible. Deploy the same weights on all peers and identify each generation with the same --weight-version. At startup, rank 0 warns if the version is left at its default and any loaded target or draft revision is unpinned. Live peers trust the configured versions. A flushed weight update must name its weight_version, which moves the namespace, as it does for L3.
With --enable-memory-saver, the supported configuration is Ascend Prefill or Decode with a single member per replica (attention TP1/KVP1), Device landing and local cache tiers. It uses a model recipe with a transferable cache ABI, DFlash draft retention, target weight discard and an explicit weight version with the WeightStore updater. After releasing Peer KV, call resume_scheduler after restoring all memory regions on both P/D endpoints. Separate calls to restore KV and graph memory leave scheduler dispatch paused.
Local Disk tier
--disk-tier-paths DIR [DIR ...] caches prefixes on the node's local SSD below Host L2 (design: RFC 0006). Each rank keeps one file in one of the directories, sized by --disk-tier-size-gb. Host L2 writes the entries the GPU evicted into it in the background, and a prompt whose prefix only the file holds waits while it is read back into Host, then is admitted as a Host hit. The file is recreated empty at every start: its contents never outlive the process. The directories must be on a file system that supports O_DIRECT (XFS or ext4, not tmpfs).
Local Disk configuration
The following table lists the local Disk flags and their defaults:
| Flag | Default | Meaning |
|---|---|---|
--disk-tier-paths | off | One directory per drive; ranks spread over them. |
--disk-tier-size-gb | — | The file's size per rank, in gigabytes. |
--disk-tier-io | required | io_uring, or psync (a thread pool calling pread/pwrite) where io_uring is unavailable. |
--disk-tier-write-mbps | required | The MB per second each rank may write: the SSD's endurance budget. Reads are never throttled and go first. |
--disk-tier-config | — | A JSON object with the tuning keys in the following table. |
Disk tier tuning settings
The following table lists the --disk-tier-config tuning keys and their defaults:
--disk-tier-config key | Default | Meaning |
|---|---|---|
queue_depth | 32 | Requests in flight on the drive; with psync, threads. |
write_queue_depth | 8 | Of those, at most this many writes. |
max_io_bytes | 4194304 | Longer ranges are issued as several requests; a multiple of 4096. |
max_operations | 16 | Disk operations in flight, reads and writes. Cleaning writes are capped at max(1, max_operations / 4) concurrent operations, and one operation is reserved for reads when max_operations > 1. |
max_blocks_per_operation | 4096 | Blocks one operation moves. |
host_blocks_fraction | 0.25 | The share of Host L2 blocks Disk operations may hold at once. |
write_host_blocks_fraction | 0.5 | Of those, the share writes may hold; also derives the Host clean-reserve watermark (in whole LCM parents) below which background cleaning runs. |
max_queued_cleanings | 65536 | Deprecated compatibility field (must remain positive); cleaning discovers dirty Host entries directly from residency under both GDS and LRU. |
min_prefetch_tokens | 256 | The fewest tokens past the local hit worth a read. |
wait_timeout_ms | 10000 | How long a prompt waits for its read before it runs from the local hit. |
ready_timeout_ms | 5000 | How long a finished read is held for its prompt. |
push_ring_mb | 512 | With --peer-prefix-port, the staging memory a peer push reads Disk blocks into, rounded up to whole blocks. |
min_clean_tokens | 0 | Minimum prefix branch length (in tokens) required to clean a Host tip to Disk when the branch length is known; 0 disables the length filter. |
require_reuse_for_cleaning | false | When true, skip cleaning Host tips that were never reused after initial publication. |
Disk tier requirements and behavior
The Disk tier needs --kvstore-write-policy write_back and prefix caching, and is refused with --kvstore-storage-backend and --pipeline-parallel-size > 1. With it, every Host block is padded to a multiple of 4096 bytes so each one moves in one direct I/O. With peer prefix sharing, a replica serves the prefixes its Disk tier holds too: it pushes them into the reader's landing, reading each block into a staging ring and writing it over RDMA as soon as it is read. A cache flush or weight update waits up to 30 s for the Disk operations in flight to finish, and fails if one does not.
Disk tier metrics
With --enable-metrics, every rank exports the tier's state. The scheduler's counts are the same on every rank of a replica; do not sum them across TP ranks.
The following table lists the Disk tier metrics:
| Metric | Labels | Meaning |
|---|---|---|
tokenspeed:disk_scheduler_resources | resource | disk_blocks, free_disk_parents, operations, held_host_blocks, queued_cleanings (compatibility gauge, always 0 under residency cleaning), waiting_requests, ready_requests. |
tokenspeed:disk_blocks_total | direction, result | Blocks written or read (success), failed (failure), or cleaning candidates truncated/cancelled before Disk publication (write, skipped). |
tokenspeed:disk_read_expirations_total | phase | Reads a prompt stopped waiting for (waiting), or did not take in time (ready). |
tokenspeed:disk_io_bytes_total | direction | Bytes this rank moved to and from its file. |
tokenspeed:disk_io_queued_bytes | state | queued_read, queued_write (including what waits for the write budget) and inflight bytes. |
tokenspeed:disk_io_failed_jobs_total | Executor jobs that failed on this rank. | |
tokenspeed:disk_job_seconds | direction, stage, outcome | Each Disk operation's executor job on this rank: queued until its first request reached the kernel (behind reads, other jobs, and the write budget), and total until it reported. |
A /start_profile trace shows each Disk operation on a Disk read or Disk write row from submission to report, with its queued part; a holder's pushes on Peer push rows, with each block's RDMA write; and a reader's landings on Peer landing rows, phase by phase.