mlx-bun library API
    Preparing search index...

    Affine-quantized keys and values for one sliding-window layer, bf16 first: the rotating counterpart of Bf16FirstQuantizedKVCache, with the same numbers, transition and obligations. Storage is a RotatingKVCache of maxSize until an append leaves it holding at least start positions, then converts (RotatingKVCache.toQuantized: the ring as laid out, its write index carried) into a RotatingQuantizedKVCache, whose own reads serve every later append. Every written ring position equals the convert-after path's bit for bit.

    Implements

    Index
    • Parameters

      • maxSize: number

        The sliding window: the ring's capacity and the window every read applies.

      • groupSize: number
      • bits: number
      • start: number

        Positions held in bf16 before the conversion; 0 converts after the first append.

      • kernelSet: AffineKernelSet

        The affine kernel set the converted storage attends with, named by the composition (composedAffineKernels).

      • masks: AttentionMasks = ...

        The per-forward masks of the model this cache belongs to.

      • Optionalstorage: Cache

      Returns Bf16FirstRotatingQuantizedKVCache

    bits: number
    composed: ComposedStorage = ...

    The storage the row layouts, clones and saved files take.

    groupSize: number
    kernelSet: AffineKernelSet

    The affine kernel set the converted storage attends with, named by the composition (composedAffineKernels).

    masks: AttentionMasks = ...

    The per-forward masks of the model this cache belongs to.

    maxSize: number

    The sliding window: the ring's capacity and the window every read applies.

    start: number

    Positions held in bf16 before the conversion; 0 converts after the first append.

    • Window: L new positions per row, causal within the window, for prefill chunks, prefill tails and speculative verify windows. Query i of a row sees the row's earlier valid positions and window positions 0..i, limited to the cache's sliding window. Left padding and prepared prefill padding are never visible. Outputs at padded query positions are unspecified and the caller ignores them. To append context without attending, make this call and dispose the read unused.

      Parameters

      Returns AttentionRead

    • 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

    • 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
      • Optionalbypass: boolean

      Returns void