Repository navigation
Redo handling of operand reuse to prevent stack allocation. - #12041
Conversation
|
FYI @matthias-springer leaving this as a placeholder for us to chat about more. You dont need to worry about the actual changes, just the PR description is something we can use as a seed for the discussion. |
Abbreviated Android Benchmark Summary@ commit 3dc539223bc3eb1529713d6e4d9dd856435e4c85 (vs. base dd3ea1d9084da4b23b382bc1085ef6d2322c13f1) Regressed Latencies 🚩
Improved Latencies 🎉
Regressed Compilation Times 🚩
[Top 3 out of 8 results showed] Improved Compilation Times 🎉
[Top 3 out of 67 results showed] Improved Total Dispatch Sizes 🎉
[Top 3 out of 4 results showed] For more information: |
For dispatches with ``` %r = <some compute op> %store = linalg.generic ... ins(%r, ...) outs(%empty :) ``` where the value of `%store` is the final result of the dispatch, to avoid creation of stacks for `%r` when vectorization does not kick in, the user is converted to ``` %store = linalg.generic ... ins(, ...) outs(%r :) ``` This is a very specific change to work around something that really should be handled later on during bufferization (but is outside scope of bufferization today). This change needs to kick in very specific conditions (since its a work-around, and really the created `linalg.generic` is somewhat of an anti-pattern), using a pattern rewrite to make this change does not allow controlling the transformation. Change this to use a walk and trigger only when needed. Fixes iree-org#12019.
215bdb0 to
3dc5392
Compare
| nestedModulePM.addNestedPass<func::FuncOp>( | ||
| IREE::LinalgExt::createTileAndDecomposeAttentionPass()); | ||
| nestedModulePM.addNestedPass<func::FuncOp>( | ||
| IREE::LinalgExt::createDecomposeSoftmaxPass()); |
There was a problem hiding this comment.
Something in this PR triggered failures on Emscripten (llvm cpu with that target triple): https://github.com/iree-org/iree/actions/runs/4130706149/jobs/7137719751
[14/350] Generating check_llvm-cpu_local-task_attention.mlir_module.vmfb from attention.mlir
FAILED: tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb /work/build-emscripten/tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb
cd /work/build-emscripten/tests/e2e/linalg_ext_ops && /work/full-build-dir/install/bin/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu /work/tests/e2e/linalg_ext_ops/attention.mlir -o check_llvm-cpu_local-task_attention.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/build-emscripten\" --iree-llvm-target-triple=wasm32-unknown-emscripten
/work/tests/e2e/linalg_ext_ops/attention.mlir:6:8: error: 'linalg.generic' op inferred input/output operand #3 has shape's dimension #0 to be 2, but found 4
%1 = iree_linalg_ext.attention ins(%query, %key, %value : tensor<1x4x4xf32>,
^
#12081 will run that job on presubmit, but it hasn't been merged yet
We should also figure out how to get this sort of test coverage without Emscripten - maybe adding tests that use the llvm cpu path with a different (baseline?) target triple?
There was a problem hiding this comment.
Yeah maybe.... Having emscripten on presubmit will automatically do that... Is it OK if I take a look at that tomorrow? Or is this urgent enough to be P0?
There was a problem hiding this comment.
In the meantime, is there a way to temporarily disable the flash_attention test on emscipten. Just to unblock CI.... The flash attention stuff is still on the experimental side of things...
There was a problem hiding this comment.
Is it OK if I take a look at that tomorrow? Or is this urgent enough to be P0?
Not a P0. While waiting for a fix, we could either
- revert this PR
- let the emscripten build stay broken (it is post-submit and doesn't block anyone... but it makes the whole project look broken with the red x :P)
- disable the emscripten build
- disable the test on emscripten (trickier)
There was a problem hiding this comment.
I can see about just disabling that test on Emscripten
Least-hacky way I could think of to disable building the `iree_tests_e2e_linalg_ext_ops_check_llvm-cpu_local-task_attention.mlir` target on Emscripten while we work on a fix. See #12041 (comment) and https://github.com/iree-org/iree/actions/runs/4130706149/jobs/7137719751 ``` [14/350] Generating check_llvm-cpu_local-task_attention.mlir_module.vmfb from attention.mlir FAILED: tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb /work/build-emscripten/tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb cd /work/build-emscripten/tests/e2e/linalg_ext_ops && /work/full-build-dir/install/bin/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu /work/tests/e2e/linalg_ext_ops/attention.mlir -o check_llvm-cpu_local-task_attention.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/build-emscripten\" --iree-llvm-target-triple=wasm32-unknown-emscripten /work/tests/e2e/linalg_ext_ops/attention.mlir:6:8: error: 'linalg.generic' op inferred input/output operand #3 has shape's dimension #0 to be 2, but found 4 %1 = iree_linalg_ext.attention ins(%query, %key, %value : tensor<1x4x4xf32>, ^ ``` #12081 will run the Emscripten CI on presubmit to catch errors like this sooner.
…#12041) For dispatches with ``` %r = <some compute op> %store = linalg.generic ... ins(%r, ...) outs(%empty :) ``` where the value of `%store` is the final result of the dispatch, to avoid creation of stacks for `%r` when vectorization does not kick in, the user is converted to ``` %store = linalg.generic ... ins(, ...) outs(%r :) ``` This is a very specific change to work around something that really should be handled later on during bufferization (but is outside scope of bufferization today). This change needs to kick in very specific conditions (since its a work-around, and really the created linalg.generic is somewhat of an anti-pattern), using a pattern rewrite to make this change does not allow controlling the transformation. Change this to use a walk and trigger only when needed. Fixes iree-org#12019. Fixes iree-org#12019
…org#12127) Least-hacky way I could think of to disable building the `iree_tests_e2e_linalg_ext_ops_check_llvm-cpu_local-task_attention.mlir` target on Emscripten while we work on a fix. See iree-org#12041 (comment) and https://github.com/iree-org/iree/actions/runs/4130706149/jobs/7137719751 ``` [14/350] Generating check_llvm-cpu_local-task_attention.mlir_module.vmfb from attention.mlir FAILED: tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb /work/build-emscripten/tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb cd /work/build-emscripten/tests/e2e/linalg_ext_ops && /work/full-build-dir/install/bin/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu /work/tests/e2e/linalg_ext_ops/attention.mlir -o check_llvm-cpu_local-task_attention.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/build-emscripten\" --iree-llvm-target-triple=wasm32-unknown-emscripten /work/tests/e2e/linalg_ext_ops/attention.mlir:6:8: error: 'linalg.generic' op inferred input/output operand iree-org#3 has shape's dimension #0 to be 2, but found 4 %1 = iree_linalg_ext.attention ins(%query, %key, %value : tensor<1x4x4xf32>, ^ ``` iree-org#12081 will run the Emscripten CI on presubmit to catch errors like this sooner.
For dispatches with ``` %r = <some compute op> %store = linalg.generic ... ins(%r, ...) outs(%empty :) ``` where the value of `%store` is the final result of the dispatch, to avoid creation of stacks for `%r` when vectorization does not kick in, the user is converted to ``` %store = linalg.generic ... ins(, ...) outs(%r :) ``` This is a very specific change to work around something that really should be handled later on during bufferization (but is outside scope of bufferization today). This change needs to kick in very specific conditions (since its a work-around, and really the created linalg.generic is somewhat of an anti-pattern), using a pattern rewrite to make this change does not allow controlling the transformation. Change this to use a walk and trigger only when needed. Fixes #12019. Fixes #12019
Least-hacky way I could think of to disable building the `iree_tests_e2e_linalg_ext_ops_check_llvm-cpu_local-task_attention.mlir` target on Emscripten while we work on a fix. See #12041 (comment) and https://github.com/iree-org/iree/actions/runs/4130706149/jobs/7137719751 ``` [14/350] Generating check_llvm-cpu_local-task_attention.mlir_module.vmfb from attention.mlir FAILED: tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb /work/build-emscripten/tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb cd /work/build-emscripten/tests/e2e/linalg_ext_ops && /work/full-build-dir/install/bin/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu /work/tests/e2e/linalg_ext_ops/attention.mlir -o check_llvm-cpu_local-task_attention.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/build-emscripten\" --iree-llvm-target-triple=wasm32-unknown-emscripten /work/tests/e2e/linalg_ext_ops/attention.mlir:6:8: error: 'linalg.generic' op inferred input/output operand #3 has shape's dimension #0 to be 2, but found 4 %1 = iree_linalg_ext.attention ins(%query, %key, %value : tensor<1x4x4xf32>, ^ ``` #12081 will run the Emscripten CI on presubmit to catch errors like this sooner.
…#12041) For dispatches with ``` %r = <some compute op> %store = linalg.generic ... ins(%r, ...) outs(%empty :) ``` where the value of `%store` is the final result of the dispatch, to avoid creation of stacks for `%r` when vectorization does not kick in, the user is converted to ``` %store = linalg.generic ... ins(, ...) outs(%r :) ``` This is a very specific change to work around something that really should be handled later on during bufferization (but is outside scope of bufferization today). This change needs to kick in very specific conditions (since its a work-around, and really the created linalg.generic is somewhat of an anti-pattern), using a pattern rewrite to make this change does not allow controlling the transformation. Change this to use a walk and trigger only when needed. Fixes iree-org#12019. Fixes iree-org#12019
…org#12127) Least-hacky way I could think of to disable building the `iree_tests_e2e_linalg_ext_ops_check_llvm-cpu_local-task_attention.mlir` target on Emscripten while we work on a fix. See iree-org#12041 (comment) and https://github.com/iree-org/iree/actions/runs/4130706149/jobs/7137719751 ``` [14/350] Generating check_llvm-cpu_local-task_attention.mlir_module.vmfb from attention.mlir FAILED: tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb /work/build-emscripten/tests/e2e/linalg_ext_ops/check_llvm-cpu_local-task_attention.mlir_module.vmfb cd /work/build-emscripten/tests/e2e/linalg_ext_ops && /work/full-build-dir/install/bin/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu /work/tests/e2e/linalg_ext_ops/attention.mlir -o check_llvm-cpu_local-task_attention.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/build-emscripten\" --iree-llvm-target-triple=wasm32-unknown-emscripten /work/tests/e2e/linalg_ext_ops/attention.mlir:6:8: error: 'linalg.generic' op inferred input/output operand iree-org#3 has shape's dimension #0 to be 2, but found 4 %1 = iree_linalg_ext.attention ins(%query, %key, %value : tensor<1x4x4xf32>, ^ ``` iree-org#12081 will run the Emscripten CI on presubmit to catch errors like this sooner.
For dispatches with
where the value of
%storeis the final result of the dispatch, to avoid creation of stacks for%rwhen vectorization does not kick in, the user is converted toThis is a very specific change to work around something that really should be handled later on during bufferization (but is outside scope of bufferization today). This change needs to kick in very specific conditions (since its a work-around, and really the created
linalg.genericis somewhat of an anti-pattern), using a pattern rewrite to make this change does not allow controlling the transformation. Change this to use a walk and trigger only when needed.Fixes #12019.