ReadonlybatchRows in the layout, or null before the first append.
Optional ReadonlycomposedPresent on a cache that composes the storage it holds (see ComposedStorage).
ReadonlykvReadonlyleftOptionalminimumEarliest prefix whose retained representation can resume generation. Irreversible transitions may preserve bytes while invalidating older precision boundaries. Reuse policy must not trim below this offset.
Optional ReadonlyprefillA preparation method commits each request's own precision boundary. Splitting a forward for a sibling must not move that boundary.
ReadonlyropeOptional ReadonlyropeCompiled-decode trace adapters expose the RoPE offset as an int32 array input here; real caches leave it unset (static int path).
ReadonlyrowOptional Readonlystatestate() returned temporary views that the caller must release.
Appends L positions per row (latent [B, L, kvLoraRank], rope
[B, L, ropeHeadDim], and indexKeys [B, L, indexHeadDim] exactly when the
cache stores them), advancing every row by L, and returns the state as of
this append. A rejected append leaves the cache unchanged.
OptionalbytesPhysical cache storage consumed by one additional token for one row. Recurrent caches return 0 because their state does not grow with the sequence. Optional for stateless/training adapters that are never admitted or persisted.
OptionalcaptureOptionalcaptureCan trim(n) drop the last n tokens? (Ring caches lose trimability
once wrapped.)
OptionalmaxMaximum committed positions before this state changes precision.
Stable storage identity for compatibility guards and persistence. REQUIRED: every capability predicate (isPlainKvCache, isRotating*, packages/inference/src/state/persistence.ts codecs) is a string compare on this value, so a missing override used to fail OPEN into wrong routing (PRs #42/#43: BatchedRotatingCache shipped without one and batched joins dropped running rows). Wrappers report their own kind plus the inner kind.
OptionalspecSpeculative verify-round support for NON-trimmable recurrent caches
(SSMCache — gated-DeltaNet conv + recurrent state). A cache exposing
these is spec-eligible without isTrimmable(): the serve loop arms a
round before the verify forward (the layer snapshots pre-round state —
free, MLX arrays are immutable — and records its position-local kernel
inputs), then resolves it: commit on full accept, or rollback(keep)
which restores the snapshot and bit-exactly REPLAYS the first keep
window tokens through the recurrence (identical arithmetic prefix ⇒
identical state). Trimmable caches leave these unset and keep trim().
OptionalspecOptionalspecThe index keys stored so far, [B, offset, indexHeadDim], owned by the caller; null when none are stored (a cache without DSA, or an empty one).
Drop the last n tokens (future writes overwrite them). bypass (default
false → unchanged behavior) skips the isTrimmable guard for the
speculative-decode rollback case (trim the last n ≤ γ tips right after a
1 concat write); rotating caches then physically shrink the buffer tail.
Optionalbypass: boolean
State for one multi-head latent attention layer (GLM-5.2's MLA): it stores the checkpoint-native compressed state per position (the latent and the decoupled RoPE key, and on a sparse-attention layer the DSA index key), never per-head keys and values. The attention block projects its queries and that state, appends the state here and reads back everything stored, from which it reconstructs or absorbs keys and values itself (the same split as GatedDeltaCache: the block keeps its projections, the cache keeps the state and its row layout). A layer composed with DSA appends an index key with every position and reads the index keys stored before its append to select positions.
Rows: one row for a single sequence; a batch keeps its rows right-justified along the sequence axis,
rowOffsets[b]positions in rowbstarting atleftPad[b]. Inputs to an append are borrowed and float32.