[Qwen-Image 2.1 / Z-Image] Complex-valued RoPE hard-fails on backends without complex64 kernels (Ascend NPU: aclnnIndex EZ1001)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
Read transformer_qwenimage21.py, transformer_z_image.py, and the existing ROPE_PER_DEVICE and real-valued rotary path in transformer_qwenimage.py. Check the behavior described for Ascend NPU, CoreML export, and torch.compile, then trace how device-specific frequency tables are selected. Done means the three pipeline families use the requested real-valued path where needed and Qwen-Image 1.0 registers NPU support; no test file is named in the issue.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Two pipeline families in the Qwen-Image lineage still build their RoPE table with torch.polar and then index/multiply it as complex64 on the device, with no real-valued fallback:
transformer_qwenimage21.py—QwenImage21Rope.forwardhardcodesuse_real=Falsetransformer_z_image.py—torch.polar+view_as_complex
transformer_qwenimage.py (Qwen-Image 1.0) already has ROPE_PER_DEVICE from the AWS Neuron work in #13718, but only "neuron" is registered, so other accelerators keep taking the complex path.
On backends without complex64 kernels this is a hard failure rather than a slowdown, and it affects three targets, not one:
- Ascend NPU (torch_npu) — the op-plugin has no complex64
index/mul.QwenImage21Rope.forwardraisesaclnnIndex EZ1001as soon as the complex frequency table is indexed on device. Qwen-Image 2.1 and Z-Image currently cannot run on Ascend NPUs without an out-of-tree monkey-patch. - CoreML export —
torch.polarhas no MIL equivalent (apple/coremltools#2258). torch.compile— inductor cannot codegen complex ops (#12668), which matches this same code path.
CUDA eager is unaffected, which is presumably why this has stayed low-pressure upstream.
I understand #12668 already tracks the complex-op problem from the torch.compile angle; opening this as a separate issue because the backend failure mode and the fix scope are different (see "Describe the solution you'd like"). Happy to close this if you would rather consolidate into #12668.
Reproduction
The failure is device-specific, but the code path is easy to isolate. On an Ascend NPU with a from-source diffusers checkout:
import torch
from diffusers.models.transformers.transformer_qwenimage21 import QwenImage21Rope
# Any small instantiation of the rope module is enough; the failure happens at the
# first on-device indexing of the complex frequency table.
rope = QwenImage21Rope(...).to("npu") # or .to(torch.device("npu"))
rope(x, freqs_cis) # -> aclnnIndex EZ1001
A backend-agnostic sanity check for the same assumption (runs anywhere, no model weights needed):
import torch
freqs = torch.polar(torch.ones(8, 4), torch.rand(8, 4)).to("npu") # complex64 on device
freqs[torch.arange(8).to("npu")] # index -> unsupported on NPU
Describe the solution you'd like
Extend the existing #13718 pattern instead of adding a new one:
- port
ROPE_PER_DEVICE+ the real-valuedapply_rotary_emb_qwen_neuronpath intotransformer_qwenimage21.pyandtransformer_z_image.py; - keep the frequency table and its indexing on CPU, crossing the device boundary as reals (
_get_device_freqsalready does this for Neuron); - register
"npu"inROPE_PER_DEVICEfor Qwen-Image 1.0.
Context
I hit this while bringing up image models on a single Ascend 910B2; Qwen-Image 2.1 was the only pipeline in the set that could not run at all without patching.
Disclosure, and a note on scope: I opened PR #14905 for exactly this in September and it was auto-closed because it did not link an issue — that is on me, not on the change. Before re-opening anything I would like an explicit ack here, as the AI-assisted contribution section asks. I am also happy to split the work into one PR per pipeline instead of one size/L PR covering both, if that is easier to review.
Logs
RuntimeError: The inner error is reported as above. The process exits for this inner error. (Inner error: EZ1001: ... aclnnIndex ...)
File "diffusers/models/transformers/transformer_qwenimage21.py", line ..., in forward
...
(The exact op-level message from aclnnIndex is the one that names the unsupported complex64 dtype.)
System Info
- diffusers: main (from-source checkout at the time of report; PR #14905 was opened 2026-09-29)
- platform: Linux aarch64
- Python: 3.12.13
- torch: 2.10.0+cpu
- torch_npu: 2.10.0.post4
- CANN: 9.1.0
- accelerator: 1x Ascend 910B2 (HBM 64 GB)
Who can help?
Anyone with familiarity with the Qwen-Image RoPE implementations, or with Apple/Neuron backends where the same real-valued path already exists.
- 主要语言
- Python
- 星标
- 34.9k
- 派生
- 7.5k
- 平均合并
- 3 天 16 小时
- 30 天内合并 PR
- 65
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
huggingface/diffusers 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
huggingface/diffusers#15363 ·
维护者通常 1 天内回复
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeError可能已有人在做 @chessing234 于 1 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 70/100
huggingface/diffusers#15337 · 2 条评论 ·
维护者通常 1 天内回复
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)可能已有人在做 @sunhouy 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
huggingface/diffusers#15313 ·
维护者通常 1 天内回复
-
TCDScheduler advances the generator on the final step of a strength-truncated custom schedule可能已有人在做 @SIDDARTHAREDDY8 于 5 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 74/100
huggingface/diffusers#15288 · 2 条评论 ·
维护者通常 1 天内回复
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded again可能已有人在做 @sohailshk 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
huggingface/diffusers#15211 · 3 条评论 ·
维护者通常 1 天内回复
查看 huggingface/diffusers 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
Unused loot bag group names left in dreamcraft en_US.lang可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭Status: Triage Suggestion
难度 1/5 1 小时以内 新手友好度 90/100
GTNewHorizons/GT-New-Horizons-Modpack#27789 ·
维护者通常 1 天内回复
-
bug frontend sev-5
难度 2/5 1-3 小时 新手友好度 83/100
-
core good first issue
难度 2/5 1-3 小时 新手友好度 65/100
-
b4b code health next
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复