Repository navigation
Studio: fit an oversized DiffusionGemma GGUF to the GPU in Auto mode - #13312
Conversation
Codex Review SummaryThis 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 SummaryThis 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. |
… record the pinned context
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53bb12c3d5
ℹ️ 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".
| if not pinned and len(rows) > 1 and os.environ.get("CUDA_DEVICE_ORDER") != "PCI_BUS_ID": | ||
| row = max( | ||
| rows, |
There was a problem hiding this comment.
Size unpinned launches against a card they may actually use
On a heterogeneous multi-GPU host without CUDA_DEVICE_ORDER=PCI_BUS_ID, this replaces the candidate corresponding to gpu with the roomiest card, even though nothing guarantees CUDA's fastest-first selection will choose that card. This also ignores an explicit DG_GPU selection because only gpu_ids sets pinned; for example, selecting an 8 GiB GPU while another card has 24 GiB makes the fit return no split, then the child still launches on the selected 8 GiB card and reproduces the allocation failure this change is intended to prevent. Resolve the actual selected device or conservatively size against every device it could denote rather than taking the maximum.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Deliberate: sizing an ambiguous unpinned device against the smallest card would cut layers from loads that fit today. Taking the roomiest card is never worse than before this PR (no split = today's launch); DG_GPU with mixed cards is an operator override outside the picker.
| binary = self._find_llama_server_binary() | ||
| # Vulkan ordinals are not the CUDA ids the runner's mask takes. | ||
| if binary and self._is_vulkan_backend(binary): | ||
| return None |
There was a problem hiding this comment.
Classify the resolved visual-server binary
When DG_VISUAL_BIN points to a visual server whose backend differs from the normal llama-server installation, the fit classifies the unrelated llama-server binary instead. A Vulkan llama-server alongside an explicitly configured CUDA visual server therefore returns here without fitting and leaves an oversized model fully GPU-resident; the inverse configuration can probe CUDA memory for a Vulkan child, and the Windows sysmem-fallback classification below is similarly taken from the wrong installation. Pass the already resolved visual_bin into the fitter and use it for backend and fallback detection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
DG_VISUAL_BIN pointing at a visual server from a different backend than the installed llama-server is a developer override, not a shipped layout; the prebuilt bundle installs both from one build.
| usable = _vram_usable_mib( | ||
| free_mib, total_mib, _active_vram_fraction(), sysmem_fallback = sysmem_fallback |
There was a problem hiding this comment.
Record the VRAM budget used by the diffusion fit
Auto diffusion placement now uses the active VRAM-budget fraction to decide both whether a split is needed and how many layers to offload, but the diffusion launch path still sets _vram_fraction_launched to None because it previously did not consume that setting. As a result, lowering the budget after a launch reports reload_required=false, and reapplying the identical model deduplicates against the running process instead of recomputing --ngl, leaving the old, higher VRAM allocation active. Capture the load's budget fraction and record it for diffusion launches that run this fit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The VRAM budget control is not shown for diffusion models, and a stale split only lasts until the next load; the split stays safe either way. Not worth widening the dedup for.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20fbebe9d8
ℹ️ 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".
| if file_mib <= usable: | ||
| return None |
There was a problem hiding this comment.
Include the context reserve before declaring a full fit
When the GGUF weights fit by themselves but the weights plus the requested context do not, this early return skips fitting before ctx_reserve is calculated. For example, the tested 16,806,810,208-byte Q4 model on a 20,475 MiB card with 19,500 MiB free is considered fully resident even at maxtok=8192, although the function's own estimate adds about 8,806 MiB of context/probe reserve; the runner can therefore still OOM or spill into system memory. Base the full-fit decision on the file plus the applicable context reserve, not the file alone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Deliberate: when the weights fit, the runner's own context probe degrades the context rather than failing, and that is today's behaviour on every card that loads now. Moving layers to the CPU there would slow every borderline card for a context the runner already shrinks; this PR only changes loads that cannot hold the weights.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 930d09e113
ℹ️ 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".
| # Auto: a GGUF too large for that device gets the split that fits it (#6456). | ||
| fit_ngl = None | ||
| if manual_ngl is None: | ||
| fit_ngl = self._diffusion_fit_ngl(model_path, gpu, maxtok, pinned = bool(gpu_ids)) |
There was a problem hiding this comment.
Apply the auto split before the training VRAM guard
When diffusion training is active, _guard_chat_load_against_training still scales required_override_gb only for an explicit manual diffusion_ngl (routes/inference.py lines 16593-16604), so an oversized Auto DiffusionGemma is evaluated as fully GPU-resident and rejected with 409 before execution can reach this new fit. This makes the Auto fix unavailable in the supported chat-during-training flow—particularly significant because the UI hides the manual diffusion layer control—even when the fitted split would fit alongside training. Reuse the Auto planner in the preflight guard, or otherwise admit the load based on the split it will actually launch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Out of scope and unchanged from base: the guard refuses an Auto DiffusionGemma load during LLM training exactly as before this PR, which protects the running job. Admitting a CPU-heavy split beside an active trainer is a separate policy decision, not part of fixing the oversized Auto load.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
|
Backend CI It passes on main, and this PR changes the DiffusionGemma start path in |
…st during the health wait
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
|
pre-commit.ci run |
Fixes #6456
Problem
Studio serves DiffusionGemma GGUFs through the diffusion runner (the
unsloth_zooshim drivingllama-diffusion-gemma-visual-server). In Auto GPU memory mode the runner always puts every layer on the GPU. The GPU-layer control is hidden for diffusion models in the model picker, so Auto is the only path a UI user has.When the GGUF is larger than the card (diffusiongemma-26B-A4B Q4_K_M is 16.8 GB, the report is an 8 GB RTX 4060):
unable to allocate CUDA0 buffer.#7575 made a Manual layer split reach the runner, but left Auto unchanged, and the picker does not offer Manual for diffusion.
Change
In Auto mode, before launching the runner, Studio checks whether the GGUF fits the runner's device (same
_vram_usable_mibbudget, Windows sysmem-fallback reserve included, plus 512 MiB for the runner's own CUDA context). Only when it does not fit does it pass--ngl N, with N the number of layers that fit while leaving room for the runner's compute buffer (1.75x the[n_head, N, N]fp32 scores, measured on a T4: 1752 MiB at 4096) and the 8% of VRAM the runner's context probe keeps free. When it splits and the context was left to auto-size,--maxtok 4096is pinned too: the runner's second sizing pass probes against host RAM, which on Windows would again be backed by shared memory.Unchanged:
--ngl, same--maxtok, byte-identical argv.DG_GPU/ UUID tokens, Vulkan builds.unsloth_zooshim without--ngl: logs a warning and keeps today's launch.CUDA_DEVICE_ORDER=PCI_BUS_ID: sized against the roomiest card, so a load that fits any card is never cut down./statusstill reports Auto, and reload dedup compares the request, not the fit.Composes with #13291 (multi-GPU split): that PR widens
--gputo a comma list, which this fit leaves alone.Evidence
Colab T4 (15 GB), Linux,
install.sh --localfrom the merge base, same venv, llama.cpp and unsloth_zoo for both arms; only the Studio backend tree differs.diffusiongemma-26B-A4B-it-Q4_K_M.gguf, Auto mode, no GPU pick:--gpu 0 --maxtok 4096llama_model_load: error loading model: unable to allocate CUDA0 buffer, load fails--gpu 0 --maxtok 4096 --ngl 20--gpu 0 --maxtok 4096 --ngl 20MAXTOK=4096 budget=requestedSplits the fit picks for this GGUF at a 4096 context: RTX 4060 8 GB on Windows 6 layers, on Linux 8; 6 GB card 4; T4 20; 20 GB, 24 GB and larger cards unchanged (all layers).
Tests:
studio/backend/tests/test_diffusion_auto_fit_ngl.py(16 cases: fit decisions, device selection, Vulkan / failed probe, and the real_start_diffusion_serverargv for split, fits, old shim and manual).test_differential.pyagainst the merge base: the two launch tests fail on base and pass here; the fits / old-shim / manual launch tests pass on both. The 35 existing backend andtests/studiofiles touching diffusion: 3498 passed, 0 failed on both base and head.Not covered here: the Windows sysmem-fallback path itself (no Windows NVIDIA runner); the split is sized with that reserve and the context pinned, but it was measured on Linux only.