Skip to content

studio: preserve standalone gguf settings in compare mode - #11311

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
mahiatlinux:fix/studio-lm-studio-settings-persistence
Sep 21, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
mahiatlinux:fix/studio-lm-studio-settings-persistence

Conversation

@mahiatlinux

Copy link
Copy Markdown
Contributor

Compare mode reloads a standalone GGUF with the quant label reported by inference status, but the picker saves its settings without a variant. resolveResidentInitialConfig now uses that saved identity for standalone files while preserving variant-specific settings for directories and Hub repositories.

Real Qwen3-0.6B Q4_K_M comparison: a standalone model saved with 6,144 context tokens and 3 slots previously reloaded with 40,960 tokens and 1 slot. It now restores 6,144/3. The directory model retains 4,096/2.

Before and after

Checks:

  • 146 focused Node tests pass; three new regression cases fail on base.
  • Frontend typecheck and production build pass.
  • Real two-turn compare flow passes in Chromium and Firefox. Chromium base/head runs use separate installs and application homes; screenshot captions report measured backend status.

@mahiatlinux

mahiatlinux commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Verified against base c7d8980a206d9724630f7081e29d64dd6141c538 and head 9e42640f4663907e6a80bb273436d436c9bd634b using separate Studio installs, application homes, model copies, and browser contexts.

The reproduction saves 6,144 context tokens and 3 parallel slots for a standalone Qwen3-0.6B Q4_K_M file, enters Compare with that resident model on the left and an LM Studio publisher/model directory on the right, then sends two prompts. The second turn forces the left model to reload with the quant label returned by inference status.

Reload Base request Base backend status Head request Head backend status
Standalone GGUF Context 0, slots unset Context 40,960, slots 1 Context 6,144, slots 3 Context 6,144, slots 3
LM Studio directory Context 4,096, slots 2 Context 4,096, slots 2 Context 4,096, slots 2 Context 4,096, slots 2

Playwright drove real UI controls and real inference through llama-server b11027 with cached Qwen3-0.6B Q4_K_M weights. Linux x86_64, Python 3.13.14, Node 26.8.2, Playwright 1.61.1, Chromium 149.0.7827.55, Firefox 151.0. Viewport: 1440 × 1100. Chromium ran the same scene on base and head; Firefox independently passed the head scene. No mocked APIs or stores.

Two-turn compare before and after

Screenshots show the completed comparison; captions report the measured load requests and backend status. The fix changes restored settings, not the chat layout. Originals: before, after.

Checks: 146 focused Node tests pass; the three new standalone-file cases fail on base and pass on head. Removing the lookup fix reproduces all three failures. npm run typecheck, npm run build, and git diff --check pass. ESLint reports the identical pre-existing no-restricted-imports violation for @/features/chat/external-providers on base and head.

Review completed with no findings on mirror head d1c502b09f. Its changed files match source head 9e42640f4663907e6a80bb273436d436c9bd634b exactly; all 146 focused tests also pass on the mirror merge result. No fixes needed to be transferred. Both PRs remain open and unmerged. At completion, source CI had no failures, with checks still queued or running.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed this against main, where resolveResidentInitialConfig in per-model-config.ts still reads with the status-reported quant while sidebar-model-config.tsx saves standalone files with no variant, so the saved context and slot counts are dropped on reload. Will get this reviewed.

…ookup

resolveResidentInitialConfig now drops the reported quant before the direct
lookup when the id names a standalone GGUF file, so the contract test's
literal source assertion no longer matched and the studio repo tests failed.
Assert the new call while keeping what the contract is for: the raw
identifier is still read before the cached-repo alias.
Dropping the reported quant for the direct lookup also drops the records a
picker before unslothai#7473 wrote, which keyed the label straight through. Those are
still read on main today, so the fix as it stood blanked settings for anyone
who configured a loose .gguf before that release.

Read the bare path first and fall back to the label, which is the order the
backend already reads its own override candidates in.
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #11311, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#51.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1 — reviewed mirror 972c40c8a6 (this PR's 4993377e0)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 972c40c8a6

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 972c40c8a6 (this PR's 4993377e0).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit dfb130d into unslothai:main Sep 21, 2026
36 of 39 checks passed
@mahiatlinux
mahiatlinux deleted the fix/studio-lm-studio-settings-persistence branch September 25, 2026 05:32
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…11311)

* studio: restore saved settings for standalone gguf reloads

* studio: update the resident-config contract test for the standalone lookup

resolveResidentInitialConfig now drops the reported quant before the direct
lookup when the id names a standalone GGUF file, so the contract test's
literal source assertion no longer matched and the studio repo tests failed.
Assert the new call while keeping what the contract is for: the raw
identifier is still read before the cached-repo alias.

* studio: keep reading a standalone gguf record keyed by its quant label

Dropping the reported quant for the direct lookup also drops the records a
picker before unslothai#7473 wrote, which keyed the label straight through. Those are
still read on main today, so the fix as it stood blanked settings for anyone
who configured a loose .gguf before that release.

Read the bare path first and fall back to the label, which is the order the
backend already reads its own override candidates in.

* studio: tighten the comments on the standalone settings lookup

---------

Co-authored-by: Daniel Han <[email protected]>
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 26, 2026
…load (unslothai#15139)

The model picker, the compare pane and auto-load each built two payloads
from the same settings: one for the `/validate` preflight and one for
`/load`. `validateModel` then re-serialized the first through a
hand-kept allow-list. That is 13 payload literals across
`use-chat-model-runtime.ts`, `shared-composer.tsx`, `chat-adapter.ts`
and `chat-api.ts`, and every new load setting had to be added to each
one.

The history shows the copies drifting apart:
- unslothai#9410 added Checkpoints and the draft KV dtype to every load and never
to the allow-list.
- unslothai#13596 (vLLM/SGLang KV dtype, seed, memory limit) had to edit the
picker, compare and `chat-api.ts` separately.
- The managed-engine offer (unslothai#13135, then unslothai#13229) and GGUF settings
preservation (unslothai#9562, then unslothai#11311) each landed on the picker first and
needed a follow-up PR for compare and auto-load.

The preflight exists so Studio refuses a load before it unloads the
working model, and also to guard training. When `/validate` judges a
different command from the one `/load` runs, it approves a load that
`/load` then refuses after the unload, or refuses one that would fit.

## Changes

- **One request, sent twice.** Each path builds one `LoadModelRequest`
and sends it to both `/validate` and `/load`. Only the load-only fields
are added at the `/load` call: request id, lease, force flags and
`alongside`.
- **The allow-list is gone.** `/validate`'s body is the load request;
the route ignores load-only fields. `validateRequestBody` fills defaults
for the non-nullable fields only.
- **`llamaServerLoadFields`** owns the one rule for llama-server's
knobs, which the three paths used to spell out with slightly different
gating:
- reasoning budget, batch sizes, server tuning and pass-through args are
sent for GGUF only;
- diffusion GGUF requests omit custom reasoning overrides, server tuning
and pass-through args, while still forwarding batch sizes;
  - blank values are omitted, never sent as null.
- **The picker re-baselines once.** On a model switch it re-baselines
its per-model settings before `/validate`, instead of mirroring that
reset in a second set of `validate*` variables.
- **New module.** `lib/load-request.ts` holds the three helpers.
Production code is 225 lines shorter.

## Preflight and load now agree

- **The three dropped settings now reach `/validate`.** `validateModel`
dropped `ctx_checkpoints`, `spec_draft_cache_type` and `tensor_split`.
Checkpoints affect sizing; a load with Checkpoints set was priced at the
default 32. Forwarding the draft KV dtype and GPU split makes validation
apply the same explicit-setting precedence over inherited flags as
loading. The training coexistence guard does not directly price draft KV
memory.
- **The picker and compare preflights now send the speculative mode and
depth.** They omitted `speculative_type` and `spec_draft_n_max`, so
validation used the default Auto mode, which already counts some
drafters but can differ from the selected mode. The preflight now
receives the same selected values as loading. Auto-load already sent
them.
- **A model switch with a staged run-settings config is now sized like
the load.** The picker's preflight used Auto layers and no context pin,
while `/load` used the staged layer count and context length.
- **Compare and auto-load no longer send llama-server's pass-through
args or tuning to a diffusion GGUF.** The diffusion runner takes none of
them, and the picker already left them out.

## Validation

- **Wire check:** the same GGUF request was sent through the real
`chat-api.ts` of each checkout, comparing what `/validate` receives with
what `/load` receives. On `main`, `/validate` is missing `tensor_split`,
`spec_draft_cache_type` and `ctx_checkpoints`; here it is missing
nothing.
- **Contract test:** `chat-load-request-one-builder.test.ts` reads
`ValidateModelRequest` from `studio/backend/models/inference.py`. It
fails if any field it prices cannot ride `LoadModelRequest` or is not
forwarded. It also table-tests the llama-server knob rule and checks
that every path sends one request.
- **Frontend:** `npm test` gives 13,857 passed. The 3 failures are
HTML/TextEdit charset decoding tests that fail the same way on `main` in
this environment. Typecheck is clean with both `bun check` and `tsc`.
- **Python contract tests:** the 30 files in `tests/studio` that read
these sources give 807 passed and 63 skipped. The two Playwright files
cannot import here, on `main` too.
- **The auto-load harness** (`test_chat_autoload_failure_gate.py`) now
inlines the real `load-request.ts` instead of a copy; all 81 scenarios
pass.
- **Rewritten tests:** text-matching tests that counted the duplicated
literals now assert one request per path. The rule they pinned is tested
behaviourally in the new file.

| Case | Before | After |
|---|---|---|
| GGUF load with Checkpoints, draft KV dtype or a per-GPU split |
`/validate` sent none of the three; used default checkpoints and could
resolve inherited flags differently | Same fields as `/load` |
| Picker or compare load with a DFlash/DSpark drafter | Preflight sized
Auto rather than the selected speculative mode | Selected mode
forwarded, as in `/load` |
| Model switch from a staged config with a context length and manual
layers | Preflight sized Auto context and Auto layers | Sized like
`/load` |
| Compare or auto-load of a diffusion GGUF with remembered extra args |
Args and tuning sent to a runner that takes none | Not sent, as the
picker already did |

Not in this PR: auto-load still ignores a model's saved engine
(vLLM/SGLang) and loads it on the default engine. That looks deliberate
(background loads avoid starting a managed engine), so it is left as is.

---------

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.

2 participants