Repository navigation
Studio FLUX.3: probe strided cuDNN attention on every layer split card - #17341
Merged
Merged
Conversation
The strided processor install probes only the primary GPU, but a layer split can place blocks on secondary cards of a different type. Probe each secondary card before placement and keep the stock processors if any fails.
Codex Review Summary: ✅ CompletedThis 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. |
[skip ci]
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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
FLUX.3 strided cuDNN attention is now verified on every card a layer split places blocks on, not just the primary. If any secondary card fails the probe, Studio keeps the stock processors on every FLUX.3 attention module.
Root cause
#17180 added
diffusion_flux3_attn.install, which swaps FLUX.3 attention processors only when a load-time probe shows the strided cuDNN call is bitwise equal to the contiguous call. That probe runs ontarget's device, which is the primary GPU. It runs fromapply_attention_backend, and that happens before placement. The layer split planner (_backend_cards) restricts secondaries to identical cards only for flash / Sage backends, not_native_cudnn. So in a mixed-card layer split, the strided processor can run on a secondary card where it was never probed. cuDNN admission depends on the hardware and the tensor parameters, so a pass on one card says nothing about another. #17290 narrowed Auto's use of cuDNN, but an explicit cuDNN selection still reaches this path.Fix
diffusion_flux3_attn.installrecords the probe dtype on each swapped processor.diffusion_flux3_attn.verify_cards(pipe, cards)runs the existing per-card cached probe (strided_matches) on every secondary card for each swapped module's (dtype, heads, head_dim). If any card fails, it restores the stockFlux3AttnProcessorand keeps the backend and parallel config. It never raises.apply_layer_split_plancalls it with the split's non-primary cards beforeplace_layer_split, so the swap happens before the first forward. The probes run outside any compiled forward.Flip test
studio/backend/tests/test_diffusion_flux3_strided_attn.py::test_layer_split_probes_every_secondary_card[True|False]installs the strided processors with a mocked probe that passes on cuda:0. It then applies a mocked two-card layer split (0, 1) and checks two things: cuda:1 was probed, and the processors stay strided when cuda:1 passes but revert to stock when it fails.2 failed(assert 1 in [0, 0, 0, 0, 0]: only the primary is ever probed)2 passedTests run
tests/test_diffusion_flux3_strided_attn.py: 11 passed (diffusers 0.42.1, CPU).-o addopts= -m "not server and not native_mxc":test_diffusion_flux3_strided_attn.py,test_diffusion_layer_split_plan.py,test_diffusion_layer_split.py,test_diffusion_layer_split_order.py,test_diffusion_layer_split_lifecycle.py,test_diffusion_flux3.py. Result: 230 passed, 6 failed. The same 6 failures happen on origin/main without this change (5 intest_diffusion_flux3.pyauto-switch / status tests, 1 intest_diffusion_layer_split_lifecycle.pyworkflow pipeline guard), so they are not caused by this change.Not proven