Skip to content

Studio: an aiter attention pick on ROCm runs the auto pick when diffusers has no local aiter backend - #18924

Merged
danielhanchen merged 2 commits into
mainfrom
studio-aiter-attention-alias
Nov 22, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-aiter-attention-alias

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Picking attention_backend=aiter on an AMD ROCm GPU silently ran native SDPA, which is slower than the default pick.

diffusers 0.41 removed the local aiter attention backend. Only aiter_fa2_hub is left, and that one downloads its kernel from the Hub. Studio pins 0.42.1 (0.41.0 on Python 3.10) but still mapped aiter to the old name. set_attention_backend("aiter") raised, and the load fell back to native SDPA. On gfx1151 (Radeon 8060S) with FLUX.3 klein bf16 at 1024x1024, that was 1.70 s/step against 1.40 s/step for the default flash pick. Every cell of the AITER arm reported native (requested aiter, fell_back).

Change

  • _diffusers_aiter_usable() returns True only when the installed diffusers has an aiter entry in AttentionBackendName and its _CAN_USE_AITER_ATTN check passes. It never raises.
  • select_attention_backend: on ROCm, an aiter request where that check fails becomes Studio's auto pick. This is the same rewrite unsloth_int8 already gets. In practice it gives verified ROCm flash when the speed profile allows it, otherwise native, exactly what auto returns. Studio does not fetch the hub kernel.
  • explicit_attention_decline: for that case the status reads fell_back and says why, so the reported state stays accurate.
  • No change where the local backend works (diffusers 0.36 on Python < 3.10 with the aiter package installed): aiter is honored as before. Off ROCm (NVIDIA, MPS, CPU) it is still unsupported, the same as other platform-gated picks.
  • The hint shown when ROCm flash_attn is missing no longer suggests attention_backend=aiter. The request field descriptions now say when aiter can engage.

The Images and Video pages do not offer aiter (their selector lists auto / native / cudnn / flash3 / sage), so nothing changes in the UI. Only API requests can send it.

Tests

tests/test_diffusion_attention_aiter_alias.py (CPU, hermetic):

  • On ROCm, aiter with a hub-only diffusers equals the auto pick for every speed state and flash-verified state. Fails on main, where it returns aiter.
  • The decline status is fell_back with the reason. Fails on main.
  • A usable local backend is still honored, and off ROCm aiter is still unsupported. Passes on both.
  • A frozen table of main's answers for every other alias, on NVIDIA and ROCm, both speed states, under a hub-only and a local-aiter diffusers. It matches on main and on this branch.

Against the real diffusers 0.42.1 package, _diffusers_aiter_usable() is False and ROCm aiter resolves to the flash candidate (main: aiter, which diffusers rejects).

tests/test_diffusion_attention*.py: 541 passed, 2 skipped.

…e on ROCm

diffusers 0.41+ (Studio pins 0.42.1) removed the local aiter attention
backend and only ships aiter_fa2_hub, a hub-downloaded kernel. Studio still
mapped attention_backend=aiter to the dead name, so set_attention_backend
raised and every ROCm load silently fell to native SDPA, ~20% slower than
the default flash pick on gfx1151 (FLUX.3 klein 1024^2: 1.70 vs 1.40 s/step).

On ROCm, aiter now resolves to Studio's auto pick when diffusers has no
usable local aiter backend, and the status reports fell_back with the reason.
Where the local backend is usable (diffusers 0.36 with aiter installed) the
pick is honored as before; off ROCm it stays unsupported. Every other alias
is unchanged (frozen table test).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 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-22T16:34:32.307332Z ae862b8 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. What shall we delve into next?

Reviewed commit: ae862b8e71

ℹ️ 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 3fac9d2 into main Nov 22, 2026
@danielhanchen
danielhanchen deleted the studio-aiter-attention-alias branch November 22, 2026 18:35
danielhanchen added a commit that referenced this pull request Nov 22, 2026
… since #18924 (#18942)

## Summary

`Backend tests` (the `(Python 3.13, rest)` shard) is red on `main` since
#18924:

```
tests/test_xformers_stub_diffusion_parity.py:407: in test_xformers_is_never_selected_on_a_rocm_target
E   AssertionError: assert None == 'aiter'
```

Both ROCm wheel parametrizations fail. It shows on unrelated PRs, for
example the staging run for #18737, which only touches translate files.

#18924 made an explicit `aiter` pick on ROCm run the auto pick when
diffusers has no usable local aiter backend
(`_diffusers_aiter_usable()`), so the pick no longer fails mid-render.
That change is correct. #18924 patched `_diffusers_aiter_usable` in its
own tests, but this older parity test still asserted that `aiter` is
always honoured on a ROCm target. On a runner whose diffusers has no
local aiter backend, which is every CI runner, that is no longer true.

## Fix

The test now pins both outcomes explicitly instead of depending on the
runner's diffusers:

- With `_diffusers_aiter_usable` returning True, an `aiter` pick on ROCm
is still `aiter`.
- With it returning False, an `aiter` pick resolves to the same backend
as `auto`.

The xformers assertions the test exists for are unchanged. Only the test
changes.

## Testing

- `tests/test_xformers_stub_diffusion_parity.py`: 2 failed on `main`,
all pass with this change.
- The file plus `tests/test_diffusion_attention.py` and
`tests/test_diffusion_attention_aiter_alias.py`: 193 passed.
- Sabotage: with #18924's fallback (`if alias == "aiter" and
_is_cuda_rocm(target) and not _diffusers_aiter_usable(): alias =
ATTN_AUTO`) removed, the new no-aiter assertion fails for both ROCm
wheels, alongside #18924's own
`test_dead_aiter_on_rocm_is_the_auto_pick` cases.
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