Skip to content

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.

fix(studio): include loaded llama extra args in active model baseline (#10870)

Sourav Rajvia7d24c820b68
diff --git a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
index e4dc6ca9a75..e27d5e7d6d4 100644
--- a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
+++ b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
@@ -44,6 +44,7 @@ import { sameGpuSelection } from "@/hooks/gpu-selection";
import { resolveBatchSizeSeed } from "./resolve-batch-size-seed";
import { resolveChatTemplateSeed } from "./resolve-chat-template-seed";
import { resolveCtxPinSeed } from "./resolve-ctx-pin-seed";
+import { resolveLlamaExtraArgsSeed } from "./resolve-llama-extra-args-seed";
import { shouldSeedVisionSwitch } from "./resolve-vision-switch-seed";
type LocalReasoningEffort = Extract<ReasoningEffort, "low" | "medium" | "high">;
@@ -621,11 +622,12 @@ export function applyActiveModelStatusToStore(
// status, not just the first: another client can reload the SAME model with different
// arguments, and a pinned baseline would resurrect arguments that are not running.
// seedLoadParams still guards it, so a mid-switch poll cannot overwrite performLoad.
- ...(status.requested_llama_extra_args !== undefined &&
- (status.is_gguf ?? true) &&
- seedLoadParams && {
- loadedLlamaExtraArgs: status.requested_llama_extra_args ?? null,
- }),
+ ...resolveLlamaExtraArgsSeed({
+ incoming: status.requested_llama_extra_args,
+ isGguf: status.is_gguf ?? true,
+ hydratingExistingModel,
+ seedLoadParams,
+ }),
// one rule per batch pair, see resolveBatchSizeSeed
...("loaded" in nBatchSeed && { loadedNBatch: nBatchSeed.loaded ?? null }),
...("value" in nBatchSeed && { nBatch: nBatchSeed.value ?? null }),
diff --git a/studio/frontend/src/features/chat/lib/resolve-llama-extra-args-seed.ts b/studio/frontend/src/features/chat/lib/resolve-llama-extra-args-seed.ts
new file mode 100644
index 00000000000..69287e3fa7b
--- /dev/null
+++ b/studio/frontend/src/features/chat/lib/resolve-llama-extra-args-seed.ts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+/** What a settled status does to `loadedLlamaExtraArgs`: `{}` leaves it alone. */
+export function resolveLlamaExtraArgsSeed({
+ incoming,
+ isGguf,
+ hydratingExistingModel,
+ seedLoadParams,
+}: {
+ incoming: string[] | null | undefined;
+ isGguf: boolean;
+ hydratingExistingModel: boolean;
+ seedLoadParams: boolean;
+}): { loadedLlamaExtraArgs?: string[] | null } {
+ if (!seedLoadParams) {
+ return {};
+ }
+ if (incoming !== undefined) {
+ return isGguf ? { loadedLlamaExtraArgs: incoming ?? null } : {};
+ }
+ // A backend that omits the field: keep this tab's first-hand record for the same model, but
+ // never hand the previous model's arguments to a new one.
+ return hydratingExistingModel ? { loadedLlamaExtraArgs: null } : {};
+}
diff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsx
index cbe092cc073..fb6942eaf75 100644
--- a/studio/frontend/src/features/model-picker/components/model-config-page.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-config-page.tsx
@@ -2743,7 +2743,9 @@ export function ModelConfigPage({
platform.deviceType,
platform.chatOnlyReason,
);
- const atBaseline = perModelConfigsEqual(config, baseline);
+ const atBaseline = perModelConfigsEqual(config, baseline, {
+ followGlobal: true,
+ });
// The fitted value is an outcome, not an override. Auto stays at the default even
// when a loaded model reports less than its native context. A non-GGUF pin is an
// override too, read from whichever field it was saved in.
@@ -3237,7 +3239,9 @@ export function ModelConfigPage({
// Recheck the committed draft so Save/Forget reloads when needed.
const effectivePersistenceOnly =
isActiveModel &&
- perModelConfigsEqual(effectiveConfig, baseline) &&
+ perModelConfigsEqual(effectiveConfig, baseline, {
+ followGlobal: true,
+ }) &&
rememberChanged;
const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig);
if (effectivePersistenceOnly) {
diff --git a/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts b/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts
index bcd9e36259d..5206a36ac1b 100644
--- a/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts
+++ b/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts
@@ -56,6 +56,9 @@ export function useActiveModelConfig(): ActiveModelConfigState {
const chatTemplateOverride = useChatRuntimeStore(
(s) => s.chatTemplateOverride,
);
+ const loadedLlamaExtraArgs = useChatRuntimeStore(
+ (s) => s.loadedLlamaExtraArgs,
+ );
const gpuMemoryMode = useChatRuntimeStore((s) => s.gpuMemoryMode);
const gpuLayers = useChatRuntimeStore((s) => s.gpuLayers);
const nCpuMoe = useChatRuntimeStore((s) => s.nCpuMoe);
@@ -121,6 +124,10 @@ export function useActiveModelConfig(): ActiveModelConfigState {
selectedGpuIds,
selectedGpuIndexKind,
tensorSplit: splitRatio,
+ // Absent until the runtime reports a list: undefined is what lets the editor hydrate the stored row.
+ ...(loadedLlamaExtraArgs != null
+ ? { llamaExtraArgs: [...loadedLlamaExtraArgs] }
+ : {}),
};
}, [
checkpoint,
@@ -144,6 +151,7 @@ export function useActiveModelConfig(): ActiveModelConfigState {
tensorParallel,
disableVision,
chatTemplateOverride,
+ loadedLlamaExtraArgs,
gpuMemoryMode,
gpuLayers,
nCpuMoe,
diff --git a/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
index 897147131bc..c9c88ad6839 100644
--- a/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
+++ b/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
@@ -155,18 +155,23 @@ export function currentRuntimePerModelConfig(
};
}
+/** `followGlobal`: only against the running config, which holds the mode a null one resolved to.
+ * Stored configs and presets keep null distinct from an explicit mode equal to today's global. */
export function perModelConfigsEqual(
a: PerModelConfig,
b: PerModelConfig,
+ { followGlobal = false }: { followGlobal?: boolean } = {},
): boolean {
+ const speculative = followGlobal
+ ? resolvedSpeculativeType
+ : normalizeSpeculativeType;
return (
(a.customContextLength ?? null) === (b.customContextLength ?? null) &&
normalizeMaxSeqLength(a.maxSeqLength) ===
normalizeMaxSeqLength(b.maxSeqLength) &&
(a.kvCacheDtype ?? null) === (b.kvCacheDtype ?? null) &&
(a.mlxKvQuant ?? null) === (b.mlxKvQuant ?? null) &&
- normalizeSpeculativeType(a.speculativeType) ===
- normalizeSpeculativeType(b.speculativeType) &&
+ speculative(a.speculativeType) === speculative(b.speculativeType) &&
(a.specDraftNMax ?? null) === (b.specDraftNMax ?? null) &&
(a.specDraftCacheDtype ?? null) === (b.specDraftCacheDtype ?? null) &&
(a.nParallel ?? null) === (b.nParallel ?? null) &&
@@ -186,6 +191,10 @@ export function perModelConfigsEqual(
);
}
+function resolvedSpeculativeType(value: string | null | undefined): string {
+ return normalizeSpeculativeType(value) ?? readPersistedSpeculativeType();
+}
+
/** Compare on the launched command, so "not loaded" and "cleared" are equal here. They differ
* only in what a SAVE does, and treating them as different would make the row read as an
* unsaved change the moment it finished reading the server. */
diff --git a/studio/frontend/src/features/model-picker/model-config/config-signature.ts b/studio/frontend/src/features/model-picker/model-config/config-signature.ts
index 240f291fec9..c30ef802e63 100644
--- a/studio/frontend/src/features/model-picker/model-config/config-signature.ts
+++ b/studio/frontend/src/features/model-picker/model-config/config-signature.ts
@@ -68,6 +68,9 @@ export function loadedConfigSignature(
config.chatTemplateOverride == null
? ""
: `${config.chatTemplateOverride.length}:${hashString(config.chatTemplateOverride)}`,
+ config.llamaExtraArgs == null
+ ? ""
+ : `${config.llamaExtraArgs.length}:${hashString(config.llamaExtraArgs.join("\u0000"))}`,
gpuFieldsSignature(config),
].join("|");
}
diff --git a/studio/frontend/tests/active-model-baseline.test.ts b/studio/frontend/tests/active-model-baseline.test.ts
new file mode 100644
index 00000000000..4980015379d
--- /dev/null
+++ b/studio/frontend/tests/active-model-baseline.test.ts
@@ -0,0 +1,117 @@
+// 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 type { ActiveModelConfigState } from "../src/features/model-picker/hooks/use-active-model-config.ts";
+import type { PerModelConfig } from "../src/features/model-picker/model-config/per-model-config.ts";
+import { loadWithStubs } from "./helpers/module-stubs.ts";
+
+function useActiveConfigFor(patch: Record<string, unknown>, gguf = true) {
+ const state = {
+ params: { checkpoint: "unsloth/Qwen3-0.6B-GGUF", maxSeqLength: 2048 },
+ loadedLlamaExtraArgs: null,
+ ...patch,
+ };
+ const { useActiveModelConfig } = loadWithStubs<{
+ useActiveModelConfig: () => ActiveModelConfigState;
+ }>(
+ new URL(
+ "../src/features/model-picker/hooks/use-active-model-config.ts",
+ import.meta.url,
+ ),
+ {
+ "@/features/chat": {
+ isExternalModelId: () => false,
+ useChatRuntimeStore: (select: (value: typeof state) => unknown) =>
+ select(state),
+ },
+ "@/config/env": { usePlatformStore: () => ({ deviceType: "cuda" }) },
+ react: { useMemo: (factory: () => unknown) => factory() },
+ "../model-config/per-model-config": {
+ isServedByLlamaCpp: () => gguf,
+ residentIsServedByMlx: () => false,
+ },
+ },
+ );
+ return useActiveModelConfig().config!;
+}
+
+function configsEqual(persistedMode: string) {
+ return loadWithStubs<{
+ perModelConfigsEqual: (
+ a: PerModelConfig,
+ b: PerModelConfig,
+ options?: { followGlobal?: boolean },
+ ) => boolean;
+ }>(
+ new URL(
+ "../src/features/model-picker/model-config/apply-per-model-config.ts",
+ import.meta.url,
+ ),
+ {
+ "@/features/chat/stores/chat-runtime-store": {
+ normalizeSpeculativeType: (value: string | null | undefined) =>
+ value == null || value === "" ? null : value.toLowerCase(),
+ readPersistedSpeculativeType: () => persistedMode,
+ },
+ "@/features/chat/presets/preset-policy": {},
+ "./config-signature": { gpuFieldsSignature: () => "" },
+ "./per-model-config": {
+ normalizeMaxSeqLength: (value: number | null | undefined) =>
+ value ?? null,
+ },
+ },
+ ).perModelConfigsEqual;
+}
+
+const BASE: PerModelConfig = {
+ customContextLength: null,
+ maxSeqLength: null,
+ kvCacheDtype: null,
+ speculativeType: null,
+ specDraftNMax: null,
+ nParallel: null,
+ reasoningBudget: -1,
+ reasoningBudgetMessage: "",
+ nBatch: null,
+ nUbatch: null,
+ tensorParallel: false,
+ disableVision: false,
+ chatTemplateOverride: null,
+};
+
+test("the active GGUF baseline carries the arguments the server runs with", () => {
+ const config = useActiveConfigFor({ loadedLlamaExtraArgs: ["--no-warmup"] });
+ assert.deepEqual(config.llamaExtraArgs, ["--no-warmup"]);
+ assert.deepEqual(
+ useActiveConfigFor({ loadedLlamaExtraArgs: [] }).llamaExtraArgs,
+ [],
+ );
+});
+
+test("unreported or non-llama.cpp arguments stay absent so the stored row can hydrate", () => {
+ assert.equal("llamaExtraArgs" in useActiveConfigFor({}), false);
+ assert.equal(
+ "llamaExtraArgs" in
+ useActiveConfigFor({ loadedLlamaExtraArgs: ["--no-warmup"] }, false),
+ false,
+ );
+});
+
+test("following the global mode, a stored Auto (null) equals the mode it resolves to", () => {
+ const runtime = { followGlobal: true };
+ const autoEqual = configsEqual("auto");
+ assert.ok(autoEqual(BASE, { ...BASE, speculativeType: "auto" }, runtime));
+ assert.ok(!autoEqual(BASE, { ...BASE, speculativeType: "off" }, runtime));
+ const offEqual = configsEqual("off");
+ assert.ok(offEqual(BASE, { ...BASE, speculativeType: "off" }, runtime));
+ assert.ok(!offEqual(BASE, { ...BASE, speculativeType: "auto" }, runtime));
+});
+
+test("between stored configs a null mode stays distinct from an explicit one", () => {
+ // Presets: null means no mode carried, so an explicit Off must never fold into it.
+ const offEqual = configsEqual("off");
+ assert.ok(!offEqual(BASE, { ...BASE, speculativeType: "off" }));
+ assert.ok(offEqual({ ...BASE, speculativeType: "mtp" }, { ...BASE, speculativeType: "MTP" }));
+});
diff --git a/studio/frontend/tests/llama-extra-args-status-hydration.test.ts b/studio/frontend/tests/llama-extra-args-status-hydration.test.ts
index 8bc59b1a052..fba27d67c36 100644
--- a/studio/frontend/tests/llama-extra-args-status-hydration.test.ts
+++ b/studio/frontend/tests/llama-extra-args-status-hydration.test.ts
@@ -10,13 +10,29 @@
// and the previous model comes back without the arguments it was running.
//
// The fix is that /api/inference/status publishes requested_llama_extra_args and the
-// applier seeds the baseline from it. Checked at the source, like the chat-template
-// seed test next door: the applier is one large object literal with no seam to call.
+// applier seeds the baseline from it, through resolveLlamaExtraArgsSeed.
import assert from "node:assert/strict";
import { test } from "node:test";
-import { readSrc } from "./helpers/kit.ts";
+import { readSrc, registerBundlerResolver } from "./helpers/kit.ts";
+
+registerBundlerResolver();
+const { resolveLlamaExtraArgsSeed } = await import(
+ "../src/features/chat/lib/resolve-llama-extra-args-seed.ts"
+);
+
+function seed(
+ incoming: string[] | null | undefined,
+ { model = false, gguf = true, seedLoadParams = true } = {},
+) {
+ return resolveLlamaExtraArgsSeed({
+ incoming,
+ isGguf: gguf,
+ hydratingExistingModel: model,
+ seedLoadParams,
+ });
+}
const APPLIER = readSrc("features/chat/lib/apply-inference-status-to-store.ts");
const RUNTIME = readSrc("features/chat/hooks/use-chat-model-runtime.ts");
@@ -29,8 +45,12 @@ test("the status type carries the running arguments", () => {
test("the applier seeds the loaded baseline from the status echo", () => {
assert.match(
APPLIER,
- /loadedLlamaExtraArgs: status\.requested_llama_extra_args \?\? null/,
+ /resolveLlamaExtraArgsSeed\(\{\s*incoming: status\.requested_llama_extra_args,\s*isGguf: status\.is_gguf \?\? true,\s*hydratingExistingModel,\s*seedLoadParams,/,
);
+ assert.deepEqual(seed(["--numa", "distribute"]), {
+ loadedLlamaExtraArgs: ["--numa", "distribute"],
+ });
+ assert.deepEqual(seed(["--numa"], { gguf: false }), {});
});
test("the CLI adoption path hydrates settings while it owns the load lease", () => {
@@ -48,10 +68,15 @@ test("the CLI adoption path hydrates settings while it owns the load lease", ()
);
});
-test("an older backend that omits the field changes nothing", () => {
+test("an older backend that omits the field changes nothing for the same model", () => {
// undefined is "this server does not publish it", which must leave a baseline this
// tab recorded first-hand alone rather than clearing it to null.
- assert.match(APPLIER, /status\.requested_llama_extra_args !== undefined/);
+ assert.deepEqual(seed(undefined), {});
+});
+
+test("an older backend's model change drops the previous model's arguments", () => {
+ // Kept, they become the new model's baseline and a Reload sends them to it.
+ assert.deepEqual(seed(undefined, { model: true }), { loadedLlamaExtraArgs: null });
});
test("the baseline follows a same-model reload from elsewhere", () => {
@@ -59,10 +84,9 @@ test("the baseline follows a same-model reload from elsewhere", () => {
// arguments, or with none: a baseline pinned at the first read would resend the
// old list from the rollback path and resurrect arguments that are not running.
// The in-flight guard stays, since performLoad owns these values mid-switch.
- assert.match(
- APPLIER,
- /requested_llama_extra_args !== undefined &&\s*\n\s*\(status\.is_gguf \?\? true\) &&\s*\n\s*seedLoadParams/,
- );
+ assert.deepEqual(seed(null), { loadedLlamaExtraArgs: null });
+ assert.deepEqual(seed(["--a"], { seedLoadParams: false }), {});
+ assert.deepEqual(seed(undefined, { model: true, seedLoadParams: false }), {});
});
test("the rollback still resends that baseline explicitly", () => {
@@ -78,8 +102,5 @@ test("an explicit empty list is kept apart from an unknown one", () => {
// carrying the arguments of the load that just failed. null stays for "never told".
assert.match(RUNTIME, /loadLlamaExtraArgs !== undefined\s*\n?\s*\? \(loadLlamaExtraArgs \?\? \[\]\)/);
// The status echo goes in as it arrives, so a server running none reads as [].
- assert.match(
- APPLIER,
- /loadedLlamaExtraArgs: status\.requested_llama_extra_args \?\? null/,
- );
+ assert.deepEqual(seed([]), { loadedLlamaExtraArgs: [] });
});
diff --git a/studio/frontend/tests/model-config-instance-key.test.ts b/studio/frontend/tests/model-config-instance-key.test.ts
index 44815cc33cf..0c5d57f6c8b 100644
--- a/studio/frontend/tests/model-config-instance-key.test.ts
+++ b/studio/frontend/tests/model-config-instance-key.test.ts
@@ -145,3 +145,19 @@ test("the model and its quant still key the editor", () => {
modelConfigInstanceKey(MODEL, undefined, LIVE),
);
});
+
+test("the arguments the model is running with key the editor", () => {
+ // Another tab relaunching with only different arguments must re-seed, or Apply resends the old list.
+ const running = { ...LIVE, llamaExtraArgs: ["--numa", "distribute"] };
+ const base = modelConfigInstanceKey(MODEL, VARIANT, running);
+ assert.notEqual(
+ modelConfigInstanceKey(MODEL, VARIANT, { ...LIVE, llamaExtraArgs: ["--numa", "isolate"] }),
+ base,
+ );
+ assert.notEqual(modelConfigInstanceKey(MODEL, VARIANT, { ...LIVE, llamaExtraArgs: [] }), base);
+ assert.notEqual(modelConfigInstanceKey(MODEL, VARIANT, LIVE), base);
+ assert.equal(
+ modelConfigInstanceKey(MODEL, VARIANT, { ...LIVE, llamaExtraArgs: [...running.llamaExtraArgs] }),
+ base,
+ );
+});
diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.py
index 90c60427489..405f6b4d78f 100644
--- a/tests/studio/test_model_picker_contracts.py
+++ b/tests/studio/test_model_picker_contracts.py
@@ -508,8 +508,12 @@ def test_active_model_config_round_trips_gpu_fields():
"nCpuMoe",
"selectedGpuIds",
"selectedGpuIndexKind",
+ "llamaExtraArgs",
+ "loadedLlamaExtraArgs",
):
assert field in src, field
+ assert "loadedLlamaExtraArgs != null" in src
+ assert "llamaExtraArgs: [...loadedLlamaExtraArgs]" in src
assert "if (!isGguf)" in src and "return base" in src
assert "useActiveModelConfig(" in _read("features/chat/chat-page.tsx")
# Live config sync is in the shared draft store; instance keys still remount on signature.
@@ -1226,7 +1230,7 @@ def test_context_commit_rechecks_persistence_only_shortcut():
"""Committed context changes must bypass persistence-only saves."""
src = _read("features/model-picker/components/model-config-page.tsx")
assert "const effectiveConfig =" in src
- assert "perModelConfigsEqual(effectiveConfig, baseline)" in src
+ assert "perModelConfigsEqual(effectiveConfig, baseline, {" in src
assert "const effectivePersistenceOnly =" in src
assert "if (effectivePersistenceOnly)" in src