mlx-bun library API
    Preparing search index...

    Recurrent cache for a gated-DeltaNet layer — port of mlx-lm cache.ArraysCache(size=2): slot 0 = causal-conv state [B, K-1, conv_dim], slot 1 = recurrent state [B, Hv, Dv, Dk] f32. recurDecode and recurWindow own both slots and the kernels that update them (GatedDeltaCache); the DeltaNet block hands them its projections. advance(N) only tracks token count for B=1 single-stream (lengths / left_padding are batched-decode concerns). Not a key/value cache: no KV scheme converts it.

    A rolled-back speculative round leaves the snapshot in the slots and its retained window rows pending; they fold in (the state-only kernel over the recorded rows, and the convolution tail) the next time anything reads the state: the next forward, state(), the slots, row moves or persistence. The rollback itself builds no graph.

    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.

    • Methods may retain different verified prefixes for each active request.

      Parameters

      • counts: readonly number[]

      Returns void

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

      Returns number

    • 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