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: save a model's run settings without loading it (#10216)
Nilay7a8c05523e3c
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.tsxindex 72058ee3f2c..43de6a816a8 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@@ -3042,10 +3042,7 @@ export function ModelConfigPage({? "Reload model": "Load model";- const handleRun = () => {- if (budgetSettling) {- return;- }+ const commitDraft = () => {// Same-click Load/Reload: a numeric draft the user just typed is flushed only by that input's// blur handler, which runs after this click closure captured the stale value, so commit// every numeric input imperatively.@@ -3120,56 +3117,41 @@ export function ModelConfigPage({? maxSeqLengthValue: (normalizeMaxSeqLength(effectiveConfig.maxSeqLength) ??clampMaxSeqLength(DEFAULT_MAX_SEQ_LENGTH, nativeMaxSeqLength));- // Recheck the committed draft so Save/Forget reloads when needed.- const effectiveAtBaseline = perModelConfigsEqual(effectiveConfig, baseline);- const effectivePersistenceOnly =- isActiveModel && effectiveAtBaseline && rememberChanged;+ return { effectiveConfig, effectiveRuntimeConfig, effectiveMaxSeqLengthValue };+ };++ const persistConfig = (next: PerModelConfig) => {// Judge what storage keeps: savePerModelConfig normalizes first, so the raw object over-reports.- const normalizedRuntimeConfig = normalizePerModelConfig(- effectiveRuntimeConfig,- );- const defaultConfig = isDefaultConfig(normalizedRuntimeConfig);- let saveFailed = false;+ const normalized = normalizePerModelConfig(next);const evicted: { modelId: string; ggufVariant: string | null }[] = [];- if (remember) {- saveFailed = !savePerModelConfig(- configId,- target.ggufVariant,- normalizedRuntimeConfig,- evicted,- );- } else {- saveFailed = !deletePerModelConfig(configId, target.ggufVariant);- }+ const saved = remember+ ? savePerModelConfig(configId, target.ggufVariant, normalized, evicted)+ : deletePerModelConfig(configId, target.ggufVariant);// Mirror to the server so an API load gets these settings, not app defaults. Best-effort, and// skipped when the localStorage write failed or the two would permanently disagree. Gated on// auto-switch reach, not GGUF-ness: the resolver skips a materialized Ollama link, and a// native-path lease is the same.// A forget also drops the local records for every other spelling the server reports clearing.- if (- !saveFailed &&- (target.apiLoadable ?? target.isGguf) &&- !nativePathToken- ) {+ if (saved && (target.apiLoadable ?? target.isGguf) && !nativePathToken) {syncModelOverride(configId,target.ggufVariant,- remember ? normalizedRuntimeConfig : null,+ remember ? normalized : null,remember? {resetReasoningBudget:baseline.reasoningBudget !== -1 &&- normalizedRuntimeConfig.reasoningBudget === -1,+ normalized.reasoningBudget === -1,resetReasoningBudgetMessage:baseline.reasoningBudgetMessage !== "" &&- normalizedRuntimeConfig.reasoningBudgetMessage === "",+ normalized.reasoningBudgetMessage === "",}: undefined,);}// Only once the write landed: a blocked or full localStorage leaves the values on screen,// and clearing anyway let the next read replace them with the older stored row.- if (!saveFailed) {+ if (saved) {clearModelConfigDraftEdited(draftKey);}// Saving can push the local map over budget and drop other models, whose server entries would@@ -3179,24 +3161,65 @@ export function ModelConfigPage({keepLaunchFlags: true,});}+ return { saved, defaultConfig: isDefaultConfig(normalized) };+ };++ const finishPersist = (defaultConfig: boolean) => {+ const nextRemember = remember && !defaultConfig;+ setSavedRemember(nextRemember);+ setRemember(nextRemember);+ toast.success(+ nextRemember+ ? "Settings saved."+ : remember+ ? "Default settings kept."+ : "Settings forgotten.",+ );+ };++ const handleSave = () => {+ const { effectiveRuntimeConfig } = commitDraft();+ const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig);+ if (!saved) {+ toast.error("Couldn't save settings for this model.");+ return;+ }+ // The page stays mounted, so show a context pinFixedLayerContext stored (else it reads "Auto").+ // Not on a forget: that stored nothing, and pinning here would change the next load.+ // setConfig, not update: this mirrors what was just saved, so the draft must stay unedited.+ if (+ remember &&+ effectiveRuntimeConfig.customContextLength !== config.customContextLength+ ) {+ setConfig((current) => ({+ ...current,+ customContextLength: effectiveRuntimeConfig.customContextLength,+ }));+ }+ finishPersist(defaultConfig);+ };++ const handleRun = () => {+ if (budgetSettling) {+ return;+ }+ const { effectiveConfig, effectiveRuntimeConfig, effectiveMaxSeqLengthValue } =+ commitDraft();+ // Recheck the committed draft so Save/Forget reloads when needed.+ const effectivePersistenceOnly =+ isActiveModel &&+ perModelConfigsEqual(effectiveConfig, baseline) &&+ rememberChanged;+ const { saved, defaultConfig } = persistConfig(effectiveRuntimeConfig);if (effectivePersistenceOnly) {- if (saveFailed) {+ if (!saved) {toast.error("Couldn't save settings for this model.");return;}- const nextRemember = remember && !defaultConfig;- setSavedRemember(nextRemember);- setRemember(nextRemember);- toast.success(- nextRemember- ? "Settings saved."- : remember- ? "Default settings kept."- : "Settings forgotten.",- );+ finishPersist(defaultConfig);return;}- if (saveFailed) {+ if (!saved) {toast.error("Couldn't save these settings, loading with them anyway.");}// MLX pins in customContextLength as GGUF does, so unpinned sends nothing.@@ -3440,13 +3463,9 @@ export function ModelConfigPage({)}</div>- <div- className={- variant === "sidebar"- ? "mt-5 flex flex-col gap-2 border-t border-border pt-5"- : "mt-5 flex items-center justify-between gap-3 border-t border-border pt-5"- }- >+ {/* Stacked in both variants: a row that wraps on demand reflows when the same click that+ commits a draft mounts Save settings, moving Load out from under the cursor. */}+ <div className="mt-5 flex flex-col gap-2 border-t border-border pt-5"><div className="flex min-w-0 items-center gap-2"><Checkboxid={rememberId}@@ -3465,13 +3484,7 @@ export function ModelConfigPage({Remember for this model</label></div>- <div- className={- variant === "sidebar"- ? "flex flex-wrap items-center gap-2"- : "flex shrink-0 items-center gap-2"- }- >+ <div className="flex flex-wrap items-center gap-2">{/* Primary action first, like the Preset row's Save/Delete. */}<Buttontype="button"@@ -3492,6 +3505,29 @@ export function ModelConfigPage({>{primaryActionLabel}</Button>+ {/* Hidden with nothing to save or forget, else never-remembered models show a dead Forget. */}+ {!persistenceOnly && (remember || savedRemember) && (+ <Button+ type="button"+ variant="outline"+ size="sm"+ className={FOOTER_BUTTON_CLASS}+ // Same gates as Load: an unclassified model or an in-flight budget PUT would persist+ // settings the load path strips or has already captured. Forget stores nothing, so+ // broken saved arguments must not lock it.+ disabled={+ stagedMetadataPending ||+ budgetSettling ||+ (remember &&+ ((!extraArgsLoadable && !sharedExtraArgsCleared) ||+ sharedExtraArgsRefused ||+ extraArgsHydrating))+ }+ onClick={handleSave}+ >+ {remember ? "Save settings" : "Forget settings"}+ </Button>+ )}<Buttontype="button"variant="outline"diff --git a/tests/studio/playwright_model_config.py b/tests/studio/playwright_model_config.pyindex 49a3aba62a1..46af4e4c758 100644--- a/tests/studio/playwright_model_config.py+++ b/tests/studio/playwright_model_config.py@@ -775,7 +775,8 @@ with sync_playwright() as p:def primary_button(popover):# Anchored: get_by_role matches the accessible name as a substring by default, so- # "Load model" would also match "Reload model". The panel shows exactly one of these four.+ # "Load model" would also match "Reload model". `.first` is the primary: it precedes the+ # separate Save settings button (#10216).## One locator for all four, not the name seen at lookup: the label follows the runtime# store, which fills in after a page load, so a resident model can read "Load model" anddiff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex 762b9ddc080..8e78bdd90d5 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -1523,6 +1523,71 @@ def test_diffusion_picker_hides_and_clears_unsupported_memory_modes():assert field in page+def _save_button_gate():+ page = _read("features/model-picker/components/model-config-page.tsx")+ save_button = page.split("onClick={handleSave}", 1)[0].rsplit("<Button", 1)[1]+ assert "disabled={" in save_button, "the Save button no longer has a disabled gate"+ return save_button.split("disabled={", 1)[1].split("}", 1)[0]+++def test_save_settings_waits_for_gguf_classification():+ """Save without load (#10216) must wait for classification, or it persists (locally and to+ the API override) settings the diffusion sanitizer would strip."""+ gate = _save_button_gate()+ assert "stagedMetadataPending" in gate, gate+++def test_save_settings_waits_for_the_vram_budget_to_settle():+ """A Save during a budget PUT would toast "Settings saved." while the in-flight load+ carries the config captured before the click."""+ gate = _save_button_gate()+ assert "budgetSettling" in gate, gate+++def test_forget_settings_is_not_locked_by_unloadable_extra_args():+ """Forget only deletes, so invalid saved llama args must not lock it: the args gates+ apply to a save only."""+ gate = " ".join(_save_button_gate().split())+ assert "(remember && ((!extraArgsLoadable && !sharedExtraArgsCleared) ||" in gate, gate+ assert "sharedExtraArgsRefused || extraArgsHydrating))" in gate, gate+++def test_the_run_settings_footer_does_not_reflow_under_the_pointer():+ """A footer that wraps on demand moved Load ~30px between mousedown and mouseup when the+ blur-committed draft mounted Save, so the click was never dispatched (#10216)."""+ src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())+ before = src.split("<Checkbox id={rememberId}", 1)[0]+ footer = before.rsplit("<div", 2)[1]+ assert "flex-wrap" not in footer, footer[:200]+ assert "variant ===" not in footer and "flex flex-col" in footer, footer[:200]+++def test_save_settings_is_not_rendered_when_it_could_do_nothing():+ """A never-configured model must not show a dead "Forget settings" (#10216)."""+ src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())+ before = src.split("onClick={handleSave}", 1)[0].rsplit("<Button", 1)[0]+ guard = "!persistenceOnly && (remember || savedRemember) && ("+ assert guard in before, before[-160:]+ assert "</Button>" not in before.rsplit(guard, 1)[1]+++def test_save_settings_reflects_the_context_it_pinned():+ """Save stays on the page, so a pinned context must show; a forget must not pin one."""+ src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())+ handler = src.split("const handleSave = () => {", 1)[1].split("const handleRun", 1)[0]+ assert (+ "if ( remember && effectiveRuntimeConfig.customContextLength !== config.customContextLength"+ in handler+ )+ assert (+ "setConfig((current) => ({ ...current, customContextLength: "+ "effectiveRuntimeConfig.customContextLength, }));" in handler+ )+ # update() re-marks the draft edited right after persistConfig cleared it, and an edited+ # draft refuses newer server settings on the next hydration.+ assert "update(" not in handler++def test_legacy_migration_is_idempotent_and_non_destructive():"""The v1->v2 localStorage migration (unsloth_load_settings -> unsloth_model_configs)is invoked on every store read, so it must be idempotent: repeated reads, browser@@ -2863,11 +2928,11 @@ def test_only_gguf_configs_are_mirrored_to_the_server():resolver indexes GGUFs only."""src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())assert (- "if ( !saveFailed && (target.apiLoadable ?? target.isGguf) && !nativePathToken ) "+ "if (saved && (target.apiLoadable ?? target.isGguf) && !nativePathToken) ""{ syncModelOverride(" in src)# The local save is not behind the same gate.- assert "if (remember) { saveFailed = !savePerModelConfig(" in src+ assert "const saved = remember ? savePerModelConfig(" in srcdef test_a_native_leased_gguf_is_not_mirrored_to_the_server():@@ -2875,7 +2940,7 @@ def test_a_native_leased_gguf_is_not_mirrored_to_the_server():/api/inference/status reports model_identifier as null for it, so the checkpoint thebrowser keys settings by is the bare file name the backend echoes back."""page = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())- assert "&& !nativePathToken ) { syncModelOverride(" in page+ assert "&& !nativePathToken) { syncModelOverride(" in pageassert ("const nativePathToken = target.meta.nativePathToken ?? ""(isActiveModel ? activeNativePathToken : null);" in page@@ -2940,9 +3005,9 @@ def test_reasoning_resets_reach_the_server_without_making_backfill_destructive()page = _read("features/model-picker/components/model-config-page.tsx")assert "baseline.reasoningBudget !== -1" in page- assert "normalizedRuntimeConfig.reasoningBudget === -1" in page+ assert "normalized.reasoningBudget === -1" in pageassert 'baseline.reasoningBudgetMessage !== ""' in page- assert 'normalizedRuntimeConfig.reasoningBudgetMessage === ""' in page+ assert 'normalized.reasoningBudgetMessage === ""' in pagedef test_a_recipe_restores_the_previous_model_at_its_reasoning_budget():@@ -3149,14 +3214,14 @@ def test_the_settings_page_judges_the_config_storage_actually_keeps():"""savePerModelConfig normalizes before deciding, and the runtime hands this pageSpeculative Decoding "auto", which canonicalizes to null."""src = " ".join(_read("features/model-picker/components/model-config-page.tsx").split())- assert (- "const normalizedRuntimeConfig = normalizePerModelConfig( effectiveRuntimeConfig, );" in src- )- assert "const defaultConfig = isDefaultConfig(normalizedRuntimeConfig);" in src+ # Load and Save (#10216) both go through persistConfig.+ assert "const normalized = normalizePerModelConfig(next);" in src+ assert "defaultConfig: isDefaultConfig(normalized)" in src# The same object goes to storage and to the server, or they disagree again.- assert "target.ggufVariant, normalizedRuntimeConfig, evicted," in src- assert "remember ? normalizedRuntimeConfig : null," in src+ assert "savePerModelConfig(configId, target.ggufVariant, normalized, evicted)" in src+ assert "remember ? normalized : null," in srcassert "isDefaultConfig(effectiveRuntimeConfig)" not in src+ assert "isDefaultConfig(next)" not in srcstore = " ".join(_read("features/model-picker/model-config/per-model-config.ts").split())assert "export function normalizePerModelConfig(" in store@@ -3272,7 +3337,7 @@ def test_the_sidebar_settings_editor_reseeds_when_the_live_config_lands():assert "!isModelConfigDraftEdited(draftKey) &&" in pageassert "markModelConfigDraftEdited(draftKey)" in page# Only once the write landed, or the next read replaces values still on screen.- assert re.search(r"if \(!saveFailed\) \{.*?clearModelConfigDraftEdited\(draftKey\);", page)+ assert re.search(r"if \(saved\) \{.*?clearModelConfigDraftEdited\(draftKey\);", page)# An unticked Remember is a pending Forget the read's own guard would pass and re-tick.assert "markModelConfigDraftEdited(draftKey); setRemember(checked === true);" in page# A peer that fixed the text lifts this editor's retained refusal.