Skip to content

Studio: add 'Load on selection' toggle to configure load options before loading - #6348

Merged
Imagineer99 merged 23 commits into
unslothai:mainfrom
oobabooga:studio-load-on-selection
Jun 17, 2026
Merged

Imagineer99 merged 23 commits into
unslothai:mainfrom
oobabooga:studio-load-on-selection

Conversation

@oobabooga

Copy link
Copy Markdown
Member

Currently you can't change a GGUF model's load settings before loading it. The load options (context length, KV cache, tensor parallelism) only show up in the Model menu after the model is already loaded, and picking a model loads it right away.

This PR adds a "Load on selection" toggle to the "Select model" menu. When it's off, picking a model reads its metadata (downloading the file first if needed), fills in the Model menu on the right sidebar, and shows that menu without loading the model. You set the options you want, then click the new "Load model" button.

image

This is a necessary preliminary step for fine-grained GPU/memory management options, which will be added in a follow-up.

Example

Say I want to load a model with Tensor Parallelism. Today that takes:

  1. Click the model name.
  2. It loads, and the Model menu appears on the right sidebar.
  3. Check Tensor Parallelism.
  4. Click Apply Settings.
  5. The model loads again, this time with the setting.

The first load is wasted work: the full load time and disk reads, just to unload and reload a moment later. With the toggle off, you set Tensor Parallelism first and load once.

How it works

The toggle defaults to on, so existing one-click behavior is unchanged. When off, picking a GGUF stages it instead of loading:

  1. If the file isn't downloaded, the download starts immediately (progress and cancel shown in the sidebar).
  2. Once the file is local, its native context length is read straight from the GGUF header, with no GPU load.
  3. The sidebar shows Context Length, KV Cache, Speculative Decoding, and Tensor Parallelism for the staged model.
  4. "Load model" then loads it once with those settings.

The download happens once (you need the file regardless) and the GPU load happens once, with the options already applied.

A native (dropped or picked) file is read in place via its path token, with no download. If the header can't be read (a failed download, or an expired native lease), the sidebar still opens without the context slider and the model loads normally, with context coming from the load response.

Scope: every model pick respects the toggle. The main chat selector, the Hub "Load" button, native drag-drop, and "Pick a file from disk" all stage when it's off and load immediately when it's on. External models always load immediately, since there's no file or load option to set.

Backend

  • read_gguf_context_length reads {arch}.context_length from the header (about 30 ms, cached by path/mtime/size). It reuses the existing gguf_metadata parser and skip logic, so there is no new GGUF parsing.
  • resolve_local_gguf_path locates the downloaded shard-1 file in the HF cache, read-only. It never triggers a download. For a native file the resolved canonical path is read directly.
  • /validate returns context_length only when the new include_context_length flag is set, so the normal load preflight pays nothing for it. The probe is best-effort: a header-read failure can't fail validation, and a non-positive ceiling reads as absent.

Frontend

  • A staging hook downloads via the existing download manager and reads the header context on completion. The staged context lives on pendingSelection, not the loaded model's ggufContextLength, so it can't pollute the loaded model's display.
  • A staged Load keeps the speculative mode you picked, skipping the reset a normal model switch would apply.
  • The staged pick is abandoned, and its knobs reverted to the loaded baseline, on Cancel, closing the sidebar, switching threads or view, and leaving the chat. This mirrors the incognito reset, so a stale "Load model" button can't resurface.

@oobabooga
oobabooga requested a review from danielhanchen as a code owner June 16, 2026 02:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements a deferred-load staging flow ("Load on selection" off) for GGUF models. When disabled, selecting a model stages it as a pending selection, allowing users to configure load options (such as context length, tensor parallelism, and speculative decoding) before performing the actual GPU load. To support this, the backend can now read the native context length directly from the local GGUF header, and the frontend uses this metadata to populate the context slider. The review feedback points out an outdated comment in chat-settings-sheet.tsx that incorrectly states certain options cannot be configured during staging, and suggests updating it to match the actual implementation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@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: 0f0f33858a

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

@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: 6f13924475

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

Comment thread studio/backend/routes/inference.py Resolved

@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: 98700e0c6e

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

@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: 3669c8ad66

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

@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: 61a0d07385

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

@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: 97fb7ef6d9

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

@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: 109639a625

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

@Imagineer99

Copy link
Copy Markdown
Member

There are a couple UX gaps here that may be worth addressing before merge.

First, when “Load on selection” is disabled, it may not be instantly clear to users that selecting a model does not load it anymore. Consider showing a small popup/dialog after selection that forces per model setting configurations to appear and an explicit load model button.

Also, this control appears in the general model selector, but the deferred-load behavior currently applies only to GGUF/local load paths. That can make the UX feel conflicted: the toggle reads like a general model-selection behavior, while non-GGUF selections still load immediately.

We should clarify the copy/scope.

Imagineer99 and others added 2 commits June 16, 2026 12:01
Keep the load-on-selection hint visually anchored to the control and make the on/off behavior explicit without changing the broader deferred-load flow.

@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: 587be286dd

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@Imagineer99

Copy link
Copy Markdown
Member

CI passes on CI test fork except for inherited failures from main, tested and improved UX to include explicit staging notification and gguf only hint.
image
image

Great work @oobabooga, merging.

@Imagineer99
Imagineer99 merged commit c6cf537 into unslothai:main Jun 17, 2026
24 of 30 checks passed
danielhanchen added a commit that referenced this pull request Jun 18, 2026
Bring the branch up to date with main (#6348 'Load on selection' and the
GGUF native context-length probe) and resolve the validate-model overlap
by keeping BOTH sides:

- ValidateModelRequest: main's include_context_length opt-in.
- ValidateModelResponse: the PR's requires_security_review AND main's
  context_length.
- /inference/validate: run both the LoRA/security target resolution and
  the optional GGUF header context-length probe.
- types/api.ts: expose both requires_security_review and context_length.

Also restore the '@/components/ui/alert' import in chat-settings-sheet.tsx,
which main's staged-load Alert block needs (the import block had taken the
branch side during auto-merge).
shimmyshimmer pushed a commit that referenced this pull request Jun 18, 2026
Bring the Select model redesign up to date with main, which now carries the
new Hub and the deferred-load staging flow from #6348.

- Adopt main's staging as canonical: the store, use-chat-model-runtime and
  use-staged-model-preparation, the staged Run settings sidebar, and the
  gguf metadata context reader. Drop the parallel implementation this branch
  carried so there is a single staging path.
- Keep the redesigned single-Hub selector with section pills, the always-on
  fine-tuned shortcut and empty state, the Custom Folders jump, the folder
  browser refetch fix and the instant picker tooltips.
- Move the 'Load on selection' toggle out of the popover into Settings, Chat
  so there is one control for the setting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants