mlx-bun library API
    Preparing search index...

    Affine KV uses the same row-position storage operations for its packed values, scales and biases. No dequantization or requantization is needed for merge, rollback, retirement or extraction. Inputs share this codec.

    Reads: append through updateAndFetchQuantized, then the kernel kernels fixed for the read at construction. While every row is unpadded and at one position, decode passes no mask and a window the bottom-right causal matrix, as makeMask leads the graphs to today; otherwise both pass the per-row mask (causal, past each row's left padding) for their query count, built once per forward through masks, and a window takes the masked-window kernel. The kernels are kernels while the layout holds one unpadded row and its multiRow set otherwise (rowLayoutKernels); rows it extracts keep kernels. The committed read is quantizedAppendAttention, for one row.

    Implements

    Index
    bits: number
    groupSize: number
    kernels: AffineKernels

    The kernel of each read; empty batches and extracted rows keep them.

    masks: AttentionMasks = ...

    The per-forward masks of the model this layout serves.

    • 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

      • count: number

      Returns void