Skip to content

Model picker: context length hint, and the preset note as a tooltip - #7755

Merged
shimmyshimmer merged 3 commits into
mainfrom
studio-context-length-hint
Aug 2, 2026
Merged

shimmyshimmer merged 3 commits into
mainfrom
studio-context-length-hint

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Context Length hint

Adds a line under the Context Length slider saying where the number came from:

By default, Unsloth uses the model's full context, lowering it only if it will not fit your device's memory.

That matches the loader: the field defaults to the model's native context, and _fit_context_to_vram reduces it to the largest context that fits the memory budget, returning the request verbatim when KV metadata is unavailable or the cache is offloaded to CPU RAM.

The model picker and the Run Settings sidebar render the same block, so both surfaces get it from the one change. It sits under the slider and above the existing VRAM warning, which keeps the amber line next to the value it refers to, and uses the muted helper style the panel already uses for descriptions.

Preset note

The note about what a preset stores was a paragraph under the Save and Delete buttons. It is read once and then takes up height on every visit, and it was the only explanation in the panel not behind the usual info affordance.

It moves to an InfoHint on the Preset section header, passed through headerAction, which exists for this and keeps the control a sibling of the label and chevron rather than a button inside a button. The dynamic parts are unchanged: the active load summary and, when it differs, the summary saved in the preset both still show inside the tooltip.

The panel's tooltip trigger toggles on click as well as hover, so the note stays reachable on touch.

Testing

  • npm run typecheck clean
  • npm test: 300 passing, 0 failing
  • npm run build clean
  • biome check on both touched files matches main exactly

Says what the number started as and that it can be changed. Sits in the
shared block, so the picker and the Run Settings sidebar both get it.

@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: 1e17adb343

ℹ️ 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 on lines +1195 to +1196
Unsloth automatically uses 95% of your device's maximum
supported context, but you can adjust it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge State the actual automatic context policy

When Context Length is left on Auto, this claim is incorrect: LlamaCppBackend._fit_context_to_vram selects the full native context when it fits or the largest context fitting the applicable memory budget, and the discrete-GPU budget uses _CTX_FIT_VRAM_FRACTION = 0.97; other paths use different policies. Nothing consistently selects 95% of a device's supported context, so this guidance can mislead users about both the chosen value and how much headroom remains. Describe the VRAM-aware fit instead of asserting 95%.

Useful? React with 👍 / 👎.

The context line now says what the default is without naming a percentage.

The preset note was a paragraph under the buttons, which pushed the section
tall for text that is read once. It moves to the info tooltip on the section
header, where the rest of the panel keeps its explanations. The active and
saved summaries still show inside it.
@shimmyshimmer shimmyshimmer changed the title Model picker: describe the automatic context length under the slider Model picker: context length hint, and the preset note as a tooltip Aug 2, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 2d42e48f30

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

The fit starts from the model's native context and reduces it to what the
device can hold, so the device's memory is the ceiling, not the starting
point. Say that instead.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

The facts here are right, and they still applied after the reword, so fixed in 65d2e23.

Checked each claim rather than taking them:

  • _CTX_FIT_VRAM_FRACTION = 0.97 exists at llama_cpp.py:1583, and it caps total GPU occupancy, it is not a context fraction
  • _fit_context_to_vram is documented as returning the largest context that fits, and returns the request verbatim when KV metadata is unavailable or --kv-offload puts the cache in CPU RAM
  • the Apple path uses its own _APPLE_UNIFIED_MEMORY_FRACTION = 0.85
  • nothing anywhere selects 95%

The 95% line had already gone in an earlier commit on this branch, but the replacement was wrong in a subtler way. It said the default is the maximum context your device supports, when the call site starts from native_ctx_for_cap = self._context_length, the model's native context, and reduces from there. The device's memory is the ceiling, not the starting point, so a model whose native context is smaller than the card could hold never reaches that maximum.

Now reads:

By default, Unsloth uses the model's full context, lowering it only if it will not fit your device's memory.

That covers both branches, including the paths that honor the request verbatim, since those do not lower it.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 65d2e23211

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

@shimmyshimmer
shimmyshimmer merged commit 3044401 into main Aug 2, 2026
39 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-context-length-hint branch August 2, 2026 15:16
Sneakr added a commit to Sneakr/unsloth that referenced this pull request Aug 2, 2026
Bring in unslothai/unsloth main through unslothai#7755 after the recent unslothai#7683 sync. Preserve the train-page model and dataset preflight, cached resource pins, MLX validation, local fix commits, and the PR-side UI/UX work. Carry upstream's persistent advanced-settings preference, inventory exports, desktop training guard, and generalized native file filters into the reworked flows.
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.

1 participant