Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
// The YAML export writes every offload field, so an import has to read every one back.
import assert from "node:assert/strict";
import test from "node:test";
import { registerStoreStubResolver } from "./helpers/kit.ts";
registerStoreStubResolver();
const { mapBackendModelConfigToTrainingPatch } = await import(
"../src/features/training/lib/model-defaults.ts"
);
test("importing an exported config restores every offload field", () => {
const patch = mapBackendModelConfigToTrainingPatch({
training: { offload_layers: "auto", offload_vram_gb: 12.5, prefetch_depth: "auto" },
});
assert.equal(patch.offloadLayers, "auto");
assert.equal(patch.offloadVramGb, 12.5);
assert.equal(patch.prefetchDepth, "auto");
const off = mapBackendModelConfigToTrainingPatch({
training: { offload_layers: 14, offload_vram_gb: null, prefetch_depth: 3 },
});
assert.equal(off.offloadVramGb, null);
assert.equal(off.prefetchDepth, 3);
const cards = mapBackendModelConfigToTrainingPatch({
training: { offload_vram_gb_per_device: { "0": 20, "1": null, "3": 12.5 } },
});
assert.deepEqual(cards.offloadVramGbPerDevice, { "0": 20, "3": 12.5 });
assert.deepEqual(
mapBackendModelConfigToTrainingPatch({ training: { offload_vram_gb_per_device: [null, 6] } })
.offloadVramGbPerDevice,
{ "1": 6 },
);
// Configs exported before these fields existed keep the current values.
assert.equal("offloadVramGb" in mapBackendModelConfigToTrainingPatch({ training: {} }), false);
});