mlx-bun library API
    Preparing search index...

    Child-local native resources. The parent job host owns the execution lease.

    interface FinetuneRuntime {
        createModel: {
            <Model>(
                weights: Weights,
                config: ModelConfig,
                composition: Composition | undefined,
                resolved: ResolvedModelProfile | undefined,
                implementations: ModelImplementationProvider<Weights, Model>,
            ): Model;
            (
                weights: Weights,
                config: ModelConfig,
                composition?: Composition,
                resolved?: ResolvedModelProfile,
                implementations?: ModelImplementationProvider<
                    Weights,
                    RuntimeModel,
                    Composition,
                >,
            ): RuntimeModel;
        };
        defaults: TrainConfig;
        loadConfig: (modelDir: string) => Promise<ModelConfig>;
        loadTemplate: (
            modelDir: string,
            opts?: { disableThinking?: boolean; fallback?: TemplateFallback },
        ) => Promise<ChatTemplate>;
        loadTokenizer: (modelDir: string) => Promise<LoadedTokenizer>;
        openWeights: (
            modelDir: string,
            options?: WeightsOpenOptions,
        ) => Promise<Weights>;
        train: (
            model: RuntimeModel,
            tok: LoadedTokenizer,
            tmpl: ChatTemplate,
            dataDir: string,
            cfg: TrainConfig,
            emit: TrainingProgressCallback,
            control?: { signal?: AbortSignal },
        ) => Promise<TrainResult>;
        recommendedLimit(): number;
        setWiredLimit(limit: number): number;
        synchronize(): void;
    }
    Index
    createModel: {
        <Model>(
            weights: Weights,
            config: ModelConfig,
            composition: Composition | undefined,
            resolved: ResolvedModelProfile | undefined,
            implementations: ModelImplementationProvider<Weights, Model>,
        ): Model;
        (
            weights: Weights,
            config: ModelConfig,
            composition?: Composition,
            resolved?: ResolvedModelProfile,
            implementations?: ModelImplementationProvider<
                Weights,
                RuntimeModel,
                Composition,
            >,
        ): RuntimeModel;
    }

    Type Declaration

    defaults: TrainConfig
    loadConfig: (modelDir: string) => Promise<ModelConfig>
    loadTemplate: (
        modelDir: string,
        opts?: { disableThinking?: boolean; fallback?: TemplateFallback },
    ) => Promise<ChatTemplate>

    Type Declaration

      • (
            modelDir: string,
            opts?: { disableThinking?: boolean; fallback?: TemplateFallback },
        ): Promise<ChatTemplate>
      • Loads the artifact's template. fallback renders artifacts that ship none (the model layer supplies it from the profile); without one, a missing template is an error.

        Parameters

        • modelDir: string
        • opts: { disableThinking?: boolean; fallback?: TemplateFallback } = {}

        Returns Promise<ChatTemplate>

    loadTokenizer: (modelDir: string) => Promise<LoadedTokenizer>
    openWeights: (
        modelDir: string,
        options?: WeightsOpenOptions,
    ) => Promise<Weights>
    train: (
        model: RuntimeModel,
        tok: LoadedTokenizer,
        tmpl: ChatTemplate,
        dataDir: string,
        cfg: TrainConfig,
        emit: TrainingProgressCallback,
        control?: { signal?: AbortSignal },
    ) => Promise<TrainResult>

    Type Declaration

      • (
            model: RuntimeModel,
            tok: LoadedTokenizer,
            tmpl: ChatTemplate,
            dataDir: string,
            cfg: TrainConfig,
            emit: TrainingProgressCallback,
            control?: { signal?: AbortSignal },
        ): Promise<TrainResult>
      • Train a LoRA adapter on the caller's model. Obligations of the control.signal seam: cancellation is observed only at boundaries (entry, before every optimizer step, and once more after the last step once every checkpoint write has completed), so a step is never interrupted and numerics are unchanged; a cancellation observed at a boundary rejects with the signal's reason, detaches the caller's model, releases the LoRA leaves after any checkpoint write that borrowed them has settled, keeps checkpoints saved earlier on disk, and writes no final adapter. Starting the final save is the commit point: a signal that arrives after it does not stop the complete save, and the run reports success. Every exit, including failure, leaves the model detached from training.

        Parameters

        Returns Promise<TrainResult>