mlx-bun library API
    Preparing search index...

    The graph's operations and construction facts. Pooled embedding support is declared by its operation alone. Other operations accompany the promises in graphCapabilities; composition checks their pairing when it binds (declaredGraph).

    Implements

    Index
    cacheLayers: readonly MlxCacheLayer[]
    cachePaging: true

    One cache per layer, the lego the composition's KV scheme names for it (bf16, bf16-first affine, per listed layer under a per-layer scheme, or TurboQuant on full-attention layers, read deferred as Gemma 4 reads it), a ring of the sliding window on sliding layers, all sharing one mask memo; under the composition's paging the full-attention layers hold pages of what the scheme names (maybePageKv, growing from one block). The encoder prefill fills them, the decoder canvas pass reads them.

    canvasLength: number
    config: ModelConfig
    denoisingAppend: readonly MlxDenoisingAppendRange[]
    denoisingDecode: readonly MlxDenoisingDecodeRange[]
    denoisingPrefill: readonly MlxDenoisingPrefillRange[]

    Unscaled token embeddings, for media prompts that splice embeddings.

    embedScale: number
    encoderLayerScalars: MlxArray[]
    finalNorm: RMSNorm
    imageTokenId: number
    layers: DiffDecoderLayer[]
    loraState: LoraState = ...
    makeCache: () => Cache[]

    The graph binds compiled GeGLU and softcap closures, matching the reference's mx.compile'd operations.

    prefixBase: "model.decoder"
    selfConditioning: SelfConditioning
    slidingWindow: number
    softcap: number
    visionTower: DiffusionVisionTower | null

    Dedicated DiffusionGemma SigLIP vision tower (image-text-to-text).

    weightsBytes: number
    • Decoder canvas pass over an on-device canvas: embed canvas -> 30 layers, each reading its cache through the block read (the cache builds the reference _make_decoder_masks sliding mask and keeps the newest sliding_window - 1 encoder positions) -> final norm. Returns hidden [1, canvasLength, hidden]. The D2 engine drives this per denoising step (canvas stays on-device).

      Parameters

      • canvasArr: MlxArray
      • cache: Cache[]
      • scLogits: MlxArray | null = null
      • scEmbeddings: MlxArray | null = null
      • layers: readonly {
            forward: (
                x: MlxArray,
                cache: Cache,
                read: PassRead,
                offset: number,
                layerScalar: MlxArray | null,
            ) => MlxArray;
        }[] = ...

      Returns MlxArray

    • Image-text-to-text encoder prefill: merged embeddings through all layers, each reading through the encoder window (causal over the whole prompt, no sliding window, image positions both ways; reference _make_encoder_masks + _vision_block_overlay, one mask for every layer), filling cache. The canvas decoder then reads it like the text path.

      Parameters

      • splicedIds: number[]
      • pixels: MlxArray
      • cache: Cache[]
      • layers: readonly {
            forward: (
                x: MlxArray,
                cache: Cache,
                read: PassRead,
                offset: number,
                layerScalar: MlxArray | null,
            ) => MlxArray;
        }[] = ...

      Returns void

    • Re-prefill the encoder over an accepted canvas block (continuation), so the next block's decoder sees it as context. Appends to the existing cache.

      Parameters

      • canvasArr: MlxArray
      • cache: Cache[]
      • layers: readonly {
            forward: (
                x: MlxArray,
                cache: Cache,
                read: PassRead,
                offset: number,
                layerScalar: MlxArray | null,
            ) => MlxArray;
        }[] = ...

      Returns void