Skip to content

Studio: save a model's run settings without loading it - #10216

Merged
danielhanchen merged 15 commits into
unslothai:mainfrom
NilayYadav:save-settings-without-load
Sep 29, 2026
Merged

danielhanchen merged 15 commits into
unslothai:mainfrom
NilayYadav:save-settings-without-load

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #10168.

The run settings panel only let you save settings as part of loading the model. If you wanted to set up a model ahead of time, you had to load it every time.

This adds a Save settings button next to Load model. It stores the settings for that model, including the copy the API uses for its own loads, and leaves the model unloaded. The footer now wraps in the picker so the "Remember for this model" label is not cut off.

Tested in the browser against a fresh install of main and this branch. On main the button does not exist and nothing is saved. On this branch clicking it shows "Settings saved.", the server has the new settings, and the model stays unloaded.

Before / after

Run settings for an unloaded on-device GGUF (gemma-3-270m-it-GGUF UD-Q4_K_XL), merge base 7617fc398 vs head 332ed632e. Before, the footer only offers Load model and Reset. After, Save settings sits between them; clicking it shows "Settings saved.", stores the config, and no model is loaded.

Run settings footer before and after

@NilayYadav
NilayYadav force-pushed the save-settings-without-load branch from 725c63a to 3b2acad Compare September 7, 2026 14:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T13:27:25.346326Z d1b16ab New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@NilayYadav

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
Resolve conflicts with main's footer rework (primary action first, pill buttons) and the
reasoning-budget reset options on syncModelOverride. Save settings now sits between Load and
Reset in a stacked footer for both variants. Forget settings is no longer disabled by
unloadable llama arguments, since it only deletes the stored entry. The reset step in the
picker suite uses main's click_and_wait_for_commit instead of waiting for the native context,
which never arrives when auto-fit caps it.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 29, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 29, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 29, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 29, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 29, 2026
# Conflicts:
#	tests/studio/playwright_model_config.py
@danielhanchen
danielhanchen merged commit 7a8c055 into unslothai:main Sep 29, 2026
40 of 43 checks passed
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 23, 2026
unslothai#14515)

Fixes unslothai#10631

## Problem

Studio already saves each model's run settings (context length, KV
cache, speculative decoding, GPU placement), and the OpenAI-compatible
auto-switch applies them when an API request loads that model (unslothai#7473,
unslothai#11904, unslothai#10216). Sampling is the gap:

- Chat only remembers the last values used with each model. There is no
way to say "this is how I want this model to sample" outside the chat
sidebar.
- An API request that switches to a model and leaves `temperature`,
`top_p` and so on unset always gets the model's recommended values.
Nothing the user set in Studio reaches it.

## What this adds

A **Save for this model** button at the bottom of Chat settings, below
Retrieval. It saves the sampling currently shown (Temperature, Top P,
Top K, Repetition Penalty, Presence Penalty, and Min P when it is set to
a custom value) as the loaded model's defaults. It is hidden for
external providers. Seed and Max Tokens are not part of it.

A save writes to two places:

- **API requests.** The values go to a per-model, per-account server
store (`model_sampling_defaults`, `PUT
/api/settings/model-sampling-defaults`). `resolve_effective_sampling`
reads it, so `/v1/chat/completions`, `/v1/completions`, `/v1/responses`
and `/v1/messages` fill unset fields from it, including the request that
switches the model in. The order is: operator `UNSLOTH_SAMPLING_*` pin,
then the request's own value, then the saved default, then the model's
recommendation, then the schema default. The `/sampling-defaults` route
behind the API page's example request uses the same function.
- **Chat.** The same values go into the per-model memory Chat already
restores on every load, so new chats with that model start from them.
Without the button, sampling edits made inside a conversation stay with
that conversation. If a slider moves while the save is in flight, the
newer value is kept on screen.

How defaults are keyed:

- One row per model, not per quant.
- A cache snapshot path is stored under its repo id, so a new revision
still finds the row.
- Repo ids and Windows, UNC and WSL paths match regardless of case,
using the launch overrides' `_fold_case_insensitive_path` rule. POSIX
paths match exactly.
- The server resolves reads itself, so the browser does not mirror these
rules.

## Not changed

- Nothing changes for anyone who never saves a default. The store is
empty, the lookup returns early and resolution is the same as before.
- Run settings and load overrides are untouched. The sampling store is
separate from the launch override map on purpose: a row there counts as
a load override, can shadow a broader repo row and re-ticks "Remember
for this model".
- Explicit request values and operator pins still win.
- `/v1/completions` on a vLLM or SGLang engine still forwards the body
without any per-model fill, as before.
- The button and its save code are loaded lazily. The startup bundle
grows by 274 B raw / 131 B transfer, inside the existing budget, so
`scripts/check-bundle-budget.ts` is unchanged.

## End to end

Real Studio installs at the merge base and at this branch, CPU only,
`unsloth/gemma-3-270m-it-GGUF` Q8_0, auto-switch on. Values are what
llama-server reports in `/slots` after the request:

| | merge base | this PR |
|---|---|---|
| Save temperature 0.123, top_k 7, repetition 1.17 | route absent (405)
| 200 |
| `/v1/chat/completions` that switches the model in, no sampling fields
| temp 1.0, top_k 64, repeat 1.0 (recommended) | temp 0.123, top_k 7,
repeat 1.17 |
| Same request with `temperature: 0.9` | 0.9 | 0.9 |

## Cost

`resolve_effective_sampling` runs once per request, never per token. The
store read reuses the 2 s cached setting the auto-switch already uses,
and an index is rebuilt only when that cache refreshes. Per-call timing
on this host (median of 5 x 20k calls, base and head alternating, two
rounds):

| | base | head |
|---|---|---|
| nothing saved | 6.5 / 8.1 us | 8.6 / 9.9 us |
| 50 models saved, miss | - | 10.1 / 10.0 us |
| 50 models saved, hit | - | 10.4 / 11.4 us |

## Tests

`studio/backend/tests/test_model_sampling_defaults.py` (16 tests)
covers:

- precedence against explicit values, operator pins and the Qwen3
thinking table;
- the `/v1/completions` passthrough `repeat_penalty` alias;
- snapshot path and quant-qualified ids;
- POSIX and Windows path matching, and ambiguous case folds;
- out-of-range and NaN values dropped, idempotent saves, clearing;
- an unreadable store never failing a request;
- `/sampling-defaults` reporting the saved value.

Reverting only the resolution hook makes 5 of them fail. Backend tests
touching the settings routes fail the same 27 pre-existing cases on the
merge base and on this branch, and nothing new. Frontend: `tsc` clean,
`vite build` OK, `npm test` 13619 passed, 0 failed.

## Screenshots

Bottom of Chat settings with a GGUF loaded, merge base vs this PR.
Clicking the button on the right stored the sampling shown for the
model, and `/api/inference/sampling-defaults` then reported those
values:

![Save for this model at the bottom of Chat
settings](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14515/chat_bottom_pair-9a2d30120e79.png)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit that referenced this pull request Oct 25, 2026
## Summary


`tests/studio/test_model_picker_contracts.py::test_the_run_settings_footer_does_not_reflow_under_the_pointer`
fails on main since #15104 (pinned Run settings footer). It shows up in
`Repo tests (CPU, studio)` on unrelated PRs, for example #15123:

```
E   AssertionError:  className={cn( "mt-5", // Sticky offsets start inside the scroller's 18px padding ... variant === "page" && "sticky -bottom-4.5 ...
E   assert ('variant ===' not in ' className=...
```

The test found the footer as "the third `<div` back" from the Remember
checkbox. #15104 wrapped the footer in a new sticky `<div>`, so that
count now lands on the wrapper. The wrapper's `variant === "page"`
condition only pins the footer to the panel edge. The footer itself is
still `flex flex-col gap-3.5 border-t ...`, with no `flex-wrap` and no
variant switch. So the #10216 invariant (Load must not move between
mousedown and mouseup) still holds, and only the locator broke.

## Change

- Walk the `<div>` open and close tags before the checkbox, so only the
divs that actually enclose Remember count. Sibling divs that already
closed are skipped, and `>` inside JSX braces is handled.
- The footer is the enclosing div that draws the rule (`border-t`). It
must be `flex flex-col`, must not switch on `variant`, and must not
wrap. The divs inside it, and the one wrapper just outside it (the
sticky pin), must not carry `flex-wrap` either.

## Verification

- On main: fails as above. With this change: `201 passed` for the whole
file.
- The `model-config-page.tsx` from before #15104 still passes, so the
check covers both layouts.
- Sabotage, each against the current component, each makes the test
fail:
  1. `flex-wrap` on the footer column
2. the footer's layout switched on `variant` (`flex flex-row` for the
page variant)
  3. `flex flex-wrap` on the sticky wrapper
LeoBorcherding added a commit that referenced this pull request Nov 10, 2026
…hem from the model menu (#12608)

## Why

Since #10216 you can save a model's run settings without loading it.
Once you do that for a few models, they get hard to manage:

- Nothing in the model list shows which models have saved settings, so
you have to open each one to check.
- There's no way to clear a model's saved settings without opening its
panel.

## What's new

- **Saved models keep their gear visible.** A model with saved run
settings keeps its row buttons on screen instead of showing them only on
hover. Its gear's tooltip reads "Edit saved run settings".
- **Reset run settings in the ⋮ menu.** This item only shows when the
model has saved settings. One click clears them without opening the
panel. If a saved Run preset is selected or pinned for the model, it
goes back to Default, the same way main's server-side forget does. The
toast ("Run settings reset for …, takes effect the next time it loads")
offers Undo for 10 seconds, and Undo restores the settings and the
preset.
- **Save state under the model name.** The Run Settings panel shows
main's existing save status in its header ("Saved for this model",
"Unsaved changes", "Loads every time", "Using the default settings" and
so on), so you can see it without scrolling to the footer. The footer
button is renamed **Reset all**.
- The new loaded-model row from main gets the same visible gear and the
same row-menu reset.

Nothing new becomes editable. Every gear here already opens on main.
This PR shows what's saved and lets you take it back.

## Not changed

This PR doesn't change what gets saved, the storage format, or what's
sent when the model loads. Reset goes through the same path as the
existing Forget settings. If a model was saved again after you reset it,
a later reset that started from older data won't wipe that newer save.

## Before / after

Two isolated Unsloth Studio installs on a MacBook Pro M5 (macOS 26): the
merge base with main `4089c57a82` (before) and this branch `73c60cd98a`
(after). Same seeded cache, two small GGUFs. On both sides
gemma-3-270m-it-GGUF UD-Q4_K_XL has KV cache q8_0 and Parallel Slots 2
saved through the panel's own Save. SmolLM2-135M has nothing saved.

**Model list, mouse away from every row.** The saved model keeps its
gear and ⋮ visible; the unsaved one doesn't. Its gear tooltip reads
"Edit saved run settings".

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/night-shift-tester/assets/unsloth-12608-v3/pr12608_pair_00.png"
width="760">

**Row ⋮ menu.** "Reset run settings" appears only for a model with saved
settings.

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/night-shift-tester/assets/unsloth-12608-v3/pr12608_pair_01.png"
width="760">

**Run Settings panel.** "Saved for this model" under the model name, and
the footer button is now "Reset all".

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/night-shift-tester/assets/unsloth-12608-v3/pr12608_pair_02.png"
width="900">

**After Reset run settings.** The row's buttons go back to hover-only,
and the toast keeps Undo for 10 seconds.

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/night-shift-tester/assets/unsloth-12608-v3/after_4_reset_toast.png"
width="760">

## Tests

Measured at `73c60cd98a` (main `4089c57a82` merged):
- 69 frontend tests across `remembered-run-settings`, its
legacy-snapshot test, `override-forget-alias-order` and
`recommended-curated-row-metadata`. They cover the saved-settings
lookup, reset + Undo (preset included), a newer save surviving a stale
Undo, and forget ordering across aliases.
- `test_model_picker_contracts.py`: 201 pass. The 2 failures
(`test_remembered_slots_are_read_through_the_cached_repo_alias`,
`test_a_standalone_gguf_has_one_settings_identity_in_the_picker`) fail
the same way on main.
- `tsc` clean, startup bundle within budget. The contract and Playwright
tests look for **Reset all** by its exact name.
- Codex is clean at this tree on the mirror
([LeoBorcherding#131](LeoBorcherding#131)).

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Allow saving cutom settings without loading the model

3 participants