Repository navigation
Open
Labels
bug 🐞Something isn't working
Description
What happened?
Compiling this:
// Torch-dialect decode-medium SDPA
module @module {
func.func @main(%arg0: !torch.vtensor<[2,1,128],f16>, %arg1: !torch.vtensor<[2,2048,128],f16>, %arg2: !torch.vtensor<[2,2048,128],f16>) -> !torch.vtensor<[2,1,128],f16> attributes {torch.assume_strict_symbolic_shapes} {
%none = torch.constant.none
%float0.000000e00 = torch.constant.float 0.000000e+00
%false = torch.constant.bool false
%float1.250000e-01 = torch.constant.float 1.250000e-01
%false_0 = torch.constant.bool false
%0 = torch.aten.scaled_dot_product_attention %arg0, %arg1, %arg2, %none, %float0.000000e00, %false, %float1.250000e-01, %false_0 : !torch.vtensor<[2,1,128],f16>, !torch.vtensor<[2,2048,128],f16>, !torch.vtensor<[2,2048,128],f16>, !torch.none, !torch.float, !torch.bool, !torch.float, !torch.bool -> !torch.vtensor<[2,1,128],f16>
return %0 : !torch.vtensor<[2,1,128],f16>
}
}
With these flags:
build/cmake/iree-host/release/iree/tools/iree-compile \
experiments/work/attention_compile/torch_attention.mlir \
--iree-hal-target-backends=llvm-cpu \
--iree-llvmcpu-target-triple=riscv64-unknown-unknown-eabi-elf \
--iree-llvmcpu-target-cpu=generic-rv64 \
--iree-llvmcpu-target-cpu-features=+m,+a,+f,+d,+c,+v,+zvl8192b,+zfhmin,+zvfh \
--mlir-print-ir-before=iree-llvmcpu-virtual-vector-lowering --mlir-print-ir-after=iree-llvmcpu-virtual-vector-lowering \
-o /tmp/a.vmfb 2> debug
Explodes the compilation time (more than 5 minutes)
The reason seems to be the lowering of vector.contract, at the Virtual Vector Lowering pass.
Before :
%35 = vector.contract {indexing_maps = [affine_map<(d0, d1) -> (d1)>, affine_map<(d0, d1) -> (d1, d0)>, affine_map<(d0, d1) -> (d0)>], iterator_types = ["parallel", "reduction"], kind = #vector.kind<add>} %33, %34, %31 : vector<512xf32>, vector<512x32xf32> into vector<32xf32>
After :
%8:3 = scf.for %arg2 = %c0 to %c2048 step %c512 iter_args(%arg3 = %cst_0, %arg4 = %cst_3, %arg5 = %cst_4) -> (vector<32xf32>, vector<1xf32>, vector<1xf32>) {
%14 = vector.transfer_read %assume_align_5[%arg0, %arg2, %c0], %0 {in_bounds = [true, true]} : memref<2x2048x128xf16, #hal.descriptor_type<storage_buffer>>, vector<512x128xf16>
%15 = arith.extf %14 : vector<512x128xf16> to vector<512x128xf32>
%16 = vector.transpose %15, [1, 0] : vector<512x128xf32> to vector<128x512xf32>
%17 = vector.extract %16[0] : vector<512xf32> from vector<128x512xf32>
%18 = vector.extract %7[0] : f32 from vector<128xf32>
%19 = vector.broadcast %18 : f32 to vector<512xf32>
%20 = vector.fma %17, %19, %cst : vector<512xf32>
%21 = vector.extract %16[1] : vector<512xf32> from vector<128x512xf32>
%22 = vector.extract %7[1] : f32 from vector<128xf32>
// ...
%2593 = vector.extract %548[511] : vector<32xf32> from vector<512x32xf32>
%2594 = vector.extract %547[511] : f32 from vector<512xf32>
%2595 = vector.broadcast %2594 : f32 to vector<32xf32>
%2596 = vector.fma %2593, %2595, %2592 : vector<32xf32>
scf.yield %2596, %541, %531 : vector<32xf32>, vector<1xf32>, vector<1xf32>
}
I can only assume the further passes do not like having a region with 2600 instructions.
Steps to reproduce your issue
See above
What component(s) does this issue relate to?
No response
Version information
iree : d0343ad
Additional context
No response
Metadata
Metadata
Assignees
Labels
bug 🐞Something isn't working
Activity
github-actions commentedon Nov 16, 2026
Hello @sixcy 👋
Thank you for submitting an issue to IREE! It looks like it's your first one.
The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there.
Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.
Action required: acknowledge IREE project policies
IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.
Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:
For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.
If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.
Thank you,
The IREE Community
sixcy commentedon Nov 16, 2026
I understand and accept the proposed policy.