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.

Studio: scope "Remember settings next time" per GGUF quant and apply on every load path (#6594)

oobabooga2193b7f31488
diff --git a/studio/frontend/src/components/assistant-ui/model-selector/remembered-load-settings.ts b/studio/frontend/src/components/assistant-ui/model-selector/remembered-load-settings.ts
index 85e088ffb2d..ec75b17f20d 100644
--- a/studio/frontend/src/components/assistant-ui/model-selector/remembered-load-settings.ts
+++ b/studio/frontend/src/components/assistant-ui/model-selector/remembered-load-settings.ts
@@ -14,6 +14,21 @@ export interface RememberedLoadSettings {
tensorParallel: boolean;
}
+// Storage key for a pick's remembered settings. The remembered knobs are
+// VRAM-budget driven (context override, KV-cache dtype, tensor-parallel), so the
+// right values differ per quant. An HF repo collapses all its GGUF variants into
+// one `id`, so fold the variant in to scope settings per quant. Local .gguf
+// paths key by their file path (already file-specific); native drag-drop files
+// key by display label, so same-named files in different folders share an entry.
+export function rememberedLoadSettingsKey(selection: {
+ id: string;
+ ggufVariant?: string | null;
+}): string {
+ return selection.ggufVariant
+ ? `${selection.id}::${selection.ggufVariant}`
+ : selection.id;
+}
+
function readAll(): Record<string, RememberedLoadSettings> {
try {
return JSON.parse(localStorage.getItem(KEY) ?? "{}");
@@ -31,24 +46,24 @@ function writeAll(all: Record<string, RememberedLoadSettings>) {
}
export function loadRememberedLoadSettings(
- modelId: string,
+ key: string,
): RememberedLoadSettings | null {
- return readAll()[modelId] ?? null;
+ return readAll()[key] ?? null;
}
export function saveRememberedLoadSettings(
- modelId: string,
+ key: string,
settings: RememberedLoadSettings,
) {
const all = readAll();
- all[modelId] = settings;
+ all[key] = settings;
writeAll(all);
}
-export function clearRememberedLoadSettings(modelId: string) {
+export function clearRememberedLoadSettings(key: string) {
const all = readAll();
- if (modelId in all) {
- delete all[modelId];
+ if (key in all) {
+ delete all[key];
writeAll(all);
}
}
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index 7d4292669d9..a288a60fb67 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -8,6 +8,10 @@ import {
type ModelOption,
ModelSelector,
} from "@/components/assistant-ui/model-selector";
+import {
+ loadRememberedLoadSettings,
+ rememberedLoadSettingsKey,
+} from "@/components/assistant-ui/model-selector/remembered-load-settings";
import { ProjectComposer, Thread } from "@/components/assistant-ui/thread";
import { CopyableErrorChip } from "@/components/ui/copyable-error-chip";
import {
@@ -1275,13 +1279,18 @@ export function ChatPage({
selectModelRef.current = selectModel;
}, [refresh, selectModel]);
// Load a cached autoLoad pick once its download finishes. The sheet was never
- // opened, so on a load failure just drop the orphaned staged knobs.
+ // opened, so on a load failure just drop the orphaned staged knobs. The knobs
+ // were already seeded on stage, so keepSpeculative only when a config was
+ // saved -- otherwise the standing speculative preference should win.
autoLoadStagedRef.current = (pending) => {
+ const remembered = loadRememberedLoadSettings(
+ rememberedLoadSettingsKey(pending),
+ );
void selectModel({
...pending,
isDownloaded: true,
forceReload: true,
- keepSpeculative: false,
+ keepSpeculative: remembered != null,
throwOnError: true,
}).catch(() => {
const store = useChatRuntimeStore.getState();
@@ -1648,10 +1657,21 @@ export function ChatPage({
(!hasGgufSource(selection) && !wantManagerDownload) ||
(store.loadOnSelection && selection.isDownloaded)
) {
- // Detach any staged pick first so its edited knobs don't leak into this
- // immediate load. Detach (not abandon) keeps its download running.
+ // Detach any staged pick first so its edited knobs (e.g. a custom
+ // context length) don't leak into this immediate load -- resolveLoad
+ // reads customContextLength before checking the target is GGUF. Detach
+ // (not abandon) keeps its download running.
detachStaged();
- await selectModel(selection);
+ // Load-on-selection skips the sheet, so seed the saved knobs here the
+ // way the sheet's restore effect would; the switch would otherwise reset
+ // the remembered speculative choice (keepSpeculative below prevents it).
+ const remembered = hasGgufSource(selection)
+ ? loadRememberedLoadSettings(rememberedLoadSettingsKey(selection))
+ : null;
+ if (remembered) store.applyRememberedLoadSettings(remembered);
+ await selectModel(
+ remembered ? { ...selection, keepSpeculative: true } : selection,
+ );
return;
}
// Loads can't queue behind each other, but a download is independent: if
diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
index d9b338e0699..bc73e1ddf22 100644
--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx
+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
@@ -21,6 +21,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import {
clearRememberedLoadSettings,
loadRememberedLoadSettings,
+ rememberedLoadSettingsKey,
saveRememberedLoadSettings,
} from "@/components/assistant-ui/model-selector/remembered-load-settings";
import {
@@ -579,6 +580,9 @@ export function ChatSettingsPanel({
);
const kvCacheDtype = useChatRuntimeStore((s) => s.kvCacheDtype);
const setKvCacheDtype = useChatRuntimeStore((s) => s.setKvCacheDtype);
+ const applyRememberedLoadSettings = useChatRuntimeStore(
+ (s) => s.applyRememberedLoadSettings,
+ );
const loadedKvCacheDtype = useChatRuntimeStore((s) => s.loadedKvCacheDtype);
const tensorParallel = useChatRuntimeStore((s) => s.tensorParallel);
const setTensorParallel = useChatRuntimeStore((s) => s.setTensorParallel);
@@ -613,25 +617,16 @@ export function ChatSettingsPanel({
// the saved per-model settings on stage, so the sheet opens with what was used
// last time; the tick reflects whether a saved entry exists.
const [remember, setRemember] = useState(false);
- const pendingId = pendingSelection?.id ?? null;
+ // Keyed per quant: a different variant of the same repo has its own settings.
+ const pendingKey = pendingSelection
+ ? rememberedLoadSettingsKey(pendingSelection)
+ : null;
useEffect(() => {
- if (!pendingId) return;
- const saved = loadRememberedLoadSettings(pendingId);
+ if (!pendingKey) return;
+ const saved = loadRememberedLoadSettings(pendingKey);
setRemember(saved != null);
- if (!saved) return;
- setCustomContextLength(saved.contextLength);
- setKvCacheDtype(saved.kvCacheDtype);
- setSpeculativeType(saved.speculativeType ?? "auto");
- setSpecDraftNMax(saved.specDraftNMax);
- setTensorParallel(saved.tensorParallel);
- }, [
- pendingId,
- setCustomContextLength,
- setKvCacheDtype,
- setSpeculativeType,
- setSpecDraftNMax,
- setTensorParallel,
- ]);
+ if (saved) applyRememberedLoadSettings(saved);
+ }, [pendingKey, applyRememberedLoadSettings]);
// While staging, the sheet reflects the STAGED model, so its header context
// takes precedence over the loaded model's (which may differ or be larger).
const baseContext = pendingIsGguf ? stagedContextLength : ggufContextLength;
@@ -1213,9 +1208,11 @@ export function ChatSettingsPanel({
type="button"
onClick={() => {
// Persist (or clear) this model's load knobs before loading.
- // Save the explicit context override only (null = auto), so
- // restoring never forces the native context into an OOM.
- const pid = pendingSelection?.id;
+ // Context is stored as the override (null = auto), never the
+ // resolved native value, so restoring can't force an OOM.
+ const pid = pendingSelection
+ ? rememberedLoadSettingsKey(pendingSelection)
+ : null;
if (pid) {
if (remember) {
saveRememberedLoadSettings(pid, {
diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
index 059a4543059..5b2dae5e086 100644
--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
@@ -1,6 +1,7 @@
// 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 type { RememberedLoadSettings } from "@/components/assistant-ui/model-selector/remembered-load-settings";
import { cancelStagedModelDownload } from "@/features/hub";
import { toast } from "@/lib/toast";
import { create } from "zustand";
@@ -770,6 +771,10 @@ type ChatRuntimeStore = {
* start each deferred-staging session clean so one staged pick's settings
* don't leak onto the next. */
resetModelSettingsToLoaded: () => void;
+ /** Seed the editable load knobs from a model's remembered settings. Shared by
+ * the settings sheet's restore effect and the "Load on selection" paths,
+ * which skip the sheet but must still honor a saved config. */
+ applyRememberedLoadSettings: (settings: RememberedLoadSettings) => void;
setTensorParallel: (value: boolean) => void;
setLoadOnSelection: (value: boolean) => void;
setExpandQuantizations: (value: boolean) => void;
@@ -1528,6 +1533,16 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set, get) => ({
setSpecDraftNMax: (specDraftNMax) => set({ specDraftNMax }),
setTensorParallel: (tensorParallel) => set({ tensorParallel }),
resetModelSettingsToLoaded: () => set((s) => loadedBaselineSettings(s)),
+ applyRememberedLoadSettings: (settings) =>
+ // Coalesce every field: a blob persisted by an older/newer build can omit
+ // keys, and a raw spread would push `undefined` into fields typed non-null.
+ set({
+ customContextLength: settings.contextLength ?? null,
+ kvCacheDtype: settings.kvCacheDtype ?? null,
+ speculativeType: settings.speculativeType ?? "auto",
+ specDraftNMax: settings.specDraftNMax ?? null,
+ tensorParallel: settings.tensorParallel ?? false,
+ }),
setLoadOnSelection: (loadOnSelection) => {
saveBool(CHAT_LOAD_ON_SELECTION_KEY, loadOnSelection);
set({ loadOnSelection });
diff --git a/studio/frontend/src/features/hub/hub-page.tsx b/studio/frontend/src/features/hub/hub-page.tsx
index b919e5f043d..c6968622831 100644
--- a/studio/frontend/src/features/hub/hub-page.tsx
+++ b/studio/frontend/src/features/hub/hub-page.tsx
@@ -1,6 +1,10 @@
// 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 {
+ loadRememberedLoadSettings,
+ rememberedLoadSettingsKey,
+} from "@/components/assistant-ui/model-selector/remembered-load-settings";
import { useHubInventory } from "@/features/hub/inventory";
import { useDebouncedValue } from "@/hooks/use-debounced-value";
import { useGpuInfo } from "@/hooks/use-gpu-info";
@@ -1088,11 +1092,32 @@ export function ModelsPage() {
openNewChat();
return;
}
+ // Detach any leftover staged pick first so its edited knobs (e.g. a custom
+ // context length) don't leak into this load -- mirrors the chat page's
+ // detachStaged(); keepDownload keeps any staged download running.
+ useChatRuntimeStore.getState().abandonStagedModel({ keepDownload: true });
+ // Load-on-selection skips the chat sheet, so seed this GGUF pick's saved
+ // load knobs here the way the sheet's restore effect would; otherwise the
+ // remembered config is silently ignored on the Hub run path. keepSpeculative
+ // then honors the restored speculative choice across the switch.
+ const remembered =
+ opts.ggufVariant != null || selectedModel.isGguf
+ ? loadRememberedLoadSettings(
+ rememberedLoadSettingsKey({
+ id: runId,
+ ggufVariant: opts.ggufVariant,
+ }),
+ )
+ : null;
+ if (remembered) {
+ useChatRuntimeStore.getState().applyRememberedLoadSettings(remembered);
+ }
void selectModel({
id: runId,
ggufVariant: opts.ggufVariant,
isDownloaded,
expectedBytes: opts.expectedBytes,
+ keepSpeculative: remembered != null,
throwOnError: true,
})
.then(() => {