Skip to content

Studio: keep Qwen-Image-2.1 image conditioning finite on ROCm - #267

Closed
shimmyshimmer wants to merge 3 commits into
mainfrom
mirror-pr-12360
Closed

shimmyshimmer wants to merge 3 commits into
mainfrom
mirror-pr-12360

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Collaborator

Qwen-Image-2.1 reference-image generation produces NaN conditioning and blank images on Radeon 8060S with native vision SDPA, on both Windows and Linux.

Fix

Use eager attention in 512-query-row chunks for the encoder's Qwen3-VL vision tower, retaining all keys and values. This avoids native SDPA's NaNs without the memory cost of unbounded eager attention. The language model, denoiser and global SDPA settings stay unchanged, and the fix applies with Speed Off too.

Default to ROCm gfx1151 only. UNSLOTH_QWEN_IMAGE_ROCM_VISION_EAGER=0 opts out; =1 enables testing on other ROCm GPUs. Preserve explicitly selected non-SDPA backends and report installation failures instead of silently skipping the fix.

Tests

Windows/Linux A/B on Radeon 8060S, PyTorch 2.11 / ROCm 7.13:

  • Native SDPA produced NaNs; the patch produced finite, nonblank 40-step images. Dense encoders with Speed Off, 512/2048 reference sizes and two repeated reference inputs also passed. Opt-out reproduced the failure.
  • The 2048-reference case peaked at 24.36 GiB under a 48 GiB cap; unbounded eager and math attention had run out of memory at that cap. Four-step detail cases validate finiteness and memory, not image quality.
  • Text-only decoder inputs remained bit-identical on both OSes.

148 focused and related tests pass after rebasing onto b1c522a4ea; Ruff and formatting checks pass. Hardware A/B used 4e8503e437 and was not repeated after the rebase and override/error-handling changes. The attention calculation is unchanged.

RX 7900 XT and other ROCm architectures remain untested.


Mirror of unslothai/unsloth#12360 by @oobabooga, opened for review only.
Do not merge here. Fixes agreed on this mirror must be applied to the source PR.
Source description digest at mirror time: 0f70eb639f50

@danielhanchen
danielhanchen force-pushed the mirror-pr-12360 branch 2 times, most recently from 1fc65cf to ea15bc0 Compare October 1, 2026 09:13
@danielhanchen

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T09:18:16.084759Z 8e4ce5b 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 8e4ce5bcb6

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

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.

3 participants