Skip to content

Studio: keep each model's recommended sampling after a system prompt edit - #18011

Merged
Lyxot merged 13 commits into
unslothai:mainfrom
oobabooga:studio-keep-recommended-sampling
Nov 17, 2026
Merged

Lyxot merged 13 commits into
unslothai:mainfrom
oobabooga:studio-keep-recommended-sampling

Conversation

@oobabooga

@oobabooga oobabooga commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Editing the system prompt on Default stops Studio from applying each new model's recommended sampling. Load Qwen3-0.6B, type a system prompt in Run settings, then load Gemma 4 E2B for the first time: Gemma keeps Qwen's temperature 0.6 and top-k 20 instead of its own 1.0 and 64. Switching away then saves those values as Gemma's settings.

Any preset edit sets activePresetSource to modified. Model loads and Qwen thinking-mode changes only apply recommended values under builtin-default, so a prompt edit blocks every sampling value. Moving one slider has the same problem: changing Temperature also keeps the previous model's top-k, max tokens and the rest.

With this PR, presetEditedKeys records which sampling controls the user changed. A prompt edit no longer blocks recommended sampling. Changing Temperature keeps that temperature, while the other values follow the next model. The same rule is used for model loads, status refreshes, comparison panes and Qwen thinking changes.

Custom presets still keep all their values, and a model with remembered settings still uses them. Picking a preset clears the edited keys.

The edited keys are saved one key at a time, so edits from two open tabs add up instead of overwriting each other. Settings saved as modified before this change have no record of which controls changed. When the backend starts, it marks every control as edited for them, so they keep the old behavior until a preset is picked again.

Verification

Studio before and after, starting with empty settings. Edits were made in Run settings; models were loaded through the API and picked up by a fresh /chat page load. These are the temperature / top-p / top-k values in the outgoing chat request:

Scenario Before After
Qwen3-0.6B, edit the system prompt, then Gemma 4 E2B 0.6 / 0.95 / 20 1.0 / 0.95 / 64
Gemma 4 E2B, set Temperature to 0.3, then Qwen3-0.6B 0.3 / 0.95 / 64 0.3 / 0.95 / 20

The edited system prompt was still sent after the switch in both builds. These runs used the first revision of this PR. Later commits changed how the edited keys are saved, not how they are applied.

New tests cover prompt and slider edits, preset changes, per-model memory, Qwen thinking changes, saving and restoring the edited keys, edits made before settings finish loading, two open tabs, and the backend upgrade of older settings. Typecheck and the backend chat settings and chat history route tests (116) pass. The full frontend suite has 18 failures, and none of them are in chat settings or presets: some test files need a newer Node than the one I ran, and the others depend on locale or time zone.

This touches the same Qwen checks as #15279, so whichever merges second will need a rebase.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T07:07:19.126944Z 0c85014 Manual request
ℹ️ 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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbb98e4a73

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/storage/studio_db.py Resolved
@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15045d1994

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/storage/studio_db.py Resolved
@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 09fa47138a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Lyxot

Lyxot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Pushed a few changes on top:

  • Reset releases the keys it restores. The Reset button under Sampling sets temperature, top-p and the rest back to the loaded model's recommendation, but it left those keys held. On an edited Default, the next model then kept this model's recommendation as if the user had moved those sliders, which is the same leak this PR fixes. Reset now calls a new store action, releasePresetEditedKeys, for the keys it sets. maxTokens is not reset, so it stays held. Under a custom preset, nothing changes.
  • editedSamplingKey in preset-policy.ts now maps a Run settings edit to the recommended key it moves (minPMode maps to minP), and has its own test.
  • The route's presetEditedKeys Literal is built from PRESET_EDITED_KEYS instead of a second hand-written list.
  • Doc fixes on presetEditedKeys and setActivePresetSource, and one guard that could never fire is removed.
  • Tests:
    • A test that pins every place a recommendation is applied (load, status refresh, Compare pane, and the Qwen layer in each) to the held-key filter.
    • A Compare pane test for an edited Default.
    • Each new test was checked to fail when the code it covers is reverted.
  • Merged the latest main, which had a conflict in test_chat_settings_payload.py. Both sides only added tests.

Checked live on MLX:

  1. Load gemma-3-270m and edit the system prompt, then load SmolLM-135M: SmolLM ran its own sampling.
  2. A temperature of 0.4 survived switching to Qwen3-0.6B, and Qwen's top-k 20 was applied.
  3. Turning thinking off applied top-p 0.8 and kept the 0.4.
  4. Reset applied 0.7 and released temperature.

@Lyxot

Lyxot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 0c8501469d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Lyxot

Lyxot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Wrap-up for 0c8501469d8:

Codex: "Didn't find any major issues" in round 1: #18011 (comment)

CI. The upstream jobs stayed queued, so CI ran on a staging copy with the same head (Lyxot#254, now closed). Results: 55 passed, 8 failed, 1 cancelled, 2 skipped. All of the frontend, build, Composer (all browsers, including Safari), Windows frontend unit tests, Python 3.11 floor, and Python 3.13 a-f (which covers test_chat_settings_payload.py and the routes.chat_history import) passed. None of the 8 failures come from this PR:

Source lint, CPU rest, gloo-tp-env, studio and Core zoo also fail on other unrelated staging PRs opened today.

Changes during this pass:

  • Merged the latest main into the branch to resolve the conflict in test_chat_settings_payload.py.
  • Resolved the four Codex threads; each one was already fixed in 15045d1 or 09fa471, and I checked each fix against the code.
  • No code changed after the Codex review. The earlier comment lists the code changes.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Codex has no remaining findings, staging CI passed (the failures were already on main), and a trial merge with current main passes the related tests.

@Lyxot
Lyxot merged commit b8b4d93 into unslothai:main Nov 17, 2026
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.

3 participants