Skip to content

Studio FLUX.3: probe strided cuDNN attention on every layer split card - #17341

Merged
danielhanchen merged 2 commits into
mainfrom
studio-strided-attn-per-device-probe
Nov 10, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-strided-attn-per-device-probe

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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 on target's device, which is the primary GPU. It runs from apply_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.install records the probe dtype on each swapped processor.
  • New 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 stock Flux3AttnProcessor and keeps the backend and parallel config. It never raises.
  • apply_layer_split_plan calls it with the split's non-primary cards before place_layer_split, so the swap happens before the first forward. The probes run outside any compiled forward.
  • Single-card loads and splits onto cards that pass the probe are unchanged.

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.

  • origin/main: 2 failed (assert 1 in [0, 0, 0, 0, 0]: only the primary is ever probed)
  • this branch: 2 passed

Tests run

  • tests/test_diffusion_flux3_strided_attn.py: 11 passed (diffusers 0.42.1, CPU).
  • Neighbouring files with -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 in test_diffusion_flux3.py auto-switch / status tests, 1 in test_diffusion_layer_split_lifecycle.py workflow pipeline guard), so they are not caused by this change.
  • Pre-push gate (stray files, AGPL headers, pre-commit ruff): pass.

Not proven

  • No GPU run. The probe and placement are mocked on CPU. I have not shown that a real secondary card produces different output or fails with the strided call.
  • On a failing secondary, the processors revert on every card, including the primary, so the primary loses the strided speedup in that case. Per-block retention was not attempted.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T04:20:30.633088Z bb23848 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: bb23848efa

ℹ️ 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".

@danielhanchen
danielhanchen merged commit e12eb2e into main Nov 10, 2026
@danielhanchen
danielhanchen deleted the studio-strided-attn-per-device-probe branch November 10, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant