Repository navigation
Add RISC-V benchmark configs - #9218
Conversation
|
@dcaballe I drafted the benchmark configs for RISC-V. They will generate the RISC-V modules when we build with I'm not familiar with RISC-V, so I have questions about
|
For the 64-bit configuration, you can try: You can find further information here: https://google.github.io/iree/building-from-source/riscv/#optional-configuration For the 32-bit configuration, I think @hcindyl should be able to help but it should be something like:
I would use RV64 and RV32 so that it's the same as in the flags.
Yes but we only need rv32 for person detection, for now. |
hcindyl
left a comment
There was a problem hiding this comment.
We need a benchmark config to invoke codegen only and add embedded library code size check.
| "--iree-llvm-target-cpu-features=+m,+a,+f,+d,+c" | ||
| ) | ||
|
|
||
| # CPU, Dylib-Sync, RISCV64, full-inference |
There was a problem hiding this comment.
We can't run the inference from the iree-benchmark-module because the runtime binary needs to be built with RV64 compiler and the binary needs to be run under an emulator.
This should be codegen only and the benchmark should be about the codegen time and the embedded dispatch library size.
There was a problem hiding this comment.
Currently the benchmark framework doesn't support only compiling modules, but there is no harm to have runtime configs here, since we don't run them in the pipeline. The rules I add here are just for compiling the RV64 modules.
I'm adding the script to collect compilation time and binary size and it will work with the module generated from these rules (#9227).
There was a problem hiding this comment.
I see from #9227 we only get the module size. However, I wonder if we should report both the bytecode module size as well as the embedded workload library size.
There was a problem hiding this comment.
I think it is a good idea to also track the embedded library size. The issue is I don't think our current infra can handle that many metrics well. So if the module size is good enough for now, I'd prefer to postpone the embedded library size.
I'm working on a new benchmark infra design and we should be able to support much more metrics with it. Happy to chat offline if you are interested in it : )
There was a problem hiding this comment.
See the reply in #9218 (comment). I didn't mean to try the size for every dispatch library, but the total size of the .so would be sufficient, so that's two numbers in total, bytecode size and .so size.
There was a problem hiding this comment.
SGTM : ) I think we can work on the bytecode size (total module size), as it is more straightforward. The .so size can be added later (with --iree-vm-emit-polyglot-zip as you suggested or other ways, but they require some extra changes in the build system).
There was a problem hiding this comment.
Sorry, I saw this after submitting #9218 (comment). Yes, please, let's focus on just one metric for now, either the .so size of the bytecode size would work. Whatever is simpler.
| "--iree-llvm-target-triple=riscv64" | ||
| "--iree-llvm-target-cpu=generic-rv64" | ||
| "--iree-llvm-target-abi=lp64d" | ||
| "--iree-llvm-target-cpu-features=+m,+a,+f,+d,+c" |
There was a problem hiding this comment.
See https://github.com/google/iree/blob/52f62b8afdd9663b37f8dd94a247eaa654857bc7/runtime/src/iree/hal/local/elf/testdata/generate.sh#L28-L47 on how to invoke iree-compile to generate the dispatchable workload we care about (not the VM control code).
There was a problem hiding this comment.
Is there a big difference between counting .vmfb vs. the embedded dynamic library? The vmfb should include all the embedded dynamic libraries and I assume usually we deploy .vmfb (according to https://google.github.io/iree/building-from-source/riscv/#optional-configuration).
There was a problem hiding this comment.
If we intend to generate the full bytecode module, we should consider to add --iree-llvm-debug-symbols=false to avoid the overhead of including the symbols in the workload library.
If we add --iree-vm-emit-polyglot-zip flag then the workload library can be extracted from the bytecode module with zipinfo
There was a problem hiding this comment.
Do we want to track the total size of workload libraries or each of them (there are usually 70~90 libraries in a model)?
The number of workload libraries (dispatches) are frequently changed when we change the fuse, so it will be an issue to track the history of their sizes. Also our dashboard can't handle that many metrics well.
There was a problem hiding this comment.
My idea is if we mainly distribute the full bytecode module (I assume), then tracking the size of bytecode module is quite important, as It tells us the final binary size that will be distributed.
This size includes the VM code, workload libraries, and maybe other unexpected things. It can be unclear which part is wrong when we see the size is increased, but it also covers every part.
The next step can count the size of each part separately, which provides better insights. But it is still valuable to track the total binary size as it is the actual binary size.
There was a problem hiding this comment.
Is there a big difference between counting
.vmfbvs. the embedded dynamic library? The vmfb should include all the embedded dynamic libraries and I assume usually we deploy.vmfb(according to https://google.github.io/iree/building-from-source/riscv/#optional-configuration).
.vmfb includes the VM flatbuffer control and the embedded dynamic library, and the LLVM target triple should only affect the latter, but the former should affect the delta for improvement/regression. For example, person detect bytecode module built for x86_64 has the size of 729kB, but 480kB is the LLVM-target-dependent workload (model_linked_llvm_embedded_elf_x86_64.so). We want to present those two numbers separably to identify the improvement/regression.
There was a problem hiding this comment.
Indeed, all that fine-grained information could be very useful in the future but the goal for this quarter is to just track the size of the full model from the .so file without symbols/debug information. I expect to use this to quickly detect major changes in code size, such us the one related to tosa.apply_scale (one order of magnitude), and get an overall long-term view but not to scrutinize/root-cause every small increase because increases will happen. For that purpose, just tracking the full model size would be enough. We can iterate and gather more information once we have something working. Let's keep it simple for now.
@benvanik provided some flags to keep the temporary files around here.
|
Updated the config with the suggestions in #9218 (comment). @dcaballe @hcindyl Let me know if those compilation options make sense to you : ) Also I refer the "microarchitecture" (defined here) of this config as "Generic", not sure if that is a correct name. |
antiagainst
left a comment
There was a problem hiding this comment.
LGTM regarding general structure; I'll leave others to check RISC-V specific stuff. :)
Just two general points that we'd like to watch out and improve in the future:
- I see we are generating more and more permutations for different targets. The benchmark suite tarball uploaded to buildkite right now contains everything. It's growingly large (at 1.27GB right now). Given that these targets are for different scenarios, we should consider split the benchmark tarball and build different subsets on different pipelines, e.g., only building ARM CPU / Adreno GPU / Mali GPU targets in android benchmarking pipeline, only building x86-64 / RISC-V / CUDA targets in cloud benchmarking pipeline. This reduces building time, reduces tarball generating / uploading time, and it also reduces time to download those tarballs (esp. for RPI4s driving those Android phones). This can be done e.g., by registering more pseudo targets like
iree-benchmark-suites-x86-64etc. and make CMake targets generating x86-64 artifacts a dependency. - As an inline comment.
| ################################################################################ | ||
| # Add benchmarks for all platforms. # | ||
| ################################################################################ | ||
| include(linux-riscv.cmake) |
There was a problem hiding this comment.
We'd want to move the configurations for mobile CPU/GPU in the above to its separate files and include here to be consistent. Don't need to happen in this patch though.
Definitely agree with target split for benchmark suites. I was planning to do this later but decided to do it first as it's not too complicated #9237. |
| "${DEEPLABV3_FP32_MODULE}" | ||
| "${MOBILESSD_FP32_MODULE}" | ||
| "${POSENET_FP32_MODULE}" | ||
| "${MOBILEBERT_FP32_MODULE}" |
There was a problem hiding this comment.
MobileSSD and mobilenet v2 should use the quantize version in https://github.com/google/iree-samples/tree/main/tflitehub.
There was a problem hiding this comment.
As #9218 (comment), we only add MobileBert in this change.
dcaballe
left a comment
There was a problem hiding this comment.
It looks good! Just a couple of comments! Thanks!
| "${POSENET_FP32_MODULE}" | ||
| "${MOBILEBERT_FP32_MODULE}" | ||
| "${MOBILENET_V2_MODULE}" | ||
| "${MOBILENET_V3SMALL_MODULE}" |
There was a problem hiding this comment.
We should only be tracking MobileNetV1 (rv64, fp32), MobileBert (rv64, fp32), DeepLabV3 (rv64, fp32) and Person Detection (rv32, quantized) for now (see #9167) but we don't have to add them all as part of this PR. I would add just one for now. We can add the rest incrementally and consider more for rv32, but first we have to figure out if they are still compiling successfully for RISC-V (we are not tracking any of this) and know more about the limitations to run them on an FPGA or any other mean. I don't think we can have a large number of models for the time being due to execution constraints.
There was a problem hiding this comment.
I only keep MOBILEBERT_FP32_MODULE in this change as an example. It is a good idea to add the rest modules in the follow-up PRs.
The configs themselves don't concern me, but I am worried about growing complexity in https://github.com/google/iree/blob/main/build_tools/cmake/iree_benchmark_suite.cmake as we add more types of "benchmarking" and more platforms. At some point we might want to pull pieces of that into standalone python/bash scripts, to decouple from the build system. |
I'm planning to do a big refactoring of the current benchmark framework in the following months, including replacing some cmake rules with python scripts. Originally I wouldn't do these changes before the new benchmark framework, but as it will take some time to happen and we want to have these features (x86, risc-v, cuda pipeline, binary sizes) now, I think it is fine as long as we don't stretch this too much. Pipelines for more architectures and collecting binary sizes are basically the boundary I would push to. Beyond that is too complicated for our current framework. |
|
+1 to reducing the complexity in iree_benchmark_suite.cmake! |
|
Thank you so much for accommodating our needs! We understand that adding support for these metrics is a stretch and that's why I'm pushing to keep it as minimalistic as possible. We currently don't have any way to test/track anything related to RISC-V, which makes our RISC-V users the first line of testing, with all the negative implications of that. The fact that we don't have hardware to run on makes the situation even more complicated. I hope that with these metrics we can at least catch some major issues before hitting the user. I also think that once these metrics are more generally used in the pipelines and we can enable execution on RISC-V, the infra implementation should be more uniform and require less special casing. At this point, I'm not aware of any other metrics or configurations that we may urgently need in the short term (@hcindyl, please, correct me if I'm wrong) other than enabling execution for RISC-V (probably in Q3). Hopefully, this provides some clarity on the short- and mid-term needs. |
dcaballe
left a comment
There was a problem hiding this comment.
The RISC-V aspect of it looks good to me. Thanks!

Add benchmark configs for RV64 and RV32 architecture.
Currently we don't mean to run these benchmarks, they are just for compiling the modules for now, so we can collect the compilation statistics. However we keep them in the same format as other benchmarks, as we will run them eventually.
There are some changes to be done in
iree_benchmark_suiteto generate the statistics with some special parameters (--iree-llvm-debug-symbols=falseand--iree-vm-emit-polyglot-zip). They will be done in the follow-up changes.