Repository navigation
Studio multi-GPU: split an even Lumina 2 batch across two cards (1.7-2.1x, fp-order only) - #16786
Merged
Merged
Conversation
The batch split (an even batch without guidance branches runs half on each card) was limited to FLUX.1 and FLUX.2. Lumina 2's denoiser takes only dim-0 per-sample inputs (latents, timestep, caption states and caption mask), so it is added with that exact keyword set; attention kwargs or any other input keep the call whole on the source card. A half pads its captions to its own longest one under the same mask, so the masked positions drop out of attention and the result differs from the whole-batch call only in floating-point order. Kill switch unchanged: UNSLOTH_DIFFUSION_BATCH_SPLIT=0.
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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With two cards selected, an even batch rendered without guidance branches (a distilled model, or guidance 1) runs half the batch on each card at the same time (#16682, #16687). That batch split only covered FLUX.1 and FLUX.2, because the gate checks argument shapes: every per-sample input has to be a dim-0 tensor.
This adds
Lumina2Transformer2DModelwith its exact keyword set:hidden_states,timestep,encoder_hidden_states,encoder_attention_mask,return_dict. Any other input, including non-emptyattention_kwargs, keeps the call whole on the source card, as before. The kill switch is unchanged:UNSLOTH_DIFFUSION_BATCH_SPLIT=0.Lumina 2 pads each sample's caption to the batch's longest caption under its own mask. A half pads to its own longest caption, and the extra positions are masked out of every attention. The math is the same, and only floating-point order changes.
Audit of the other DiT classes
Lumina2Transformer2DModelQwenImageTransformer2DModelimg_shapes, a Python list with one entry per prompt. Withzero_cond_t(Edit 2511) it builds a per-sample index from that list, so a half would need the list cut tooHiDreamImageTransformer2DModelencoder_hidden_states_llama3carries the batch on dim 1 (layers first)ZImageTransformer2DModeldiffusion_zimage_cfg_split)SD3Transformer2DModel,ChromaTransformer2DModelEvidence
Tiny random diffusers models, Studio's real
CfgParallelRouteracross two cards (Kaggle 2x T4, cuda:0 + cuda:1). Each model runs a 4-step loop, compared with the same model called whole on cuda:0. Every case engaged: 3 of 4 steps split, and step 1 learns there is one call per step.Real render,
Alpha-VLLM/Lumina-Image-2.0, Kaggle T4x2 (both T4s in one kernel). Studio was installed with its owninstall.sh(torch 2.13.0+cu130, diffusers 0.42.1). Settings: cards 0,1 selected, 768x768, 12 steps, guidance 1.0, batch 2, three prompts per arm. Studio picked fp32 on T4, plangroup. Every arm is a fresh process on the same head tree. Base isUNSLOTH_DIFFUSION_BATCH_SPLIT=0, which is the code pathmaintakes for this class. Values are scheduler-step medians in s/step.(The kernel 2 notebook log lost the first prompt's line for the off arms.)
Tests (
tests/test_diffusion_auto_multigpu_policy.py+tests/test_video_stream_residency.py, CPU):test_lumina2_batch_splits_with_per_sample_masks_and_matches_one_card,test_lumina2_attention_kwargs_and_kill_switch_stay_wholeNot covered
_hidden_stream_reason). For Lumina 2 that choice was not measured, because on T4x2 the layer split declined on its own (it did not fit).