[CPU] Complex scalar broadcasting fails or returns incorrect results
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start by running the reproduction script once per operation (mul, sub, add, div) to confirm the two failure modes: an unhandled ComplexFloat dtype error for mul.out and sub.out, and wrong values for add and div with a zero-dimensional complex scalar. The payload does not name the kernel source files, so locate the optimized CPU implementations of aten::mul.out, sub.out, add and div first. Done means all four cases match PyTorch eager under torch.testing.assert_close, with no out-of-bounds read in the division path.
索引モデルが issue の本文から書いたものです。
説明
🐛 Describe the bug
With optimized CPU kernels, mul and sub fail with Unhandled dtype ComplexFloat, while add and div return incorrect results when one operand is a zero-dimensional torch.complex64 tensor. No delegation is involved.
Minimal repro
Save as repro.py:
import sys
import torch
from executorch.exir import EdgeCompileConfig, to_edge
from executorch.runtime import Runtime
op = sys.argv[1] # mul, sub, add, or div
assert op in ("mul", "sub", "add", "div")
class Model(torch.nn.Module):
def forward(self, a, b):
if op == "mul":
return a * b
if op == "sub":
return torch.sub(a, b, alpha=2)
if op == "add":
return torch.add(a, b, alpha=2)
return a / b
x = torch.tensor([1 + 1j, 2 - 2j], dtype=torch.complex64)
s = torch.tensor(2 + 2j, dtype=torch.complex64)
inputs = (s, x) if op == "add" else (x, s)
model = Model().eval()
expected = model(*inputs)
exported = torch.export.export(model, inputs)
# Bypass the separate Edge complex-dtype schema restriction to test the kernel.
edge = to_edge(exported, compile_config=EdgeCompileConfig(_check_ir_validity=False))
program = Runtime.get().load_program(edge.to_executorch().buffer)
print("Expected:", expected, flush=True)
actual = program.load_method("forward").execute(inputs)[0]
if not isinstance(actual, torch.Tensor):
actual = torch.from_dlpack(actual)
print("Actual: ", actual, flush=True)
torch.testing.assert_close(actual, expected)
Run each case separately:
python repro.py mul
python repro.py sub
python repro.py add
python repro.py div
Actual and expected behavior
| Operation | Actual | Expected (PyTorch eager) |
|---|---|---|
x * s |
RuntimeError: method->execute() failed with error 0x12: Unhandled dtype ComplexFloat for mul.out; KernelCall failed at instruction 0:0 in operator aten::mul.out: 0x12; arg 0 with type id 1; arg 1 with type id 1; arg 2 with type id 1; arg 3 with type id 1 |
[4j, 8] |
torch.sub(x, s, alpha=2) |
RuntimeError: method->execute() failed with error 0x12: Unhandled dtype ComplexFloat for sub.out; KernelCall failed at instruction 0:0 in operator aten::sub.out: 0x12; arg 0 with type id 1; arg 1 with type id 1; arg 2 with type id 4; arg 3 with type id 1; arg 4 with type id 1 |
[-3-3j, -2-6j] |
torch.add(s, x, alpha=2) |
[5+5j, 6+2j] |
[4+4j, 6-2j] |
x / s |
[0.5, inf-infj] in this run |
[0.5, -1j] |
The incorrect div value may vary because of an out-of-bounds read.
Versions
PyTorch version: 2.14.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCm SDK used to build PyTorch: N/A
HIP used to build PyTorch: N/A
OS: Ubuntu 24.04.5 LTS (aarch64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: version 3.31.10
Libc version: glibc-2.39
Python version: 3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-7.0.0-1024-nvidia-aarch64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: NVIDIA GB10
Nvidia driver version: 580.178.04
cuDNN version: Probably one of the following:
/usr/lib/aarch64-linux-gnu/libcudnn.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_adv.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_cnn.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_precompiled.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_tensor_ir.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_ext.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_graph.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_heuristic.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_ops.so.9.27.0
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False
Caching allocator config: N/A
CPU:
Architecture: aarch64
CPU op-mode(s): 64-bit
Byte Order: Little Endian
CPU(s): 20
On-line CPU(s) list: 0-19
Vendor ID: ARM
Model name: Cortex-X925
Model: 1
Thread(s) per core: 1
Core(s) per socket: 10
Socket(s): 1
Stepping: r0p1
Frequency boost: disabled
CPU(s) scaling MHz: 100%
CPU max MHz: 3900.0000
CPU min MHz: 1378.0000
BogoMIPS: 2000.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt
Model name: Cortex-A725
Model: 1
Thread(s) per core: 1
Core(s) per socket: 10
Socket(s): 1
Stepping: r0p1
CPU(s) scaling MHz: 100%
CPU max MHz: 2808.0000
CPU min MHz: 338.0000
BogoMIPS: 2000.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt
L1d cache: 1.3 MiB (20 instances)
L1i cache: 1.3 MiB (20 instances)
L2 cache: 25 MiB (20 instances)
L3 cache: 24 MiB (2 instances)
NUMA node(s): 1
NUMA node0 CPU(s): 0-19
Vulnerability Gather data sampling: Not affected
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Old microcode: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
Vulnerability Spectre v2: Mitigation; CSV2, BHB
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Not affected
Versions of relevant libraries:
[pip3] executorch==1.6.0+05092c1
[pip3] numpy==2.5.4
[pip3] nvidia-cublas==13.1.1.3
[pip3] nvidia-cuda-cupti==13.0.85
[pip3] nvidia-cuda-nvrtc==13.0.88
[pip3] nvidia-cuda-runtime==13.0.96
[pip3] nvidia-cudnn-cu13==9.24.0.43
[pip3] nvidia-cufft==12.0.0.61
[pip3] nvidia-curand==10.4.0.35
[pip3] nvidia-cusolver==12.0.4.66
[pip3] nvidia-cusparse==12.6.3.3
[pip3] nvidia-cusparselt-cu13==0.8.1
[pip3] nvidia-nccl-cu13==2.30.7
[pip3] nvidia-nvjitlink==13.4.92
[pip3] nvidia-nvtx==13.0.85
[pip3] optimum-executorch==0.2.0.dev0
[pip3] pytorch_tokenizers==1.4.0
[pip3] torch==2.14.0+cu130
[pip3] torchao==0.19.0.dev20260907+cpu
[pip3] torchaudio==2.11.0+cu130
[pip3] torchdata==0.11.0
[pip3] torchsr==1.0.4
[pip3] torchtune==0.0.0
[pip3] torchvision==0.29.0+cu130
[pip3] triton==3.8.0+gitdf3f91dd
[conda] Could not collect
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 1.2k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 675
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytorch/executorch のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
pytorch/executorch#24434 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pytorch/executorch#24410 ·
メンテナーはふだん 1 日以内に返信
-
enhancement triaged
難易度 2/5 半日 初心者へのやさしさ 68/100
pytorch/executorch#21640 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
pytorch/executorch#24502 ·
メンテナーはふだん 1 日以内に返信
-
Optimized le.Tensor_out returns b <= a for reverse-argument broadcasts対応中かも @SofianElmotiem が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
pytorch/executorch#24485 ·
メンテナーはふだん 1 日以内に返信
pytorch/executorch の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
huggingface/deep-rl-class#723 ·
-
[tool] bug: Qwen3 XML tool parser raises on `...` argument values (Ellipsis is not JSON serializable)対応中かも @super-yuki が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
verl-project/verl#8559 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
TencentCloud/octop-harness#228 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/osv-scalibr#2585 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
NousResearch/hermes-agent#149323 ·
メンテナーはふだん 1 日以内に返信