mlx-bun library API
    Preparing search index...

    Recurrent storage behind the same row-layout port as attention KV. Inputs to merge are borrowed; request membership is owned by the caller.

    Hierarchy (View Summary)

    Implements

    Index
    offset: number = 0
    offsets: number[] | null = null

    Per-row token coverage (batch lane only; null on serial B=1 caches, where offset IS the row's count). mlx-lm's ArraysCache tracks no offset at all (cache.py:594-722) — per-sequence coverage is the server's bookkeeping; ours lives here because prompt-cache put() keys on EXACT coverage (#putOrDispose offset === tokens.length) and merged rows carry different totals. Seeded by mergeRows, advanced in lockstep by advance(), row-filtered by filter().

    prefillPadding: SsmPrefillPadding | null = null
    specRound: SsmSpecRound | null = null

    Live speculative verify round; null outside a verify transaction.

    • Row i as a fresh SERIAL cache — port of mlx-lm ArraysCache.extract (cache.py:673-676: cache.cache = [c[idx : idx + 1] for c in self.cache], a B-axis slice of every state slot). A proper subset gets compact storage so retaining one row does not pin the other rows. A singleton retains an independent handle over its complete allocation. Offset = the row's OWN coverage, not the shared max.

      Parameters

      • i: number

      Returns SSMCache

    • 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.

      Returns string

    • Speculative 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().

      Returns void

    • 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.

      Parameters

      • _n: number

      Returns void

    • Merge a fully-prefilled solo row into a running batched cache (prev null ⇒ the solo row becomes the batch). The returned cache owns fresh arrays — or, when there is nothing to concat, arrays STOLEN from solo (nulled there so the scheduler's unconditional dispose of the solo caches stays safe). prev/solo disposal remains the caller's job.

      Parameters

      Returns SSMCache