Repository navigation
feat(studio): presets include load settings (#7347) - #7352
danielhanchen merged 5 commits into
Conversation
Presets previously stored only sampling params (temperature, top_p, etc.). Extend them with an optional loadConfig blob that captures context length, KV cache dtype, speculative decoding, and GPU layer knobs from the current runtime when saving. - Apply loadConfig when switching presets or hydrating on startup - Show a short summary under the preset controls - Prompt to reload when a model is already loaded Fixes unslothai#7347
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33c365d492
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| maxSeqLength: normalizeMaxSeqLength(snapshot.maxSeqLength), | ||
| kvCacheDtype: snapshot.kvCacheDtype ?? null, | ||
| speculativeType: normalizeSpeculativeType(snapshot.speculativeType), |
There was a problem hiding this comment.
Treat default load knobs as empty
With a fresh/default runtime, currentRuntimePerModelConfig({ includeMaxSeqLength: true }) returns the app default max sequence length (4096) and the default speculative mode (auto), so capturePresetLoadConfig() produces a non-empty loadConfig even though the built-in Default preset has none. That makes hasUnsavedPresetChanges mark Default (and older presets without loadConfig) dirty immediately, enabling “Save”/copy behavior on first open when nothing changed. Coalesce default maxSeqLength/auto speculative mode to the empty preset load config, or give built-ins an equivalent loadConfig.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 11c71466: capturePresetLoadConfig() now runs through coalesceDefaultLoadKnobs(), which strips app-default maxSeqLength (4096) and speculativeType (auto) before save/compare. Built-in Default and legacy presets without loadConfig no longer show as dirty on first open.
| if (activeDefinition?.loadConfig) { | ||
| applyPresetLoadConfig(activeDefinition.loadConfig); |
There was a problem hiding this comment.
Don’t replay stale preset load settings on hydration
When a user saves a preset, then later changes load settings such as Max Seq Length or GGUF context without saving that preset again, the current values are still restored by getHydratedSettingsState/per-model config. This unconditional replay of the active preset’s older loadConfig immediately overwrites those restored values on every refresh whenever the active preset has loadConfig, silently reverting the user's current load settings. Only apply the preset loadConfig here when it is known to be the current state, or persist/compare the current load settings separately.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 11c71466: removed the post-hydration applyPresetLoadConfig(activeDefinition.loadConfig) block. Load settings now apply only when the user explicitly selects a preset, so a refresh no longer overwrites newer per-model settings with stale preset data.
| gpuMemoryMode: config?.gpuMemoryMode, | ||
| gpuLayers: config?.gpuLayers, | ||
| nCpuMoe: config?.nCpuMoe, | ||
| selectedGpuIds: null, |
There was a problem hiding this comment.
Preserve GPU pin when applying presets
PresetLoadConfig intentionally excludes per-model-only fields, but passing selectedGpuIds: null clears the active GPU selection every time a preset loadConfig is applied or hydrated. On multi-GPU machines this makes the next reload use automatic/all-GPU placement instead of the user's saved per-model GPU pin, even though presets do not expose or save that setting. Preserve the current GPU IDs rather than resetting an excluded field.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 11c71466: applyPresetLoadConfig() now passes selectedGpuIds: store.selectedGpuIds instead of null, since GPU device selection is intentionally excluded from presets.
| { | ||
| name: saveName, | ||
| params: toPresetParams(params), | ||
| ...(loadConfig ? { loadConfig } : {}), |
There was a problem hiding this comment.
Allow the backend to accept loadConfig
Saving a preset now sends loadConfig inside each customPresets entry, but the /api/chat/settings backend still validates ChatPreset with extra = "forbid" and only name/params fields (studio/backend/routes/chat_history.py:163-167). As soon as this field is present, the PUT is rejected with a 400, so presets with load settings update only local state and disappear after refresh. Add loadConfig to the backend schema/storage contract before sending it from the UI.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0882a8c7: added ChatPresetLoadConfig to studio/backend/routes/chat_history.py and wired it into ChatPreset.loadConfig. PUT /api/chat/settings now accepts presets with load settings; verified locally that saves persist across refresh.
| onParamsChange({ | ||
| ...applyPresetParams(params, p.params), | ||
| }); | ||
| applyPresetLoadConfig(p.loadConfig); |
There was a problem hiding this comment.
Skip load resets for legacy presets
This runs for every preset, including existing custom presets loaded from storage that have no loadConfig. In that case applyPresetLoadConfig(undefined) applies the default per-model config and 4096 max sequence length, so selecting an older sampling/system-prompt preset unexpectedly wipes the user's current context length, KV/speculative settings, and GPU offload knobs. Treat missing loadConfig as “no saved load settings” for legacy/custom presets, or add an explicit default loadConfig only where reset semantics are intended.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 11c71466: applyPreset() only calls applyPresetLoadConfig when p.loadConfig is present, and applyPresetLoadConfig(null) is a no-op. Legacy sampling-only presets no longer reset context/KV/GPU knobs on selection.
| applyPerModelConfigToRuntime({ | ||
| ...DEFAULT_PER_MODEL_CONFIG, | ||
| maxSeqLength: normalizeMaxSeqLength(config?.maxSeqLength) ?? DEFAULT_MAX_SEQ_LENGTH, | ||
| customContextLength: config?.customContextLength ?? null, |
There was a problem hiding this comment.
Distinguish cleared GGUF context from reuse-current
For a preset that owns load settings but intentionally has no custom GGUF context, this stores null; however the same-model reload path treats customContextLength === null as “reuse the currently loaded ggufContextLength” in resolveLoadMaxSeqLength. If a user switches from an 8k-context preset to a KV-only/default-context preset and reloads the already-loaded GGUF, the old 8k context is kept instead of the preset clearing it. Preserve an explicit “preset cleared context” sentinel or force the reload to send the auto/default context when applying such a preset.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Acknowledged — valid edge case. A KV-only preset with customContextLength: null can still reuse the loaded ggufContextLength on same-model reload (resolveLoadMaxSeqLength). Deferred to a follow-up; needs an explicit sentinel or reload-path change. Out of scope for #7347.
Add ChatPresetLoadConfig to the chat settings API schema so presets with load settings no longer 400 on save. Capture effective GGUF context from ggufContextLength when customContextLength is cleared after auto-mode load.
Coalesce default maxSeqLength/speculative/gpu knobs when capturing presets, no-op apply for legacy presets without loadConfig, preserve GPU pin on apply, and stop replaying stale loadConfig during settings hydration.
9b6b5dd to
11c7146
Compare
|
Thanks for the review — addressed the actionable items in FixedP1 — Backend P2 — Default load knobs treated as empty ( P2 — No stale hydration replay ( P2 — Legacy presets skip load reset ( P2 — Preserve GPU pin ( Deferred (follow-up)P2 — Cleared GGUF context vs reuse-current Manual verificationPlaywright flow: load model with ctx 256 + KV |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Reviewed and verified. Presets did not carry load settings, so restoring a preset lost the load configuration. This includes load settings in presets so restoring a preset reapplies them. Confirmed presets round trip the load settings and simulated save and restore. Codex review has no open items. The remaining red CI is pre-existing upstream breakage unrelated to this change. Good to merge. |
Fixes #7347
Problem
Chat presets only saved sampling params (temperature, top_p, system prompt, etc.). Load knobs like context length and KV cache dtype lived in per-model config / the runtime store, so users couldn't save named bundles like "Long context + q8_0 KV".
Fix
loadConfigonPreset(context, KV cache dtype, speculative decoding, GPU layers/mode, tensor parallel)capturePresetLoadConfig()Excluded from presets (by design): chat template override (too large), GPU device pick (machine-specific), tensor split.
Verification