You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move compilation tests from build-time to test-time #11354
We have many tests that invoke IREE's compiler at build time (using iree_bytecode_module) and then run the compiled program at test time (e.g. iree_check_test). We'd like to instead invoke the compiler at test time. Along with this, I'd like a way to add compilation-only tests (prompted by this discussion: #11327 (comment)).
This could be tricky with cross compilation - the compiler [tests] should be running on the host, then execution should happen on the target platform (e.g. Android, web, GPU machine).
Note that this would be for CMake only. Bazel doesn't have a way to have dependencies between tests. Good point about cross-compilation making this tricky...
Yeah, I'm pretty sure we don't want to do this. Compiling the artifacts is a build stage of the process and something we don't want happening concurrently with tests that are running (we want build tasks running through build systems, not ctest which isn't even a good test system lol).
(note also that ctest can't cache - needing to regenerate all test inputs every time tests are run is not great given that they can sometimes take minutes to compile)
The iree-test-deps target is a bit of a hack. For our suite of e2e tests, it would be nice if "running the tests" included both running the compiler and executing the compiled programs. That target at least makes it so a build of all doesn't fail if an individual test fails compilation.
For the WebAssembly and WebGPU tests, I'm currently using iree_check_single_backend_test_suite with no driver arg, which just drops down to a loop around iree_bytecode_module. I could
keep that setup
add a new iree_compile_test that either uses iree_bytecode_module in a similar way or runs the compiler at test time
Are there any long-term situations where we'd want this or is this just transient during WebGPU bringup? Tests for the compiler belong in compiler lit tests and if testing these e2e integration-style tests then executing them is critical. I'm not sure exclusively testing "compiler didn't crash" is worth supporting outside of bringup where you can't run anything anywhere.
Good points Ben. Stella had previously complained about all the compilation using the IREE compiler happening at build time and suggested it move to test time. I think the middle ground we ended up with is the iree-test-deps target, which has caused confusion on multiple occasions. Part of the trouble is that in CMake you can declare a dependency between two build targets or between two tests, but not between a test and a build target. One option would be to actually do the reverse and make all our tests build targets. I think this is what check-llvm does except really it's just delegating to lit. But the console output of build rules isn't really ideal for testing. It would be nice to get test caching though. This is starting to sound kind of like how Bazel works :-P
I think the particular thing tripping Scott up on this one though is that the way we do cross-compiling is weird and involves a bunch of hacks. I would love to see us rethink that as well.
Are there any long-term situations where we'd want this or is this just transient during WebGPU bringup?
I think it's transient, but I could imagine other bringup that would benefit from some restructuring. There have been many times now where I've wanted to "just compile the test suite" (and then run it if I have a way to do that) on a particular configuration, but "the test suite" is pretty nebulous - it's split between "benchmarks", "e2e tests", and even other repositories (like https://github.com/iree-org/iree-samples/tree/main/tflitehub).
Also the situation we have right now where you want to run tests, but your IREE host compiler may not support all backends seems pretty reasonable. The fact that my host compiler doesn't support Cuda shouldn't prevent me from building using the LLVM backend for Android. Maybe we should use the TARGET_BACKEND cmake options (or separate new options) even when the build of the compiler is off to indicate which backends to use when creating artifacts.
May be a case here of trying to do too much with a mechanism not really meant to do anything well. For example, something like a compiler_commands-equivalent for compiler and test invocations would let you build quite a bit of these things without trying to shove that all into ctest.
+1 to using the target backend flags to filter things for compilation and HAL drivers to filter things for execution - I'm kind of surprised we aren't doing that already?
+1 to using the target backend flags to filter things for compilation and HAL drivers to filter things for execution - I'm kind of surprised we aren't doing that already?
We do, but when cross compiling IREE_BUILD_COMPILER is set to OFF, which flips all IREE_TARGET_BACKEND_* options to OFF also:
"we can't easily check for which compiler target backends are enabled" is a bit different now that #10629 added --iree-hal-list-target-backends though:
λ iree-compile.exe --iree-hal-list-target-backends
Registered target backends:
cuda
llvm-cpu
metal
metal-spirv
vmvx
vmvx-inline
vulkan
vulkan-spirv
webgpu
webgpu-wgsl
We could have CMake run the tool and check against the list.
That's probably just because there are places only checking the IREE_TARGET_ flags that could be changed to AND IREE_BUILD_COMPILER - we could fix that such that the target backends are ON/OFF based on availability... ah, your new comment was what I was about to say :P doing that one as a cached configure-time check step would also let us verify the user-provided compiler was working.
We could have CMake run the tool and check against the list.
Yeah I think I suggested that in your PR, but I'm a bit wary of automagically turning things off because they aren't supported. In my experience that frequently leads to things not getting tested that you thought were getting tested. I think my preference would be to have the IREE_TARGET_BACKEND_* flags used even when IREE_BUILD_COMPILER=OFF. I think the entire compiler directory is gated on IREE_BUILD_COMPILER, so I'd actually be a bit surprised if there are many places that need to do the "and"
I think my preference would be to have the IREE_TARGET_BACKEND_* flags used even when IREE_BUILD_COMPILER=OFF.
I'd rather not do that, but I hear your concerns about configurations not being explicit. I like to think from the perspective of someone configuring IREE as a subproject or for their first time, and having a clear association between settings (not building the compiler -> all these options aren't relevant and thus are unavailable) helps there. Things get more complicated when building tests or cross compiling. I guess we could add some comments around IREE_HOST_BINARY_ROOT and IREE_BUILD_COMPILER, but such comments might just get buried under the rest of the CMake code...
Activity
GMNGeoffrey commentedon Nov 29, 2022
Note that this would be for CMake only. Bazel doesn't have a way to have dependencies between tests. Good point about cross-compilation making this tricky...
benvanik commentedon Nov 29, 2022
Yeah, I'm pretty sure we don't want to do this. Compiling the artifacts is a build stage of the process and something we don't want happening concurrently with tests that are running (we want build tasks running through build systems, not ctest which isn't even a good test system lol).
benvanik commentedon Nov 29, 2022
(note also that ctest can't cache - needing to regenerate all test inputs every time tests are run is not great given that they can sometimes take minutes to compile)
ScottTodd commentedon Nov 29, 2022
All good points...
The
iree-test-depstarget is a bit of a hack. For our suite of e2e tests, it would be nice if "running the tests" included both running the compiler and executing the compiled programs. That target at least makes it so a build ofalldoesn't fail if an individual test fails compilation.For the WebAssembly and WebGPU tests, I'm currently using
iree_check_single_backend_test_suitewith nodriverarg, which just drops down to a loop aroundiree_bytecode_module. I couldiree_compile_testthat either usesiree_bytecode_modulein a similar way or runs the compiler at test timetests/e2e/xla_ops/abs.mlir)benvanik commentedon Nov 29, 2022
Are there any long-term situations where we'd want this or is this just transient during WebGPU bringup? Tests for the compiler belong in compiler lit tests and if testing these e2e integration-style tests then executing them is critical. I'm not sure exclusively testing "compiler didn't crash" is worth supporting outside of bringup where you can't run anything anywhere.
GMNGeoffrey commentedon Nov 29, 2022
Good points Ben. Stella had previously complained about all the compilation using the IREE compiler happening at build time and suggested it move to test time. I think the middle ground we ended up with is the
iree-test-depstarget, which has caused confusion on multiple occasions. Part of the trouble is that in CMake you can declare a dependency between two build targets or between two tests, but not between a test and a build target. One option would be to actually do the reverse and make all our tests build targets. I think this is whatcheck-llvmdoes except really it's just delegating to lit. But the console output of build rules isn't really ideal for testing. It would be nice to get test caching though. This is starting to sound kind of like how Bazel works :-PI think the particular thing tripping Scott up on this one though is that the way we do cross-compiling is weird and involves a bunch of hacks. I would love to see us rethink that as well.
ScottTodd commentedon Nov 29, 2022
I think it's transient, but I could imagine other bringup that would benefit from some restructuring. There have been many times now where I've wanted to "just compile the test suite" (and then run it if I have a way to do that) on a particular configuration, but "the test suite" is pretty nebulous - it's split between "benchmarks", "e2e tests", and even other repositories (like https://github.com/iree-org/iree-samples/tree/main/tflitehub).
GMNGeoffrey commentedon Nov 29, 2022
Also the situation we have right now where you want to run tests, but your IREE host compiler may not support all backends seems pretty reasonable. The fact that my host compiler doesn't support Cuda shouldn't prevent me from building using the LLVM backend for Android. Maybe we should use the TARGET_BACKEND cmake options (or separate new options) even when the build of the compiler is off to indicate which backends to use when creating artifacts.
benvanik commentedon Nov 29, 2022
May be a case here of trying to do too much with a mechanism not really meant to do anything well. For example, something like a compiler_commands-equivalent for compiler and test invocations would let you build quite a bit of these things without trying to shove that all into ctest.
+1 to using the target backend flags to filter things for compilation and HAL drivers to filter things for execution - I'm kind of surprised we aren't doing that already?
ScottTodd commentedon Nov 29, 2022
We do, but when cross compiling
IREE_BUILD_COMPILERis set toOFF, which flips allIREE_TARGET_BACKEND_*options toOFFalso:iree/CMakeLists.txt
Lines 207 to 208 in 72e0d3c
That, combined with being able to set
IREE_HOST_BINARY_ROOTto anything (pip install, bazel build, etc.), led to this logic:iree/build_tools/cmake/iree_check_test.cmake
Lines 236 to 254 in 72e0d3c
ScottTodd commentedon Nov 29, 2022
"we can't easily check for which compiler target backends are enabled" is a bit different now that #10629 added
--iree-hal-list-target-backendsthough:We could have CMake run the tool and check against the list.
benvanik commentedon Nov 29, 2022
That's probably just because there are places only checking the IREE_TARGET_ flags that could be changed to AND IREE_BUILD_COMPILER - we could fix that such that the target backends are ON/OFF based on availability... ah, your new comment was what I was about to say :P doing that one as a cached configure-time check step would also let us verify the user-provided compiler was working.
GMNGeoffrey commentedon Nov 29, 2022
Yeah I think I suggested that in your PR, but I'm a bit wary of automagically turning things off because they aren't supported. In my experience that frequently leads to things not getting tested that you thought were getting tested. I think my preference would be to have the
IREE_TARGET_BACKEND_*flags used even whenIREE_BUILD_COMPILER=OFF. I think the entire compiler directory is gated onIREE_BUILD_COMPILER, so I'd actually be a bit surprised if there are many places that need to do the "and"ScottTodd commentedon Dec 1, 2022
I'd rather not do that, but I hear your concerns about configurations not being explicit. I like to think from the perspective of someone configuring IREE as a subproject or for their first time, and having a clear association between settings (not building the compiler -> all these options aren't relevant and thus are unavailable) helps there. Things get more complicated when building tests or cross compiling. I guess we could add some comments around
IREE_HOST_BINARY_ROOTandIREE_BUILD_COMPILER, but such comments might just get buried under the rest of the CMake code...ScottTodd commentedon Jun 27, 2024
Going to close this old issue. I think the path forward for these sorts of tests is to move e2e tests into a separate project (CMake subproject, pytest suite, etc.) that purely depends on release packages (or just the compiler + runtime binary tools), similar to https://github.com/nod-ai/SHARK-TestSuite/tree/main/iree_tests. It's still convenient to work with CMake from a single build directory though.