Repository navigation
Studio: split DiffusionGemma across GPUs when one GPU cannot hold it - #13291
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. |
… CUDA order for unpinned fits
…reads; keep a moved pick on dedup
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
|
Codex Review: Didn't find any major issues. 🚀 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". |
# Conflicts: # studio/backend/core/inference/llama_cpp.py
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9992b16ea
ℹ️ 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 manual_ngl is None: | ||
| fit_ngl = self._diffusion_fit_ngl(model_path, gpu, maxtok, pinned = bool(gpu_ids)) | ||
| try: | ||
| fit_gpus = self._diffusion_fit_gpus( |
There was a problem hiding this comment.
Respect the inherited NGL placement override
When an operator sets the runner's NGL environment override, _diffusion_fit_ngl intentionally returns None to leave that manual split in charge, but execution still reaches this multi-GPU fit. If the GGUF exceeds one card, the child is now widened over several GPUs while retaining the inherited layer count, whereas first-class manual --ngl requests are explicitly kept on one device. Skip _diffusion_fit_gpus when NGL is present so the environment form preserves the same single-device semantics and does not unexpectedly consume additional GPUs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
NGL sets how many layers go to the GPU, not which GPUs: those layers spread over the picked GPUs by llama.cpp's default split, which loads and serves correctly. Using GPUs the user picked is not a correctness bug, so leaving this as is.
…, matching the layer fit
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd38991335
ℹ️ 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".
| need = model_size_bytes + overhead | ||
| if cls._select_gpus(need, first, total_by_idx = total_by_idx)[0]: | ||
| return None | ||
| picked, _ = cls._select_gpus( | ||
| need, gpus, total_by_idx = total_by_idx, per_device_overhead_bytes = overhead |
There was a problem hiding this comment.
Preserve the context reserve in the multi-GPU fit
When a GGUF fits by weight but not after _diffusion_auto_ngl's attention/context reserve (for example, roughly 19–21 GiB on the tested 24 GiB cards), this check declares the first GPU sufficient because it budgets only the file plus 512 MiB. _start_diffusion_server consequently retains fit_ngl and offloads layers to CPU even though another selected GPU is available; near the aggregate limit, the same under-budgeting can clear fit_ngl for a multi-GPU load without reserving enough memory for its context. Pass through the layer fit's single-device verdict and include its context reserve when selecting the multi-GPU subset.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The layer fit's one-card verdict has no context reserve in it: _diffusion_auto_ngl returns None as soon as file_mib <= usable - 512 MiB, and the attention reserve only sizes the layer count after that test fails. This check is that same test, and test_diffusion_fit_gpus_agrees_with_the_layer_fit_on_one_card sweeps 18 to 26 GiB on 24 GiB cards and asserts the two agree at every 0.1 GiB step, so a 19 to 21 GiB GGUF never gets CPU layers here.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! 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 #6319. Addresses the inference half of #6347.
Problem
Studio serves DiffusionGemma GGUFs through a dedicated runner (the
unsloth_zoodiffusion shim drivingllama-diffusion-gemma-visual-server). Studio always handed that runner exactly one device token: the lowest picked GPU, or the first visible GPU when nothing was picked. A GGUF larger than that card therefore never loaded on a multi-GPU box. On 2x RTX 3090 (24 GB each), Q8_0 (26.9 GB) and BF16 (50.5 GB) put every layer on CUDA0 and stall at the graph reservation; on Windows the overflow spills into shared system memory and looks like a hang. Checking a second GPU in the picker did nothing, because the backend collapsed the pick to its lowest id.Runner support
The visual server builds its model with
llama_model_default_params(), so llama.cpp's default layer split already spans every device in itsCUDA_VISIBLE_DEVICES, and the zoo engine sets that mask from the--gputoken. But with more than one GPU the server turns its single-device prompt-KV store off, and that path asked for logits on every[prompt|canvas]row while the server caps outputs at the canvas, so current builds abort on the first request (GGML_ASSERT(n_outputs_max <= cparams.n_outputs_max), reproduced on 2x T4 with the shipped prebuiltb11541-mix-2500203). The runner fix lands separately in the DiffusionGemma llama.cpp pin; fixed builds answer--capabilitieswithmulti_gpu_split. Studio only splits when the installed visual server carries that marker, so with today's prebuilt nothing changes.Change
_diffusion_fit_gpusdecides the device set. It only acts with a visual server that supports the split, and only when the GGUF does not fit the single device the runner would use today (same_select_gpusbudget as llama-server). The pool is the explicit pick, else every visible GPU; the smallest fitting subset is used, and a pool that cannot hold it either still gets all of it rather than one card. An unpinned fit happens only with no inheritedCUDA_VISIBLE_DEVICESand ids from nvidia-smi / NVML, the same gate as the llama-server auto fit.--ngl),DG_GPU, non-numeric tokens (UUID / MIG), CPU-only, and Vulkan builds.gpu_ids,requested_gpu_ids),CUDA_DEVICE_ORDER=PCI_BUS_IDis set for the split as it already is for a pick, andmatches_gpu_ids/ the frontend resident match accept either the lowest id or the split set so an identical Apply does not reload.Interaction with the Auto layer fit (#13312)
Main now gives a GGUF too big for one GPU a GPU / CPU layer split in Auto mode. After merging main, the two fits compose like this:
--ngl, the runner keeps its own context auto-size.End to end (real runner, two physical B200s, memory reading spoofed to two 12 GB cards)
LlamaCppBackend.load_modelwithgpu_ids=(0, 5),tensor_parallel=True, DiffusionGemma Q4_K_M (16.8 GB), the visual server built from the pinned DiffusionGemma commit (c9b81be, answersmulti_gpu_split), then one chat request:2762603)--gpu00,5offloaded 15/31 layers to GPUoffloaded 31/31 layers to GPU4in 14.2 s4in 2.4 sStudio end to end (two isolated Studio installs)
Merge base
2762603and this PR (fd38991) each installed withinstall.sh --localinto their own home, the same split-capable visual server, both picked GPUs reported as 12 GiB cards to the fit, DiffusionGemma Q4_K_M loaded with GPUs[0, 2]picked, then "What is 2+2?" sent from the chat:/api/inference/statusgpu_ids[0][0, 2]--gpu 0,offloaded 15/31 layers to GPU, CPU_Mapped 8765 MiB, plus "does not fit GPU 0 ... rest on CPU"--gpu 0,2, every layer on the two GPUs (10.3 GB / 11.3 GB held)4after 41.7 s4after 10.4 sNo screenshot pair: the run-settings GPU list shows both GPUs switched on in both builds after this load, so it does not tell the two apart; the difference is in where the model runs.
Tests
DG_GPUoverrides, move to one card that fits), the real_start_diffusion_serverargv / env / recorded ids for split, auto split, fits-one-card and manual split, the dedup round trip, the guard pool budget, and the frontend resident match.test_differential.pyvs merge base: 5 FIXED (3 new behavioural, 2 updated source asserts), 9 NEW_API, 23 UNCHANGED, 0 head failures.