mlx-bun library API
    Preparing search index...

    Per-layer block arena, mlx-owned (ops.zeros — no host-pointer alignment/dtor hazards), every plane shaped [numBlocks, H, blockSize, width]. bf16 pages: keys and values. Affine pages: packed keys and values with their scales and biases. TurboQuant pages: the codec's five codes, key indices in keys, key scales and zero points in keyScales and keyBiases, value indices in values, value scales in valueScales. alloc()/free() manage physical slot indices; the owning PagedKVCache writes/gathers through the pool.

    Index
    • Parameters

      • opts: {
            blockSize: number;
            dtype: Dtype;
            headDim: number;
            numBlocks: number;
            numKvHeads: number;
            quantization?: PagedQuantization;
            turbo?: { fusedDecode: boolean; kBits: number; vBits: number };
            vHeadDim?: number;
        }
        • blockSize: number
        • dtype: Dtype
        • headDim: number
        • numBlocks: number
        • numKvHeads: number
        • Optionalquantization?: PagedQuantization
        • Optionalturbo?: { fusedDecode: boolean; kBits: number; vBits: number }
        • OptionalvHeadDim?: number

          V head dim when it differs from K's (attention_k_eq_v models don't reach v1's gemma4 scope, but the pool stays shape-honest).

      • Optionalsource: BlockPool

      Returns BlockPool

    blockSize: number
    dtype: Dtype
    headDim: number
    keyBiases?: MlxArray
    keys: MlxArray
    keyScales?: MlxArray
    numBlocks: number
    quantization?: PagedQuantization
    turbo?: { fusedDecode: boolean; kBits: number; vBits: number }

    TurboQuant pages' bit widths.

    valueBiases?: MlxArray
    values: MlxArray
    valueScales?: MlxArray
    vHeadDim: number
    • TurboQuant pages: the first length positions of blockTable's blocks, decoded by the codec with values in their own domain or left rotated (TurboQuantKVCache's decode, per position). Caller owns both.

      Parameters

      • blockTable: number[]
      • length: number
      • rotated: boolean

      Returns [MlxArray, MlxArray]

    • Write k/v ([1, H, l, D], l ≤ blockSize − within) into physical block physIdx starting at row within. Functional slice_update: the pool tensors are single-referenced here, so mlx donates the buffer and the write is in-place in the steady state.

      Parameters

      Returns void