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
import assert from "node:assert/strict";
import test from "node:test";
import { readSrc } from "./helpers/kit.ts";
const physical = (ids: number[], tensorSplit?: number[] | null) =>
({
gpuMemoryMode: "manual",
gpuLayers: 40,
selectedGpuIds: ids,
selectedGpuIndexKind: "physical",
tensorSplit,
}) as never;
test("a split edit is a config change, so Load and Apply stay reachable", async () => {
const { gpuFieldsSignature } = await import(
"../src/features/model-picker/model-config/config-signature.ts"
);
assert.notEqual(
gpuFieldsSignature(physical([0, 1], [26, 14])),
gpuFieldsSignature(physical([0, 1], [20, 20])),
);
assert.notEqual(
gpuFieldsSignature(physical([0, 1], [26, 14])),
gpuFieldsSignature(physical([0, 1], null)),
);
});
test("no split, whether unset or cleared, reads as the default distribution", async () => {
const { gpuFieldsSignature } = await import(
"../src/features/model-picker/model-config/config-signature.ts"
);
assert.equal(
gpuFieldsSignature(physical([0, 1], null)),
gpuFieldsSignature(physical([0, 1], undefined)),
);
});
test("the picker drops the split when the set changes and carries it on a reorder", () => {
const src = readSrc("features/model-picker/components/model-config-page.tsx");
const commit = src.slice(src.indexOf("const commitGpuIds"));
assert.match(
commit.slice(0, 600),
/nextSplit: number\[\] \| null = null[\s\S]*tensorSplit: nextSplit/,
"a toggle must reset the positional split",
);
const move = src.slice(src.indexOf("const moveGpu"));
assert.match(
move.slice(0, 700),
/\[nextSplit\[from\], nextSplit\[to\]\] = \[nextSplit\[to\], nextSplit\[from\]\]/,
"a reorder must move each share with its GPU",
);
});
test("the shares show only where the backend emits --tensor-split", () => {
const src = readSrc("features/model-picker/components/model-config-page.tsx");
const gate = src.slice(src.indexOf("const showSplit ="));
assert.match(
gate.slice(0, 300),
/!isDiffusion &&\s*isManual &&\s*!autoLayers &&\s*splitTotal > 0 &&\s*showGpuPicker &&\s*orderedGpuIds\.length > 1/,
);
});
test("the load sends the editor's split, and the dedupe compares it", () => {
const src = readSrc("features/chat/hooks/use-chat-model-runtime.ts");
assert.match(
src,
/let loadSplitRatio =\s*pendingLoadConfig\?\.tensorSplit !== undefined\s*\? pendingLoadConfig\.tensorSplit/,
);
assert.match(src, /loadSplitRatio = reconcileTensorSplit\(/);
assert.match(
src,
/splitRatio:\s*pendingConfig\?\.tensorSplit !== undefined\s*\? pendingConfig\.tensorSplit/,
);
const apply = readSrc("features/model-picker/model-config/apply-per-model-config.ts");
assert.match(apply, /reconcileTensorSplit\(config\.tensorSplit, config\.selectedGpuIds, gpuSelection\.ids\)/);
});