Repository navigation
Closed
Labels
bug 🐞Something isn't working
Description
What happened?
The transform-dialect-based lowering seems to be hitting an issue with this test case.
Run with no_attention2.mlir from here
iree-compile --iree-hal-target-backends=cuda --iree-input-type=mhlo --iree-hal-cuda-llvm-target-arch=sm_80 no_attention2.mlir
Sorry for the large test case. The failing dispatch looks like this but for some reason isolating it into a small repro doesn't reproduce the failure for me locally.
builtin.module {
func.func @_main_dispatch_342_generic_2048x2048_f32(%arg0: !flow.dispatch.tensor<readonly:tensor<2048x2048xf32>>, %arg1: !flow.dispatch.tensor<readonly:tensor<2048xf32>>, %arg2: !flow.dispatch.tensor<writeonly:tensor<2048xf32>>) {
%cst = arith.constant 0.000000e+00 : f32
%cst_0 = arith.constant 2.048000e+03 : f32
%0 = flow.dispatch.tensor.load %arg0, offsets = [0, 0], sizes = [2048, 2048], strides = [1, 1] : !flow.dispatch.tensor<readonly:tensor<2048x2048xf32>> -> tensor<2048x2048xf32>
%1 = flow.dispatch.tensor.load %arg1, offsets = [0], sizes = [2048], strides = [1] : !flow.dispatch.tensor<readonly:tensor<2048xf32>> -> tensor<2048xf32>
%2 = tensor.empty() : tensor<2048xf32>
%3 = linalg.fill ins(%cst : f32) outs(%2 : tensor<2048xf32>) -> tensor<2048xf32>
%4 = linalg.generic {indexing_maps = [#map4, #map8], iterator_types = ["parallel", "reduction"]} ins(%0 : tensor<2048x2048xf32>) outs(%3 : tensor<2048xf32>) {
^bb0(%in: f32, %out: f32):
%6 = arith.negf %in : f32
%7 = arith.addf %out, %6 : f32
linalg.yield %7 : f32
} -> tensor<2048xf32>
%5 = linalg.generic {indexing_maps = [#map, #map, #map, #map], iterator_types = ["parallel"]} ins(%4, %1, %3 : tensor<2048xf32>, tensor<2048xf32>, tensor<2048xf32>) outs(%2 : tensor<2048xf32>) {
^bb0(%in: f32, %in_1: f32, %in_2: f32, %out: f32):
%6 = arith.addf %in, %in_1 : f32
%7 = arith.divf %6, %cst_0 : f32
%8 = arith.addf %in_2, %7 : f32
linalg.yield %8 : f32
} -> tensor<2048xf32>
flow.dispatch.tensor.store %5, %arg2, offsets = [0], sizes = [2048], strides = [1] : tensor<2048xf32> -> !flow.dispatch.tensor<writeonly:tensor<2048xf32>>
return
}
}
Full error log link
Steps to reproduce your issue
See above
What component(s) does this issue relate to?
Compiler
Version information
iree.git @ ab37989
Additional context
No response
Activity
stellaraccident commentedon May 4, 2023
@ftynse can you have a look?
ftynse commentedon May 5, 2023
I don't seem to be able to reproduce this. Getting a different error about
func.func @_mainhaving mismatching argument types and signature.ftynse commentedon May 5, 2023
If I disable the verifier, I can get slightly further to
error: failed to legalize unresolved materialization from '!stream.resource<*>', 'index' to 'i32' that remained live after conversion, but this comes from the Stream level. Transform dialect interpreter runs later than that and I cannot reach it.silvasean commentedon May 5, 2023
That seems like the error from llvm/llvm-project#62249 (I have a workaround patched locally). (I haven't synced to head due to #13189). To work around it you can disable the detensorize pass as described in step 1 here: #13202 (comment)
silvasean commentedon May 5, 2023
FYI if it is useful, I worked around this particular issue in the program and hit another instance of this on another dispatch region. Seems to be another reduction.
ftynse commentedon May 6, 2023
The issue comes from upstream for some reason failing the tracking when an op is "replaced" with another pre-existing op. This sounds perfectly valid in, e.g., CSE. Shortcutting that with
removes this particular issue. @matthias-springer any reason why the replacement must be a new op?
ftynse commentedon May 6, 2023
Also with that shortcut, we start hitting another issue:
Where the problematic transform op is
and the payload op is
For some reason,
%2points to two operations. It is produced by the chainso it must be only
linalg.fill. Further investigation shows that%2is being assigned two payloads byfuse_into_containing_op. I suspect we may be hitting this TODO:https://github.com/llvm/llvm-project/blob/3fb067f7ba8e7fee66b0740705f4bc767638ccc7/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp#L641-L645
but I ran out of time. Will pick up when I get meeting-free time.
allieculp commentedon May 9, 2023
@ftynse Setting this to P1, in progress. Let us know when you have an update!
allieculp commentedon May 9, 2023
@nicolasvasilache for visibility
15 remaining items
silvasean commentedon May 16, 2023
With D150429 additionally applied, the error appears to be gone! Do we know when all the necessary fixes will land in IREE head?
ftynse commentedon May 17, 2023
Nice! I don't know how IREE handles upstream integrates and couldn't find any relevant documentation. #13651 attempts to integrate past the relevant upstream changes, but is currently blocked by mlir-hlo cmake build being broken.
ScottTodd commentedon May 17, 2023
https://github.com/openxla/iree/tree/main/build_tools/scripts/integrate
ftynse commentedon May 17, 2023
Solved that, now blocked by end-to-end tests stored outside the repo (?) that fail because of TOSA upstream changes.
Update LLVM to llvm/llvm-project@33da608
allieculp commentedon May 19, 2023
@ftynse @silvasean Is this fixed?
ftynse commentedon May 20, 2023
Update LLVM to llvm/llvm-project@33da608 (#13666)
MaheshRavishankar commentedon May 25, 2023
@silvasean the required commit has made it into IREE.
silvasean commentedon May 25, 2023
Okay let's close this then (I verified it with the patch applied locally in #13419 (comment))
Update LLVM to llvm/llvm-project@33da608 (iree-org#13666)
Update LLVM to llvm/llvm-project@33da608 (iree-org#13666)