Skip to content

refactor: drop the Neuron RoPE path in Qwen Image - #15042

Merged
sayakpaul merged 2 commits into
huggingface:mainfrom
JingyaHuang:revert-neuron-complex-rope
Oct 15, 2026
Merged

sayakpaul merged 2 commits into
huggingface:mainfrom
JingyaHuang:revert-neuron-complex-rope

Conversation

@JingyaHuang

Copy link
Copy Markdown
Contributor

What does this PR do?

Reverts the Neuron-specific RoPE workaround added to Qwen-Image in #13718.

At the time, Neuron had no complex tensor support, so the RoPE freqs were sent to the device as rotation angles
(torch.angle) and applied with a real-valued cos/sin variant (apply_rotary_emb_qwen_neuron, dispatched through
ROPE_PER_DEVICE). The latest Neuron SDK runs complex tensors on device, in both eager and torch.compile, so
Qwen-Image can use the default complex RoPE on every device again. This removes:

  • apply_rotary_emb_qwen_neuron and ROPE_PER_DEVICE
  • the device.type == "neuron" branch in QwenEmbedRope._get_device_freqs and QwenEmbedLayer3DRope._get_device_freqs

The tensor-parallel changes from #13718 (per-head unflatten in the attention processor) are kept.

Same simplification as discussed in #14865 (comment) for
Qwen-Image-2.1.

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
    • Did you read the Coding with AI agents guide?
    • Did you run the self-review skill on the diff?
    • Did you share the final self-review notes in the PR description or a comment?
  • Did you read the contributor guideline?
  • Did you read our philosophy doc? (important for complex PRs)
  • Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?
  • Are you the author (or part of the team) of the model/pipeline (only applicable for model/pipeline related PRs)?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Neuron now runs complex tensors natively, so Qwen Image uses the
default complex RoPE on every device. This removes
`apply_rotary_emb_qwen_neuron`, `ROPE_PER_DEVICE` and the
`torch.angle` branch in `_get_device_freqs`, added in huggingface#13718.
@JingyaHuang
JingyaHuang marked this pull request as ready for review October 15, 2026 11:29
@github-actions github-actions Bot added models size/M PR with diff < 200 LOC labels Oct 15, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul

Copy link
Copy Markdown
Member

/diffusers-bot pytest tests/models/transformers/test_models_transformer_qwenimage.py

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ pytest tests/models/transformers/test_models_transformer_qwenimage.py passed on GPU — view logs.

@sayakpaul
sayakpaul merged commit 4113984 into huggingface:main Oct 15, 2026
11 of 12 checks passed
@JingyaHuang
JingyaHuang deleted the revert-neuron-complex-rope branch October 15, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models size/M PR with diff < 200 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants