mlx-bun library API
    Preparing search index...

    What the shared token executors (the batch group, its preparation cohorts, the autoregressive binding) consume from a resident graph, whatever family it is: caches, the named phases (tokenPhasesOf), weights for the wired-limit scope, and the ports its declaration promises. A graph outside the model registry satisfies it structurally.

    interface MlxTokenGraph {
        adaptiveDraftGates?: ReadonlyMap<string, AdaptiveDraftGateSettings>;
        adaptiveDraftWidths?: ReadonlyMap<string, number>;
        appendKnown?: MlxKnownOperations;
        cacheLayers?: readonly MlxCacheLayer[];
        composition?: Composition;
        config: ModelConfig;
        decode?: Readonly<
            Partial<Record<number, MlxCapturingForward>> & {
                default?: MlxCapturingForward;
            },
        >;
        embed?: { encode(ids: MlxArray): MlxArray };
        embeddingPrompt?: readonly MlxEmbeddingsRange[];
        expertRuntime?:
            | {
                finishUsage?: () => Promise<void>;
                flushUsage?: () => void;
                plan: { plannedBytes: number };
            }
            | null;
        graphCapabilities: GraphDeclaration;
        knownSpans?: MlxKnownSpans;
        logits?: Readonly<
            Partial<Record<number, MlxHeadForward>> & { default?: MlxHeadForward },
        >;
        loraState?: { active: string[] };
        mixed?: readonly MlxMixedRange[];
        mixedSeparate?: MlxSeparateMixed;
        multiSequencePrompt?: readonly MlxPromptRange[];
        multiSequencePromptChunk?: readonly MlxPromptRange[];
        prompt?: readonly MlxPromptRange[];
        promptChunk?: readonly MlxPromptRange[];
        sequence?: readonly MlxSequenceRange[];
        sequenceLogits?: readonly MlxHeadRange[];
        trainable?: TrainableGraph;
        verify?: Readonly<
            Partial<Record<number, MlxCapturingForward>> & {
                default?: MlxCapturingForward;
            },
        >;
        verifyRoundCosts?: ReadonlyMap<number, number>;
        weightsBytes: number;
        wiredWeights?: boolean;
        bindMediaInput?(input: Vision): MlxPromptInput;
        compiledDecodeStep?(): MlxCompiledDecodeStep;
        dispose(): void;
        draftTarget?(caches: Cache[]): TargetView;
        embedPooled?(ids: MlxArray): MlxArray;
        expertResidency?(): Record<string, unknown> | null;
        makeCache(): Cache[];
        mediaEncoders?(
            modelDir: string,
            probes: MediaSidecarProbes,
        ): Promise<MediaEncoders>;
        nativeDraftHead?(): NativeMtpHead;
        pixelInput?(): PixelInput | null;
        prefillEmbeddings?(
            embeddings: MlxArray,
            state: Cache[],
            imageMask: MlxArray | null,
            ids: MlxArray,
            multimodalMask: MlxArray | null,
            width: number,
        ): MlxArray;
        releaseCompiledDecode?(): void;
    }

    Hierarchy (View Summary)

    Index
    adaptiveDraftGates?: ReadonlyMap<string, AdaptiveDraftGateSettings>

    The adaptive draft gate's settings per draft provider kind, measured on the hardware it serves (an adaptive drafter of a listed kind gates with them). Absent, or a kind it does not list: the gate's defaults.

    adaptiveDraftWidths?: ReadonlyMap<string, number>

    The widest adaptive round per draft provider kind, measured on the hardware it serves: an adaptive drafter of a listed kind drafts up to it instead of its own width, unless the request names a width. Absent, or a kind it does not list: the drafter's own width.

    appendKnown?: MlxKnownOperations
    cacheLayers?: readonly MlxCacheLayer[]

    One cache per cache layer: the caches the composition's KV scheme names (composedFullAttentionCache, composedSlidingAttentionCache).

    composition?: Composition

    The served configuration the graph was built for; absent for a graph that composes no KV scheme (its caches are its own).

    config: ModelConfig
    decode?: Readonly<
        Partial<Record<number, MlxCapturingForward>> & {
            default?: MlxCapturingForward;
        },
    >
    embed?: { encode(ids: MlxArray): MlxArray }

    Unscaled token embeddings, for media prompts that splice embeddings.

    embeddingPrompt?: readonly MlxEmbeddingsRange[]

    Prepared embeddings without explicit positions, indexed by total rows.

    expertRuntime?:
        | {
            finishUsage?: () => Promise<void>;
            flushUsage?: () => void;
            plan: { plannedBytes: number };
        }
        | null
    graphCapabilities: GraphDeclaration
    knownSpans?: MlxKnownSpans

    Committed known-token spans, declared when the composition qualifies them (appendKnown then reads committed).

    logits?: Readonly<
        Partial<Record<number, MlxHeadForward>> & { default?: MlxHeadForward },
    >
    loraState?: { active: string[] }

    The mounted-adapter selection; absent when the graph mounts none.

    mixed?: readonly MlxMixedRange[]

    Mixed rows in one forward, declared by a composition that serves them.

    mixedSeparate?: MlxSeparateMixed

    Mixed groups that retain their own projection geometry. The scheduler routes each group independently when a verify group is present.

    multiSequencePrompt?: readonly MlxPromptRange[]
    multiSequencePromptChunk?: readonly MlxPromptRange[]
    prompt?: readonly MlxPromptRange[]
    promptChunk?: readonly MlxPromptRange[]

    Optional chunk bindings when a file distinguishes chunks from prompt tails.

    sequence?: readonly MlxSequenceRange[]

    Full-sequence scoring operations, indexed by total token rows.

    sequenceLogits?: readonly MlxHeadRange[]
    trainable?: TrainableGraph

    What the trainer consumes: the head, segmented backward, prefix sharing, gradient checkpointing, flash-attention constraint and denoising objective this graph implements. Undeclared parts make the trainer refuse.

    verify?: Readonly<
        Partial<Record<number, MlxCapturingForward>> & {
            default?: MlxCapturingForward;
        },
    >
    verifyRoundCosts?: ReadonlyMap<number, number>

    Measured cost of a verify forward by its row count, relative to one single-row decode step (rows 1 = 1). Declared only by a graph measured on the hardware it serves; speculative depth scheduling reads it.

    weightsBytes: number
    wiredWeights?: boolean

    The graph's composition measured that its weights are wired for a generation whatever their share of the recommended working set; absent: the share decides.

    • Release what the graph built at construction (computed constants, Neural Engine programs, its own weight source where it opened one) once every execution and compiled runner has stopped. A graph that built nothing releases nothing. Its owner (the host, a draft provider) calls it before releasing the weights it supplied.

      Returns void