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
Studio: apply remembered settings for MLX and safetensors models to API loads (#11904)
Long Yixing54fbe529e6e5
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex 73b7513597f..eac74961702 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -4468,6 +4468,7 @@ export function ChatPage({modelId={inferenceParams.checkpoint}ggufVariant={activeGgufVariant ?? null}isGguf={activeModelIsGguf}+ isLora={activeModelIsLora}isDiffusion={activeModelIsDiffusion}nativeContextLength={nativeContextLength}loadedContextLength={loadedContextLength}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.tsindex 3527c0747f0..dbfaf636daf 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@@ -4,6 +4,7 @@// Barrel import (lint rule); the model-picker cycle is fine because the call// happens at runtime, not module eval.import {+ adoptCachedRepoConfig,loadedContextFields,resolveResidentInitialConfig,savedContextPin,@@ -156,6 +157,8 @@ export function applyActiveModelStatusToStore(// Only reached with a model active, so this is the one place both the status poll and the// readopt path can publish residency from. Without it a load looks unloaded for up to 10s.useChatRuntimeStore.setState({ residentCheckpoint: checkpointId });+ // Before the settings panel can open on it, which reads only the repo id.+ adoptCachedRepoConfig(checkpointId, status.gguf_variant ?? null);const store = useChatRuntimeStore.getState();const previousCheckpoint =diff --git a/studio/frontend/src/features/model-picker/api/migrate-model-overrides.ts b/studio/frontend/src/features/model-picker/api/migrate-model-overrides.tsindex 25fe0aacf3d..6ca4ece4a16 100644--- a/studio/frontend/src/features/model-picker/api/migrate-model-overrides.ts+++ b/studio/frontend/src/features/model-picker/api/migrate-model-overrides.ts@@ -5,14 +5,15 @@// only in this browser, so on upgrade an API load still used app defaults.import {+ cachedRepoConfigId,isNativeFileLabel,isOllamaLinkPath,- isOllamaModelId,normalizeGgufVariantIdentity,normalizeModelIdentity,splitQuantSuffix,} from "../model-config/model-identity";import {+ adoptCachedRepoConfig,isDefaultConfig,listPerModelConfigs,} from "../model-config/per-model-config";@@ -24,8 +25,9 @@ import {toApiOverride,} from "./model-overrides";-// Bumped when the filter below started admitting Ollama tags, so a completed v1 pass reruns.-const DONE_FLAG = "unsloth_model_overrides_backfilled_v2";+// Bumped whenever the filter below admits more, so a completed pass reruns: v2 for Ollama tags,+// v3 for non-GGUF weights.+const DONE_FLAG = "unsloth_model_overrides_backfilled_v3";function alreadyRan(): boolean {try {@@ -79,15 +81,18 @@ export async function backfillModelOverrides(): Promise<void> {if (alreadyRan()) {return;}+ // Uploaded under the path, a record an older build saved for a cached repo would outrank the repo's.+ for (const entry of listPerModelConfigs()) {+ adoptCachedRepoConfig(entry.modelId, entry.ggufVariant);+ }const local = listPerModelConfigs().filter(- // A quant means GGUF, all auto-switch resolves; a .gguf and a reference have a null variant.- // A link sits in a dir the resolver skips, a bare file name is a label it never keys.+ // Auto-switch resolves GGUF and non-GGUF weights alike. A link sits in a dir the resolver+ // skips, a bare file name is a label it never keys, and a snapshot path still here is a record+ // adoption declined.(entry) =>- (entry.ggufVariant != null ||- entry.modelId.toLowerCase().endsWith(".gguf") ||- isOllamaModelId(entry.modelId)) &&!isOllamaLinkPath(entry.modelId) &&!isNativeFileLabel(entry.modelId) &&+ cachedRepoConfigId(entry.modelId, entry.ggufVariant) === null &&!isDefaultConfig(entry.config),);if (local.length === 0) {diff --git a/studio/frontend/src/features/model-picker/api/model-overrides.ts b/studio/frontend/src/features/model-picker/api/model-overrides.tsindex a793a855923..c240c99d5fe 100644--- a/studio/frontend/src/features/model-picker/api/model-overrides.ts+++ b/studio/frontend/src/features/model-picker/api/model-overrides.ts@@ -269,6 +269,22 @@ export async function fetchLoadExtraArgs(return resolvedFrom(resolved ?? {});}+/** The row as a settings panel applies it. llama-server arguments reach a GGUF load alone, and+ * hydrating them into another model's config would count a list it cannot show as a change. */+export function panelOverrideRow(+ override: ApiModelOverride | null,+ isGguf: boolean,+): ApiModelOverride | null {+ if (!override || isGguf) {+ return override;+ }+ return presentOverride(+ Object.fromEntries(+ Object.entries(override).filter(([key]) => key !== "llama_extra_args"),+ ),+ );+}+/** Translate one server-resolved override into the picker's config shape. The row is* authoritative for the fields it CARRIES and only those: an absent field is not evidence* the user chose the default, since a failed PUT, a refused value and an old row all leavediff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsxindex 3075558d5f8..3d18c87f9e3 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@@ -88,6 +88,7 @@ import {fetchLoadModelOverride,fromApiOverride,modelOverrideKey,+ panelOverrideRow,syncModelOverride,} from "../api/model-overrides";import {@@ -2028,17 +2029,17 @@ export function ModelConfigPage({// refuse. Held by the panel rather than the row, since the row unmounts whenever Advanced// settings collapse while its tokens stay in the config.const [extraArgsLoadable, setExtraArgsLoadable] = useState(true);- // True until the stored-arguments read below settles: a load started before it lands sends no- // llama_extra_args, and /load cannot inherit them from a process that is not running.+ // True until the server-row read below settles: a load started before it lands sends none of the+ // row's settings, and with Remember unchecked it forgets the row it never read.const [extraArgsHydrating, setExtraArgsHydrating] = useState(- () => target.isGguf && !isDiffusion,+ () => !isDiffusion,);// The row does not withdraw its own objection when it unmounts, or collapsing Advanced settings// would re-enable Load for arguments the backend refuses. Only a different model retires it.// biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the model, not on the setteruseEffect(() => {setExtraArgsLoadable(true);- setExtraArgsHydrating(target.isGguf && !isDiffusion);+ setExtraArgsHydrating(!isDiffusion);}, [configId, target.ggufVariant, target.isGguf, isDiffusion]);// Compare against what the backend was asked for, not what it applied: staging a new value@@ -2239,14 +2240,13 @@ export function ModelConfigPage({]);// The server copy is shared by Desktop, LAN, and tunnel origins, so hydrate the whole- // remembered GGUF config here; localStorage is only the immediate seed. This also runs while- // Advanced is closed, since extra arguments affect every load.+ // remembered config here; localStorage is only the immediate seed. This also runs while+ // Advanced is closed, since the row reaches every load whether or not it is shown.// biome-ignore lint/correctness/useExhaustiveDependencies: the model is the identityuseEffect(() => {- if (!target.isGguf || resolvedIsDiffusion) {- // Nothing else even has this field: the row is GGUF-only and so is the load payload. A- // diffusion GGUF is GGUF-shaped but runs through the shim, which appends no llama-server- // flags, so it must not wait either.+ if (resolvedIsDiffusion) {+ // A diffusion model runs through the shim, which appends no llama-server flags, so it keeps+ // Load free of this read.setExtraArgsHydrating(false);return;}@@ -2285,8 +2285,10 @@ export function ModelConfigPage({Promise.all([// Resolved by the backend, which owns the rules; the local resolver stays as the fallback for// a backend that predates the parameter.- fetchLoadModelOverride(loadId, configId, target.ggufVariant, keys),- loadManagedLlamaFlags(),+ fetchLoadModelOverride(loadId, configId, target.ggufVariant, keys).then(+ (row) => panelOverrideRow(row, target.isGguf),+ ),+ target.isGguf ? loadManagedLlamaFlags() : null,]).then(([resolvedOverride, managed]) => {// Marked here rather than before the request: StrictMode replays the effect, so a key marked@@ -2315,7 +2317,9 @@ export function ModelConfigPage({);// A list this build refuses can equally have come from local storage, saved by a build that// still allowed it, and nothing else would catch it while Advanced stays collapsed.- const local = configRef.current.llamaExtraArgs;+ const local = target.isGguf+ ? configRef.current.llamaExtraArgs+ : undefined;// Kept for the merge below as well as for the box: a row that carries no arguments leaves the// local list standing, and handing back a refused list would re-enable Load.let sanitizedLocal = localAtStart;@@ -2356,7 +2360,7 @@ export function ModelConfigPage({// declared loadable by a verdict read off the empty server list.const hydratedArgs = serverConfig?.llamaExtraArgs ?? stored;const hydratedIsLoadable =- hydratedArgs.length === 0+ !target.isGguf || hydratedArgs.length === 0? true: extraArgsAreLoadable(diagnoseExtraArgs(diff --git a/studio/frontend/src/features/model-picker/components/model-selector/types.ts b/studio/frontend/src/features/model-picker/components/model-selector/types.tsindex 32d41d79a98..8cdadfb2579 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/types.ts+++ b/studio/frontend/src/features/model-picker/components/model-selector/types.ts@@ -99,8 +99,8 @@ export interface ModelPickTarget {displayName: string;ggufVariant?: string | null;isGguf: boolean;- /** Whether an OpenAI-compatible request can actually load this model. Not the same as isGguf:- * local_model_resolver skips Ollama's scanner. Defaults to isGguf when unknown. */+ /** Whether an OpenAI-compatible request may load this model; see apiAutoSwitchMayLoad.+ * Defaults to isGguf when unknown. */apiLoadable?: boolean;/** Identity the saved settings are keyed by, when that is not what loads: a repo cached outside* the active HF cache loads by snapshot path while its settings key on the repo id. Probesdiff --git a/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsx b/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsxindex 2877d4235b0..9f314d3b4f6 100644--- a/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsx+++ b/studio/frontend/src/features/model-picker/components/sidebar-model-config.tsx@@ -3,18 +3,15 @@import { useMemo } from "react";import { modelConfigInstanceKey } from "../model-config/config-signature";-import {- isOllamaLinkPath,- isStandaloneGgufPath,-} from "../model-config/model-identity";+import { residentModelConfigTarget } from "../model-config/model-config-handoff";import type { PerModelConfig } from "../model-config/per-model-config";import { ModelConfigPage } from "./model-config-page";-import type { ModelPickTarget } from "./model-selector/types";interface SidebarModelConfigProps {modelId: string;ggufVariant: string | null;isGguf: boolean;+ isLora: boolean;isDiffusion: boolean;nativeContextLength: number | null;loadedContextLength: number | null;@@ -22,56 +19,32 @@ interface SidebarModelConfigProps {onReload: (config: PerModelConfig) => void;}-const TRAILING_SEPARATORS = /[\\/]+$/;--function leafName(id: string): string {- const trimmed = id.replace(TRAILING_SEPARATORS, "");- const separator = Math.max(- trimmed.lastIndexOf("/"),- trimmed.lastIndexOf("\\"),- );- return separator >= 0 ? trimmed.slice(separator + 1) : trimmed;-}-export function SidebarModelConfig({modelId,ggufVariant,isGguf,+ isLora,isDiffusion,nativeContextLength,loadedContextLength,loadedConfig,onReload,}: SidebarModelConfigProps) {- // A standalone .gguf has no quant to choose between, but the loader labels it from its filename and- // /status echoes that back. Keying settings by it would write "<path>:Q4_K_M" while all other- // settings entry points use the bare path.- const settingsGgufVariant = isStandaloneGgufPath(modelId)- ? null- : ggufVariant;- const target = useMemo<ModelPickTarget>(() => {- const leaf = leafName(modelId);- return {- id: modelId,- displayName: ggufVariant ? `${leaf} · ${ggufVariant}` : leaf,- ggufVariant: settingsGgufVariant,- isGguf,- // A materialized Ollama link sits in a dir the resolver skips, so do not mirror it.- apiLoadable: isGguf && !isOllamaLinkPath(modelId),- meta: {- source: "local",- isLora: false,- ggufVariant: settingsGgufVariant ?? undefined,+ const target = useMemo(+ () =>+ residentModelConfigTarget({+ modelId,+ ggufVariant,isGguf,- isDownloaded: true,+ isLora,contextLength: nativeContextLength,- },- };- }, [modelId, ggufVariant, settingsGgufVariant, isGguf, nativeContextLength]);+ }),+ [modelId, ggufVariant, isGguf, isLora, nativeContextLength],+ );return (<ModelConfigPage- key={modelConfigInstanceKey(modelId, settingsGgufVariant, loadedConfig)}+ key={modelConfigInstanceKey(modelId, target.ggufVariant, loadedConfig)}target={target}onRun={onReload}loadedConfig={loadedConfig}diff --git a/studio/frontend/src/features/model-picker/index.ts b/studio/frontend/src/features/model-picker/index.tsindex 5a4e2306c85..4fd64727a63 100644--- a/studio/frontend/src/features/model-picker/index.ts+++ b/studio/frontend/src/features/model-picker/index.ts@@ -69,6 +69,7 @@ export {type PerModelConfig,PER_MODEL_CONFIG_STORAGE_KEY,PER_MODEL_CONFIG_UPDATED_EVENT,+ adoptCachedRepoConfig,adoptLegacyConfigKey,isServedByLlamaCpp,contextPinPatch,diff --git a/studio/frontend/src/features/model-picker/model-config/model-config-handoff.ts b/studio/frontend/src/features/model-picker/model-config/model-config-handoff.tsindex 0809f91caad..606c9fd8dc8 100644--- a/studio/frontend/src/features/model-picker/model-config/model-config-handoff.ts+++ b/studio/frontend/src/features/model-picker/model-config/model-config-handoff.ts@@ -7,8 +7,9 @@ import type {ModelSelectorChangeMeta,} from "../components/model-selector/types";import {+ apiAutoSwitchMayLoad,+ cachedRepoConfigId,ggufVariantsMatch,- isOllamaLinkPath,isOllamaModelId,isStandaloneGgufPath,modelDisplayName,@@ -68,12 +69,63 @@ export function modelConfigTarget(displayName: meta.ggufVariant ? `${name} · ${meta.ggufVariant}` : name,ggufVariant: meta.ggufVariant ?? null,isGguf,- apiLoadable: isGguf && !isOllamaLinkPath(id) && !isOllamaLinkPath(loadId),+ apiLoadable: apiAutoSwitchMayLoad([id, loadId], meta.isLora),...(separateLoadId ? { configId: id } : {}),meta,};}+const TRAILING_SEPARATORS = /[\\/]+$/;++function leafName(id: string): string {+ const trimmed = id.replace(TRAILING_SEPARATORS, "");+ const separator = Math.max(+ trimmed.lastIndexOf("/"),+ trimmed.lastIndexOf("\\"),+ );+ return separator >= 0 ? trimmed.slice(separator + 1) : trimmed;+}++/** The settings target for the model /api/inference/status reports as loaded. */+export function residentModelConfigTarget({+ modelId,+ ggufVariant,+ isGguf,+ isLora,+ contextLength,+}: {+ modelId: string;+ ggufVariant: string | null;+ isGguf: boolean;+ isLora: boolean;+ contextLength: number | null;+}): ModelPickTarget {+ // A standalone .gguf has no quant to choose between, but the loader labels it from its filename and+ // /status echoes that back. Keying settings by it would write "<path>:Q4_K_M" while all other+ // settings entry points use the bare path.+ const settingsGgufVariant = isStandaloneGgufPath(modelId)+ ? null+ : ggufVariant;+ const leaf = leafName(modelId);+ const repoId = cachedRepoConfigId(modelId, settingsGgufVariant);+ return {+ id: modelId,+ displayName: ggufVariant ? `${leaf} · ${ggufVariant}` : leaf,+ ggufVariant: settingsGgufVariant,+ isGguf,+ apiLoadable: apiAutoSwitchMayLoad([modelId], isLora),+ ...(repoId ? { configId: repoId } : {}),+ meta: {+ source: "local",+ isLora,+ ggufVariant: settingsGgufVariant ?? undefined,+ isGguf,+ isDownloaded: true,+ contextLength,+ },+ };+}+export function modelConfigTargetMatchesSelection(target: ModelPickTarget,selectedId: string | null | undefined,diff --git a/studio/frontend/src/features/model-picker/model-config/model-identity.ts b/studio/frontend/src/features/model-picker/model-config/model-identity.tsindex 0ddc8399d74..886e94bae9f 100644--- a/studio/frontend/src/features/model-picker/model-config/model-identity.ts+++ b/studio/frontend/src/features/model-picker/model-config/model-identity.ts@@ -3,8 +3,12 @@// eslint-disable-next-line no-restricted-imports -- Avoid the hub barrel's React and download-manager exports.import {+ isHfCacheSnapshotPath,+ isOllamaLinkPath,+ isStandaloneGgufPath,normalizeGgufVariantIdentity,normalizeModelIdentity,+ publicModelId,} from "@/features/hub/lib/model-identity";import { looksLikeLocalPath } from "@/lib/local-path";@@ -51,6 +55,31 @@ function parseVersionedModelStorageKey(}}+/** False when an OpenAI API auto-switch can never load this model, so its remembered settings stay+ * off the server. local_model_resolver serves GGUF and non-GGUF weights alike but never a bare LoRA+ * adapter or a materialized Ollama link; a row for anything else it refuses is inert. */+export function apiAutoSwitchMayLoad(+ ids: readonly string[],+ isLora: boolean,+): boolean {+ return !isLora && !ids.some(isOllamaLinkPath);+}++/** The repo id a cached repo's settings are keyed by when it loads from its snapshot directory with+ * no quant, else null. /status reports that path while the picker keys the repo id, and the backend+ * folds the two spellings only for a quant, so a bare snapshot-path row would outrank the picker's+ * and survive its Forget. */+export function cachedRepoConfigId(+ modelId: string,+ ggufVariant: string | null | undefined,+): string | null {+ return !ggufVariant &&+ !isStandaloneGgufPath(modelId) &&+ isHfCacheSnapshotPath(modelId)+ ? publicModelId(modelId)+ : null;+}+export function modelStorageKey(modelId: string,ggufVariant?: string | null,diff --git a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/per-model-config.tsindex 1068e302539..db6eec24216 100644--- a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts+++ b/studio/frontend/src/features/model-picker/model-config/per-model-config.ts@@ -3,6 +3,7 @@import type { GpuIndexKind } from "@/hooks/use-gpu-info";import {+ cachedRepoConfigId,ggufVariantFromStorageKey,isStandaloneGgufPath,modelIdFromStorageKey,@@ -1466,6 +1467,19 @@ export function resolveInitialConfig(return { config: { ...DEFAULT_PER_MODEL_CONFIG }, remembered: false };}+/** Moves a record an older build saved under a cached repo's snapshot path to the repo id the+ * settings panel keys it by. Returns that repo id, or null when the model is not one. */+export function adoptCachedRepoConfig(+ modelId: string,+ ggufVariant?: string | null,+): string | null {+ const repoId = cachedRepoConfigId(modelId, ggufVariant);+ if (repoId) {+ adoptLegacyConfigKey(repoId, modelId, null);+ }+ return repoId;+}+/** Remembered settings for the identifier /api/inference/status reports as loaded. An API auto-switch hands the* loader a concrete snapshot path while settings are keyed by repo id, so reading the raw identifier reports the* resident model as unremembered and blanks a control it is running with. Only a namespaced collapse is adopted,@@ -1474,6 +1488,10 @@ export function resolveResidentInitialConfig(modelId: string,ggufVariant?: string | null,): ResolvedPerModelConfig {+ const repoId = adoptCachedRepoConfig(modelId, ggufVariant);+ if (repoId) {+ return resolveInitialConfig(repoId, null);+ }// a standalone file's reported quant is a label; its settings are saved without a variant.const standalone = isStandaloneGgufPath(modelId);const direct = resolveInitialConfig(modelId, standalone ? null : ggufVariant);diff --git a/studio/frontend/tests/llama-extra-args-diagnostics.test.ts b/studio/frontend/tests/llama-extra-args-diagnostics.test.tsindex 999385a2db1..1c8a7dd5d67 100644--- a/studio/frontend/tests/llama-extra-args-diagnostics.test.ts+++ b/studio/frontend/tests/llama-extra-args-diagnostics.test.ts@@ -663,7 +663,7 @@ test("the row does not withdraw its objection when it unmounts", () => {// The panel retires it on a model change instead.assert.match(pageSource.replace(/\s+/g, " "),- /setExtraArgsLoadable\(true\); setExtraArgsHydrating\(target\.isGguf && !isDiffusion\); \}, \[configId, target\.ggufVariant, target\.isGguf, isDiffusion\]\)/,+ /setExtraArgsLoadable\(true\); setExtraArgsHydrating\(!isDiffusion\); \}, \[configId, target\.ggufVariant, target\.isGguf, isDiffusion\]\)/,);});@@ -744,20 +744,21 @@ test("load waits for the stored arguments to be read", () => {assert.doesNotMatch(body, /loadLlamaFlagCatalog\(\)[^;]*Promise\.all/);});-test("a model with no such field does not wait for one", () => {+test("Load waits for the server row on every model but diffusion", () => {const panel = pageSource.slice(pageSource.indexOf("export function ModelConfigPage("),);const body = panel.replace(/\s+/g, " ");- // The row and the load payload are both GGUF-only, so a Transformers or MLX model- // must not have Load held shut while two requests it will never use settle.- // A diffusion GGUF is GGUF-shaped but runs through the diffusion shim, which- // appends no llama-server flags, so it must not wait either.+ // Every non-diffusion model reads the row, and a Load sent before it lands with+ // Remember unchecked forgets it. A diffusion model runs through the shim, which+ // appends no llama-server flags, so it alone skips the wait.assert.match(body,- /if \(!target\.isGguf \|\| resolvedIsDiffusion\) \{ .*setExtraArgsHydrating\(false\); return; \}/,+ /if \(resolvedIsDiffusion\) \{ [^}]*setExtraArgsHydrating\(false\); return; \}/,);- assert.match(body, /useState\( \(\) => target\.isGguf && !isDiffusion, \)/);+ assert.match(body, /useState\( \(\) => !isDiffusion, \)/);+ assert.match(body, /setExtraArgsHydrating\(!isDiffusion\);/);+ assert.doesNotMatch(body, /setExtraArgsHydrating\(true\)/);});test("a diffusion classification retires the argument objection", () => {@@ -827,7 +828,7 @@ test("a hydrated list is judged even when the row cannot be", () => {);assert.match(body,- /const hydratedIsLoadable = hydratedArgs\.length === 0 \? true : extraArgsAreLoadable\( diagnoseExtraArgs\( formatExtraArgs\(hydratedArgs\)/,+ /const hydratedIsLoadable = !target\.isGguf \|\| hydratedArgs\.length === 0 \? true : extraArgsAreLoadable\( diagnoseExtraArgs\( formatExtraArgs\(hydratedArgs\)/,);// But not over an edit made while the request was out: the row is judging that// text, and replacing its verdict re-enabled Load for invalid input.diff --git a/studio/frontend/tests/llama-extra-args-panel-hydration.test.ts b/studio/frontend/tests/llama-extra-args-panel-hydration.test.tsindex e872d634c29..c7e145b35c3 100644--- a/studio/frontend/tests/llama-extra-args-panel-hydration.test.ts+++ b/studio/frontend/tests/llama-extra-args-panel-hydration.test.ts@@ -197,6 +197,16 @@ test("the panel adopts a shared server config without overwriting a live edit",);});+test("the panel strips llama-server arguments from a non-GGUF row", () => {+ // An API auto-switch applies the row to MLX and safetensors loads too, so the panel shows it.+ assert.match(PANEL, /target\.isGguf \? loadManagedLlamaFlags\(\) : null,/);+ assert.match(PANEL, /\(row\) => panelOverrideRow\(row, target\.isGguf\)/);+ assert.match(+ PANEL,+ /const local = target\.isGguf\s*\?\s*configRef\.current\.llamaExtraArgs\s*:\s*undefined;/,+ );+});+test("hydration detects a newer save or forget", () => {const modelId = "unsloth/Hydration-Race-GGUF";const variant = "Q4_K_M";diff --git a/studio/frontend/tests/model-config-handoff.test.ts b/studio/frontend/tests/model-config-handoff.test.tsindex e647283f59c..d25d9c015d7 100644--- a/studio/frontend/tests/model-config-handoff.test.ts+++ b/studio/frontend/tests/model-config-handoff.test.ts@@ -21,6 +21,7 @@ const {modelConfigTargetIsResident,modelConfigTargetMatchesSelection,requestModelConfigHandoff,+ residentModelConfigTarget,useModelConfigHandoffStore,} = await import("../src/features/model-picker/model-config/model-config-handoff.ts"@@ -256,6 +257,75 @@ test("an Ollama load identity mirrors its settings only when the API can reach i);});+test("non-GGUF weights mirror their settings, a LoRA adapter does not", () => {+ const repo = "mlx-community/Qwen3.5-9B-MLX-8bit";+ const snapshot =+ "/hf/models--mlx-community--Qwen3.5-9B-MLX-8bit/snapshots/abc";+ const cached = modelConfigTarget(repo, {+ source: "hub",+ isLora: false,+ loadId: snapshot,+ isDownloaded: true,+ isGguf: false,+ });+ assert.equal(cached.isGguf, false);+ assert.equal(cached.apiLoadable, true);+ // A local folder row leaves isGguf unset rather than false.+ const folder = "/Users/u/.lmstudio/models/mlx-community/Qwen3.5-4B-MLX-4bit";+ assert.equal(+ modelConfigTarget(folder, { source: "local", isLora: false }).apiLoadable,+ true,+ );+ const adapter = "/Users/u/outputs/checkpoint-60";+ assert.equal(+ modelConfigTarget(adapter, { source: "lora", isLora: true }).apiLoadable,+ false,+ );+});++test("the resident settings key a cached non-GGUF repo by its repo id", () => {+ const snapshot =+ "/hf/models--mlx-community--Qwen3.5-9B-MLX-8bit/snapshots/abc";+ const resident = (overrides: {+ modelId?: string;+ ggufVariant?: string | null;+ isGguf?: boolean;+ isLora?: boolean;+ }) =>+ residentModelConfigTarget({+ modelId: snapshot,+ ggufVariant: null,+ isGguf: false,+ isLora: false,+ contextLength: null,+ ...overrides,+ });++ const mlx = resident({});+ assert.equal(mlx.id, snapshot);+ assert.equal(mlx.configId, "mlx-community/Qwen3.5-9B-MLX-8bit");+ assert.equal(mlx.apiLoadable, true);+ // The backend folds a quant's two spellings itself, so a GGUF keeps its load path.+ const gguf = resident({ isGguf: true, ggufVariant: "Q4_K_M" });+ assert.equal(gguf.configId, undefined);+ assert.equal(gguf.apiLoadable, true);+ // A loose file drops its label, and every other entry point keys it by its path.+ const file = resident({+ modelId: `${snapshot}/model-Q4_K_M.gguf`,+ isGguf: true,+ ggufVariant: "Q4_K_M",+ });+ assert.equal(file.ggufVariant, null);+ assert.equal(file.configId, undefined);+ const folder = "/Users/u/.lmstudio/models/org/Model-MLX";+ assert.equal(resident({ modelId: folder }).configId, undefined);+ assert.equal(+ resident({ modelId: "/Users/u/outputs/checkpoint-60", isLora: true })+ .apiLoadable,+ false,+ );+});+test("submitting a cached handoff adopts legacy path-keyed settings", () => {store.clear();const id = "unsloth/Llama-GGUF";diff --git a/studio/frontend/tests/resident-remembered-config.test.ts b/studio/frontend/tests/resident-remembered-config.test.tsindex d8b52ce454c..39cfc04bc11 100644--- a/studio/frontend/tests/resident-remembered-config.test.ts+++ b/studio/frontend/tests/resident-remembered-config.test.ts@@ -71,6 +71,30 @@ test("a record under the raw identifier still wins over the repo alias", () => {);});+test("a cached repo loaded without a quant moves its snapshot-path record to the repo id", () => {+ store.clear();+ const snapshot = "/hf/models--mlx-community--Model-4bit/snapshots/abc";+ const repo = "mlx-community/Model-4bit";+ savePerModelConfig(snapshot, null, config(2));++ // The settings panel reads the repo id alone, so both readers must settle on one record.+ assert.equal(+ resolveResidentInitialConfig(snapshot, null).config.nParallel,+ 2,+ );+ assert.equal(resolveInitialConfig(repo, null).config.nParallel, 2);+ assert.equal(resolveInitialConfig(snapshot, null).remembered, false);++ // What the panel saved under the repo id outranks the stale path record, as on a Hub handoff.+ savePerModelConfig(snapshot, null, config(6));+ savePerModelConfig(repo, null, config(8));+ assert.equal(+ resolveResidentInitialConfig(snapshot, null).config.nParallel,+ 8,+ );+ assert.equal(resolveInitialConfig(snapshot, null).remembered, false);+});+test("the quant still separates two variants of one cached repo", () => {store.clear();savePerModelConfig(REPO_ID, "Q4_K_M", config(4));diff --git a/studio/frontend/tests/server-tuning-upgrade-downgrade-compat.test.ts b/studio/frontend/tests/server-tuning-upgrade-downgrade-compat.test.tsindex 830d02a6172..e93d86e9d0b 100644--- a/studio/frontend/tests/server-tuning-upgrade-downgrade-compat.test.ts+++ b/studio/frontend/tests/server-tuning-upgrade-downgrade-compat.test.ts@@ -41,16 +41,19 @@ const {} = await import("../src/features/model-picker/model-config/per-model-config.ts");-const { fromApiOverride, resolveStoredOverride, toApiOverride } = await import(- "../src/features/model-picker/api/model-overrides.ts"-);+const {+ fromApiOverride,+ panelOverrideRow,+ resolveStoredOverride,+ toApiOverride,+} = await import("../src/features/model-picker/api/model-overrides.ts");const { backfillModelOverrides } = await import("../src/features/model-picker/api/migrate-model-overrides.ts");const { setAuthFetchHandler } = await import("./helpers/store-stubs/auth.ts");const STORAGE_KEY = "unsloth_model_configs";-const BACKFILL_FLAG = "unsloth_model_overrides_backfilled_v2";+const BACKFILL_FLAG = "unsloth_model_overrides_backfilled_v3";const MODEL = "unsloth/Repo-GGUF";const VARIANT = "Q4_K_M";@@ -344,6 +347,50 @@ test("the backfill offers an Ollama tag's settings even after the v1 pass ran",assert.deepEqual(puts, [ref.toLowerCase()]);});+test("the backfill offers non-GGUF weights, keyed by repo id, after the v2 pass ran", async () => {+ // A cached repo loads from its snapshot directory, which an older sidebar keyed it by. Uploaded+ // under that path, the bare row would outrank the repo's and survive the picker's Forget.+ store.clear();+ store.set("unsloth_model_overrides_backfilled_v2", "1");+ const folder = "/Users/u/.lmstudio/models/mlx-community/Qwen3.5-4B-MLX-4bit";+ const snapshot = "/hf/models--mlx-community--Model-4bit/snapshots/abc";+ const template = { chatTemplateOverride: "{{ messages }}" };+ assert.ok(savePerModelConfig(folder, null, config(template)));+ assert.ok(savePerModelConfig(snapshot, null, config({ mlxKvBits: 8 })));+ // A newer build's record under the repo id makes adoption decline, and the path stays put.+ const declined = "/hf/models--org--Newer/snapshots/def";+ assert.ok(savePerModelConfig("org/Newer", null, config({ mlxKvBits: 4 })));+ const map = readMap();+ const newer = Object.keys(map).find((key) => key.includes("org/newer"));+ assert.ok(newer);+ map[newer].version = 99;+ writeMap(map);+ assert.ok(savePerModelConfig(declined, null, config({ mlxKvBits: 4 })));+ // Identities the resolver never keys.+ const link = "/home/u/.ollama/.studio_links/ab12/model-latest.gguf";+ assert.ok(savePerModelConfig(link, null, config(template)));+ assert.ok(savePerModelConfig("Model-Q4_K_M.gguf", null, config(template)));++ const puts: unknown[] = [];+ setAuthFetchHandler((_input, init) => {+ if (init?.method === "PUT") {+ puts.push(JSON.parse(String(init.body)).model_id);+ }+ return new Response(JSON.stringify({ overrides: {} }), { status: 200 });+ });+ try {+ await backfillModelOverrides();+ } finally {+ setAuthFetchHandler(null);+ }+ assert.deepEqual(+ new Set(puts),+ new Set([folder, "mlx-community/model-4bit"]),+ );+ assert.equal(resolveInitialConfig(declined, null).config.mlxKvBits, 4);+ assert.equal(store.get(BACKFILL_FLAG), "1");+});+test("an all-default config is still filtered out of the backfill", async () => {// The gate the case above walks through has to stay shut for everything else, or// every model the user ever opened is mirrored on first launch.@@ -453,6 +500,23 @@ test("eviction takes the readable records and leaves the future ones", () => {// F. The server row as the authority, and what that costs the local copy.// ---------------------------------------------------------------------------+test("a non-GGUF panel reads a row without its llama-server arguments", () => {+ const row = {+ // biome-ignore lint/style/useNamingConvention: API schema+ chat_template_override: "{{ messages }}",+ // biome-ignore lint/style/useNamingConvention: API schema+ llama_extra_args: ["--no-mmap"],+ };+ assert.deepEqual(panelOverrideRow(row, true), row);+ assert.deepEqual(panelOverrideRow(row, false), {+ // biome-ignore lint/style/useNamingConvention: API schema+ chat_template_override: "{{ messages }}",+ });+ // A row holding nothing else is no row at all.+ // biome-ignore lint/style/useNamingConvention: API schema+ assert.equal(panelOverrideRow({ llama_extra_args: [] }, false), null);+});+test("a row that carries no tuning leaves this browser's tuning standing", () => {// The mirror is lossy in both directions: a PUT that never landed, a save from a// build that did not forward the four, a row written before the route learned them.diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex 0885b0976d3..c3ed88477ab 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -2225,7 +2225,7 @@ def test_parallel_slots_setting_wired_end_to_end():signature = _read("features/model-picker/model-config/config-signature.ts")assert 'config.nParallel ?? "",' in signaturesidebar = " ".join(_read("features/model-picker/components/sidebar-model-config.tsx").split())- assert "key={modelConfigInstanceKey(modelId, settingsGgufVariant, loadedConfig)}" in sidebar+ assert "key={modelConfigInstanceKey(modelId, target.ggufVariant, loadedConfig)}" in sidebardef test_parallel_slots_reach_an_api_load_through_the_server_mirror():@@ -2934,9 +2934,9 @@ def test_backfill_includes_a_standalone_gguf_with_no_variant():"""A standalone .gguf picked directly has no quant to choose between, so it is storedwith a null variant."""src = " ".join(_read("features/model-picker/api/migrate-model-overrides.ts").split())- assert 'entry.modelId.toLowerCase().endsWith(".gguf")' in src- # Still excluded for safetensors, which auto-switch does not resolve.- assert "entry.ggufVariant != null ||" in src+ # No GGUF clause at all: auto-switch resolves non-GGUF weights too.+ assert "cachedRepoConfigId(entry.modelId, entry.ggufVariant) === null &&" in src+ assert "entry.ggufVariant != null ||" not in srcdef test_monitor_overlay_does_not_pull_in_the_lazy_page():@@ -3069,9 +3069,11 @@ def test_the_chat_picker_marks_ollama_targets_unloadable_by_the_api():"""A settings target opened from the Chat model picker carried no apiLoadable, so the`??"""handoff = " ".join(_read("features/model-picker/model-config/model-config-handoff.ts").split())- assert "apiLoadable: isGguf && !isOllamaLinkPath(id) && !isOllamaLinkPath(loadId)," in handoff- sidebar = " ".join(_read("features/model-picker/components/sidebar-model-config.tsx").split())- assert "apiLoadable: isGguf && !isOllamaLinkPath(modelId)," in sidebar+ assert "apiLoadable: apiAutoSwitchMayLoad([id, loadId], meta.isLora)," in handoff+ # The sidebar builds its target here too.+ assert "apiLoadable: apiAutoSwitchMayLoad([modelId], isLora)," in handoff+ predicate = " ".join(_read("features/model-picker/model-config/model-identity.ts").split())+ assert "return !isLora && !ids.some(isOllamaLinkPath);" in predicate# The same classification gates the backfill, or an older config still reaches the server.backfill = " ".join(_read("features/model-picker/api/migrate-model-overrides.ts").split())assert "!isOllamaLinkPath(entry.modelId) &&" in backfill@@ -3143,7 +3145,7 @@ def test_public_model_identity_matches_the_backend_for_path_loaded_models():def test_the_sidebar_settings_editor_reseeds_when_the_live_config_lands():"""ModelConfigPage primes the shared draft when loadedConfigSignature changes."""sidebar = " ".join(_read("features/model-picker/components/sidebar-model-config.tsx").split())- assert "key={modelConfigInstanceKey(modelId, settingsGgufVariant, loadedConfig)}" in sidebar+ assert "key={modelConfigInstanceKey(modelId, target.ggufVariant, loadedConfig)}" in sidebarsignature = " ".join(_read("features/model-picker/model-config/config-signature.ts").split())# "No live config yet" needs its own value: that transition is the one that must remount.@@ -3196,15 +3198,16 @@ def test_a_standalone_gguf_has_one_settings_identity_in_the_picker():"""A loose .gguf has no quant to choose between, but llama_cpp falls back to_extract_quant_label(gguf_path) when a load names no variant, and /status echoesthat as gguf_variant."""- sidebar = " ".join(_read("features/model-picker/components/sidebar-model-config.tsx").split())+ resident = " ".join(_read("features/model-picker/model-config/model-config-handoff.ts").split())# Nulled for the settings identity, and used for every field that keys it.assert (- "const settingsGgufVariant = isStandaloneGgufPath(modelId) ? null : ggufVariant;" in sidebar+ "const settingsGgufVariant = isStandaloneGgufPath(modelId) ? null : ggufVariant;"+ in resident)- assert "ggufVariant: settingsGgufVariant," in sidebar- assert "ggufVariant: settingsGgufVariant ?? undefined," in sidebar+ assert "ggufVariant: settingsGgufVariant," in resident+ assert "ggufVariant: settingsGgufVariant ?? undefined," in resident# The label still shows the quant; only the identity drops it.- assert "displayName: ggufVariant ? `${leaf} · ${ggufVariant}` : leaf," in sidebar+ assert "displayName: ggufVariant ? `${leaf} · ${ggufVariant}` : leaf," in residentidentity = _read("features/hub/lib/model-identity.ts")assert "export function isStandaloneGgufPath(" in identity