Skip to content

Studio: stop the Load Model panel flagging Auto context loads as over VRAM - #12555

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
oobabooga:worktree-auto-context-estimate
Oct 3, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
oobabooga:worktree-auto-context-estimate

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

With Context Length on Auto, the Load Model panel estimates a GGUF at its full native context and can warn "Exceeds GPU memory. Try Auto context", even though Auto is already selected and the loader can shrink the context to fit. A user with an 8 GB card reported this on Reddit.

The estimate now reports whether context can shrink, its GPU memory floor, and whether layers can move to the CPU. The panel uses that floor for Auto's fit verdict and explains context reduction, CPU offload, or possible failure. Free-memory pressure takes precedence. Displayed figures, pinned-context warnings, and verdicts from older backends remain unchanged.

The floor follows the launch settings. Tensor requests conservatively use the larger of the tensor and layer-fallback footprints at 8,192 tokens, preserving the device count for both automatic and explicit GPU selection. Host memory stays estimated at native context.

Screenshots

Main at 364a42f02f versus this branch, using Qwen3-8B Q4_K_M. GPU capacities are simulated; model memory estimates are real.

Auto on an 8 GB card: the 5.92 GiB floor fits.

rd557_auto_before_after

Auto on a 6 GB card: the floor exceeds the budget, so the note explains CPU offload.

rd557_auto_6gb_before_after

Pinned at 40,960 tokens: the warning remains.

rd557_pinned_native_before_after

Validation

  • Browser A/B checks covered the screenshots and low free VRAM, which now produces an amber pressure note.
  • Real RTX 3090 (24 GiB): Qwen3-32B UD-Q4_K_XL had a 28.90 GiB native estimate and a 20.87 GiB floor. Auto loaded at 14,848 instead of 40,960 tokens, kept all 65 layers on GPU, and generated successfully. Panel logic evaluated against the captured readings gave Auto a tight-fit advisory and retained the pinned-context warning.
  • Backend memory, context, and argument suites: 4,475 passed. Latest memory-estimate rerun: 268 passed, 86 skipped. All 55 memory-fit frontend tests passed. Broader frontend failures also occur on main, except one timing test that passes alone. Typecheck and lint are clean.

Limitations

The two-GPU fallback, Windows, macOS, ROCm, and desktop app were not tested on hardware. The Metal floor has unit coverage only. Conservative estimates can still warn unnecessarily for tensor loads that fit below 8,192 tokens or large CPU-resident draft caches that shrink with context.

Before / after (merge base 364a42f vs c44cc5c)

Run settings for Qwen3-8B Q4_K_M with Context Length on Auto, GPU capacity simulated as an 8 GB card in the browser; the memory estimate is the real backend's on both sides. Before, the panel flags 10.45 GiB as over VRAM; after, the same figure carries the Auto context note.

Load Model panel, Auto context on an 8 GB card, before vs after

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#329.

@danielhanchen

Copy link
Copy Markdown
Member

The reds on this head are all main's and are fixed on main as of today: test_studio_evaluated_unions_do_not_grow by #12556, Frontend build + bundle sanity (over the startup budget) by #12560, and the Core zoo test_mlx_generate_metal.py NAX scope failures by unslothai/unsloth-zoo#1547. A push after rebasing on main (or a re-run, for the zoo jobs) should clear them.

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 3, 2026
@danielhanchen
danielhanchen merged commit 58c9cd6 into unslothai:main Oct 3, 2026
JoshuaL3000 pushed a commit to JoshuaL3000/unsloth that referenced this pull request Oct 4, 2026
… VRAM (unslothai#12555)

* Studio: stop the Load Model panel flagging Auto context loads as over VRAM

* Drop the shorter-context hint from the over-VRAM warnings

* Keep the estimate route answering while a fit flag is half typed

* Trim estimate-memory comments

---------

Co-authored-by: Daniel Han <[email protected]>
danielhanchen added a commit that referenced this pull request Oct 29, 2026
…y host (#16014)

## Summary

Five tests in
`studio/backend/tests/test_memory_estimate.py::TestAnAutoContextIsMarkedShrinkable`
fail on any Apple Silicon host. The regular CI does not run this file on
macOS, so they surface when a PR touching memory estimation gets a macOS
leg (the staging xplat run for #15970 on `macos-26`; that PR changes
only the MLX estimate):

```
test_an_unnamed_context_is_priced_at_the_fit_floor[request_fields0-True-8192]
    assert shorter.gpu_bytes < resp.gpu_floor_bytes == floor.gpu_bytes < resp.gpu_bytes
E   assert 18402857 < 18402857
test_tensor_mode_takes_the_layer_fallback_floor[None]
E   assert 1102368297 == 1264897577
```

Since #12555, `_estimate_context_floor` uses `_FIT_FLOOR_MIN_CTX` (256)
on Apple Silicon, where Metal reprices down to the smallest context it
searches, and `_FIT_MIN_CTX` (8192) for a layer split elsewhere.
`TestTheContextFloorFollowsThePlacementPath` pins both paths explicitly;
this class assumes the layer-split one but reads the real host, so on a
Mac its auto-mode floor is the 256 context it compares against. The
product is right; the class never said which host it prices.

Reproduced on main on Linux with `is_apple_silicon()` forced to `True`
(the macOS runner's answer): the same 5 fail.

## What changed

The class's autouse fixture pins `utils.hardware.is_apple_silicon` to
`False`, with a comment pointing at the class that covers Metal.

## Verification

- Main with `is_apple_silicon()` forced `True`: 5 failed in this class.
- Head, same forcing: this class and
`TestTheContextFloorFollowsThePlacementPath` 39 passed.
- Head on Linux: `tests/test_memory_estimate.py` 283 passed, 98 skipped.
- With `_FIT_MIN_CTX` changed from 8192 to 4096, 7 tests in this class
fail, so it still pins the layer-split floor.
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