Repository navigation
Studio: fit the context again on a same-model GGUF reload under any preset - #18379
Conversation
…reset On Auto context, resolveLoadMaxSeqLength sent 0 for a GGUF load only when the active preset was the untouched built-in Default. Under a saved preset, or after any Run settings edit (which marks Default as modified), a reload of the same model and variant resent the resident fitted window with max_seq_length_auto_derived. The backend reads a positive max_seq_length as an explicit context and only re-fits it when MTP is forced, so switching the KV cache type, vision or GPUs kept the old window: a change that frees memory never grew it, and one that needs more memory kept the window and gave up something else (the vision projector moved to the CPU). An Auto GGUF load now always sends 0, so a reload is sized like a fresh load whatever preset is active. A typed Context Length is still sent as typed, and Manual memory with fixed layers still pins the resident context before the resolver runs. The replay flag no longer has a sender and is removed from the frontend; the backend keeps accepting it. The memory estimate follows the same rule.
… pin The config page decided whether a same-model reload keeps the resident context from the raw per-model gpuMemoryMode, but an unset per-model mode means the standing preference, which is what performLoad resolves. With 20 fixed layers, no per-model mode, Auto context and a standing Manual preference, Reload sends the resident 32768 while the estimate priced 0. Both fixed-layer checks on the page now go through fixedLayerContextPin, which resolves the mode the same way.
test_fixed_layer_gguf_pins_displayed_context and test_fixed_layer_pin_recomputed_after_committing_gpu_layers matched the inline conditions that moved into fixedLayerContextPin. They now check that the estimate pin reads the rendered loadableConfig and the Apply pin reads the committed effectiveConfig, both with the standing GPU memory preference.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
…ory estimate context Every Auto GGUF load now sends 0, and the resident context is only known for a GGUF, so the estimate's resident fallback and its skip flag can no longer change the result. resolveEstimateContext takes the pin alone.
…and the config page performLoad kept its own copy of the Manual fixed-layer rule that keeps the resident context on a same-model Auto reload, so a change there was only caught by a source match. It now calls fixedLayerContextPin, which takes the resolved GPU memory mode and keeps no context of 0. The MLX estimate uses resolveEstimateContext, which now does the same thing. Tests check the rule by behavior instead of by source text.
Also clarify which loads fixedLayerContextPin answers for, describe resolveEstimateContext for both engines, and drop a comment that repeated the helper's docstring.
|
Pushed four commits on top of a20dfdd after a local review. The fix itself is unchanged.
Related frontend tests (78 files, 1,184 tests), typecheck and |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fa9600aad
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
|
Wrap-up for head Codex: Round 1 raised one P2. With Manual fixed GPU layers and Auto context, it said re-picking a resident kept at its fitted context reloads it. I left the code as is and explained why in the thread. The reuse check only runs on a switch, and a switch sends 0. After that one reload the resident records 0, so it does not repeat. The check also can't tell a kept context from one the user typed earlier. Round 2: "Didn't find any major issues": #18379 (comment) CI: Upstream jobs stayed queued, so CI ran on a staging PR with the same head and base (Lyxot#262, now closed). 56 pass, 3 fail, none from this PR:
Changed during this workflow: the four commits in the change comment above. No code changed after Codex review. |
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. Every Auto GGUF load now fits the context again under any preset, and a typed context is still sent as typed.
Problem
With Context on Auto, reloading the same GGUF model fitted the context again only when the active preset was the untouched built-in Default. Under a saved preset, or after any Run settings edit such as Temperature (which marks Default as modified), changing the KV cache type, vision or the GPU set and clicking Reload model kept the old context:
Cause
resolveLoadMaxSeqLength(preset-policy.ts) returned 0 for an Auto GGUF load only whenpresetSource === "builtin-default". Undercustomandmodified, a same-model reload resentloadedContextLength, the context the resident model was fitted to, withmax_seq_length_auto_derived: true. The backend treats any positivemax_seq_lengthas explicit. It fits a resent value again only when MTP is forced, an exception added by #12231 for the MTP case of this bug (#9550). This PR removes the resend itself.Fix
isReplayedLoadContextand the frontend'smax_seq_length_auto_derivedfield are removed. This reload was their only sender.performLoaddoes. Without this, with fixed layers and an inherited Manual mode, the estimate would price a context of 0 while Reload keeps the resident context.Unchanged
performLoad), since--fit offwould otherwise launch at the native context.max_seq_length_auto_derivedfrom API clients.Verification
Live A/B through the real UI with Playwright. The same backend served the
mainand PR frontend builds. The model wasunsloth/Qwen3.5-9B-GGUFQ4_K_M on an RTX 6000 Ada with about 10 GB of VRAM free, so Auto fits below the native context. The/loadbody was captured in the browser, and the context was read from/api/inference/status.main, Default untouchedmain, Temperature edited0, gets 96,76864512, stays 64,5120, gets 96,76896768, stays 96,768 with--no-mmproj-offload0, gets 64,512, projector on GPUIn the
mainq8_0 to f16 step, the model was already at 96,768 (reached through the Default path) before the Temperature edit.Tests:
replayed-load-context.test.ts, which asserted the resend, is replaced byauto-context-reload.test.ts. The new file also covers the inherited Manual estimate case. The same-model reload cases incontext-pin-survives-load.test.tsand the two fixed-layer contract tests intest_model_picker_contracts.pyare updated.npm testhas 8 failures, the same 8 as on unmodifiedmain, and none involve this change.npm run typecheckpasses, and ESLint output for the changed files is unchanged.