Repository navigation
Add directory for microbenchmarking - #5260
Conversation
MaheshRavishankar
left a comment
There was a problem hiding this comment.
This would be good to have if you as me, but other people have a more informed opinion.
Only question though is could we just start from the linalg. operation? There are definitely advantages to using mhlo. Some ops might be lowered to a sequence of operations, but even then since we dont want anything mhlo in our core repo, starting from Linalg might be better.
| MLIR_FILE_PATH=${1} | ||
| ARGS=${@:2} | ||
|
|
||
| adb shell 'mkdir /data/local/tmp' |
There was a problem hiding this comment.
If we are checking this in, it needs more documentation.
There was a problem hiding this comment.
yeah, this would probably be better as a gist - otherwise it becomes yet another thing to support. (github deleted the rest of the comment): or a big scare tag that says "only runs on ahmeds machine, ask ahmed for help" would at least set expectations :)
There was a problem hiding this comment.
I remembered that I dropped comments about scripts somewhere, but it seems gone...
We have something similar in build_tools/mako/ which is mainly for mako benchmarks. We probably can reuse some of codes from there.
https://github.com/google/iree/blob/main/build_tools/mako/compile_android_modules.py
https://github.com/google/iree/blob/main/build_tools/mako/benchmark_modules_on_android.py
They are configured in https://github.com/google/iree/blob/main/build_tools/mako/configuration.py
I think we can add MICROBENCHMARKS, I'm happy to help on that once this gets check-in.
benvanik
left a comment
There was a problem hiding this comment.
nit: "microbenchmark" is canonically one word so you can remove the underscore in the name (https://en.wiktionary.org/wiki/microbenchmark)
Only question though is could we just start from the
linalg.operation?
Agreed that linalg would be nice - soon we'll be removing HLO from IREE (relegating it only to the tensorflow importer) and as such none of these tests would be usable without doing a tensorflow importer build. That may be fine for these uses but then we may want to put these under microbenchmarks/mhlo/ so it's easy to exclude when someone is not building tf. If MHLO was the source of truth we could also have a script to run over the mhlo/ dir and generate a linalg dir, but I'm not sure how useful that is. We'll be having a lot of things coming from tosa too, and having a mix of linalg, mhlo, and tosa for microbenchmarking will be really hard to juggle as you'd need builds of all the different tools. That may still be worth it, though, if what you want to test includes the tosa/mhlo->linalg conversion - but if you think it's mostly just testing linalg then we should bake that out. I defer to you all and just don't want any surprises when I eventually remove the HLO passes from iree-opt/iree-translate :)
| MLIR_FILE_PATH=${1} | ||
| ARGS=${@:2} | ||
|
|
||
| adb shell 'mkdir /data/local/tmp' |
There was a problem hiding this comment.
yeah, this would probably be better as a gist - otherwise it becomes yet another thing to support. (github deleted the rest of the comment): or a big scare tag that says "only runs on ahmeds machine, ask ahmed for help" would at least set expectations :)
|
|
||
| adb shell 'mkdir /data/local/tmp' | ||
| MLIR_FILE_NAME=$(basename $MLIR_FILE_PATH) | ||
| TARGET_VM_FILE=/tmp/$MLIR_FILE_NAME.fbvm |
There was a problem hiding this comment.
The plan Is this should work on any linux-machine with local android phone attached =),
I don't mind deleting but was to make it easy to reproduce the same numbers I have:
had for this is users need to are:
- Build an android release build
- Define IREE_RELEASE_DIR and run the script.
This has been my workflow for awhile iterating on performance on CPU.
IMO having both are good for but specifically at this level (performance of an op or a sequence of ops (e.g fused conv-batchnorm) it easier to start with tosa or mhlo as it gets complicated adding all init_tensor, fill and constructing (or copy-paste) linalg.generics |
a288836 to
c9ec138
Compare
|
I think it depends on what we want to benchmark. Starting from Linalg could hide something like |
hanhanW
left a comment
There was a problem hiding this comment.
I think it is meaningless if we only put files here. At least, we should translate them to IREE modules? And maybe use lit tests to check output?
I can help on connecting these to benchmarking infrastructure after we land it.
Its very important to not drop fill, init_tensor, reshapes which is why doing something like matmul or various types of conv easy to be added here at the front end side (HLO or TOSA) is easier otherwise it will get hard to reason about the performance of the op. |
Good ideas will be good to add rules to translate these and report the results on mako dashboard. |
|
I have no opinions here. If this is deemed good to land, I'd be happy to use it. |
antiagainst
left a comment
There was a problem hiding this comment.
Its very important to not drop fill, init_tensor, reshapes which is why doing something like matmul or various types of conv easy to be added here at the front end side (HLO or TOSA) is easier otherwise it will get hard to reason about the performance of the op.
+1. Even if we convert to linalg ops, we should keep them as they are part of the original op. Otherwise we might measure something that is different. For example, right now the fill and copy generated from the original padded convolution op can be a large portion of the cost. Removing them would not reflect the current status.
| @@ -0,0 +1,74 @@ | |||
| // Convolution ops sampled from MobileVision V1 (mobilenet_v1_100_224) | |||
There was a problem hiding this comment.
Convolution ops might largely be the same but still do we care v1 that much with v2 and even newer models? I'd assume later models are more prevalently used.
There was a problem hiding this comment.
This is just an FYI the following are sampled from specific model (a peace extra information that is sometimes useful)
| @@ -0,0 +1,74 @@ | |||
| // Convolution ops sampled from MobileVision V1 (mobilenet_v1_100_224) | |||
| // https://github.com/google/iree/blob/main/integrations/tensorflow/e2e/slim_vision_models/slim_vision_model_test.py#L34 | |||
|
|
|||
There was a problem hiding this comment.
It might worth to explain the naming scheme and also add some comment above each conv to mention the key points to measure (like padding, stride, etc.) cause the mhlo op can be very verbose. :)
There was a problem hiding this comment.
I think it worths to attach padding/stride informations in the function name, it can be showed on Mako benchmarks.
There was a problem hiding this comment.
+1 on explain the naming scheme
There was a problem hiding this comment.
The naming convention will get very long and they kind of implicit looking at the output size :)
I never said we should have a single linalg operation. You could have a sequence of Linalg operations (Which is more important). The goal is to eventually rid the IREE code base of MHLO ops. |
| %rhs = iree.unfoldable_constant dense<1.0> : tensor<384x32xf32> | ||
| %0 = "mhlo.dot"(%lhs, %rhs) : (tensor<384x384xf32>, tensor<384x32xf32>) -> tensor<384x32xf32> | ||
| return %0 : tensor<384x32xf32> | ||
| } No newline at end of file |
| @@ -0,0 +1,74 @@ | |||
| // Convolution ops sampled from MobileVision V1 (mobilenet_v1_100_224) | |||
| // https://github.com/google/iree/blob/main/integrations/tensorflow/e2e/slim_vision_models/slim_vision_model_test.py#L34 | |||
|
|
|||
There was a problem hiding this comment.
+1 on explain the naming scheme
|
The more I think about it, the more I dont like having operations lowered from mhlo for testing. I am not going to block this, but this will need to be deprecated/modified when we strip mhlo out of the core repo. |
This needs definitely requires more iteration for documentation, improve scripts...etc but for now IMO we can start with something simple for reproducibility and iterate ?
This needs definitely requires more iteration for documentation, improve scripts...etc but for now IMO we can start with something simple for reproducibility and iterate ?
a49ce9b to
a3c9a7f
Compare
hanhanW
left a comment
There was a problem hiding this comment.
Looks good to me. I'm not sure if others have more comment, but I approve for unblock merging it.
| // The following ops are sampled from mobile_bert | ||
| // https://github.com/google/iree/blob/main/integrations/tensorflow/e2e/mobile_bert_squad_test.py | ||
|
|
||
| func @dot_general_4_x384x32x384() -> tensor<4x384x384xf32> attributes { iree.module.export } { |
There was a problem hiding this comment.
Is the underline intended?
| func @dot_general_4_x384x32x384() -> tensor<4x384x384xf32> attributes { iree.module.export } { | |
| func @dot_general_4x384x32x384() -> tensor<4x384x384xf32> attributes { iree.module.export } { |
|
@hanhanW In addition to mako tracking these for regression. IMO it will be very cool is to have a manual gitHub action users can trigger to run microbenchmarks on head vs this PR commit and post the textual as a comment on the PR. similar to what I usually do but not on my device/machine and more globally reproducible :) |
Yes, we actually can do it on model benchmarks today. I usually do it manually through BuildKite. E.g., I'm now working on adding new metrics for linalg on tensors path, and I manually triggered a run based on current branch: https://buildkite.com/iree/iree-android-benchmark/builds/2195 We can probably integrate the action into label stuff (like kokoro:force_rerun). I think @GMNGeoffrey knows more about it. |
a3c9a7f to
a6f7f12
Compare
* 6bd5658 Merge google -> main (#5319) * 2e5257d Merge branch 'main' into google-to-main * 6936ee7 Patch VMLA performance by reserving vector size before pushing to it. (#5316) * f2f0041 NFC: Cleanup ConcretizeTileAmongstWorkgroupsPass. (#5297) * f96726a Add tests to run few other (smaller) models with Linalg on tensors path. (#5306) * fd64070 Revert "Add wasm-micro-runtime submodule and get building with CMake." (#5312) * ce0285f Continue pruning abseil usage: switch from absl::InlinedVector to std::vector... * 71e24b6 Removing hal.buffer.fill and hal.buffer.copy. (#5307) * 3c611d3 Add Mako benchmark config template file. (#5200) * 4d1a394 Fix RFFT bugs in VMLA. (#5308) * 0d55c95 Add configure_bazel.py step to TensorFlow getting started doc. * 1386d2c Switch simple_embedding_test to include drivers explicitly. (#5304) * 402550b Add StripAsserts pass and handle tf.Identity ops on tensor lists. (#5294) * fbdb4ef Add new metrics to MobileNetV2 benchmarks. (#5301) * 99c8eac Implementing Vulkan dispatch tracing. (#5287) * 2681dff Insert clones prior to mutation and not where it originates. (#5292) * aeafd9e Fix CUDA HAL bug and enable more execution tests (#5296) * 2801780 [CUDA Codegen] Enable tiling and vectorization for MatMulOp (#5293) * c61fefe Extend AffineMin canonicalization to support scf.parallel (#5289) * e0ee3f3 Add directory for microbenchmarking (#5260) * b8da32c Set wasm-export-name attributes on exported functions again. (#5286) * e2a2f81 Canonicalize affine min before applying tile-and-vecotrize passes (#5285) * 23861f7 [CUDA codegen] add vectorization infrastructure (#5278) * 6f443c4 Drop deps on Abseil's core_headers, synchronization, macros. (#5275) * e5b9e8a Actually run MobileNet with fake weights to check correctness (#5284) * e56db9a Remove dead code in LinalgToSPIRV (#5281) * 8863aa1 [NFC] Fix typos in variable names. (#5279) * 9cd93ba Turn vectorization on by default for linalg on tensors path (#5280) * 894dac6 Merge google -> main #5276 * b738162 Changing HAL dialect syntax to express all types. (#5239) * 1ba4e88 Merge branch 'main' into google-to-main * 531c73e Fix yml syntax (#5274) * 494fe32 Bumping the tracy version to 0.7.7 (WIP). (#5272) * 3616323 Disable Vulkan float16 tests on Pixel4 (#5273) * ade7ff1 Disable running BERT on Vulkan (see Issue #5268) (#5269) * 25ddc10 Add tracing to allocations made from VMA. (#5271) * df454f4 Changing iree_vm_list_resize to grow by 2x. (#5270) * bd9a113 Adding command buffer queue affinity. (#5265) * de834ae Make status matcher print the message when it fails. (#5266) * 10f5eaf Add f16 e2e tests for vulkan (#5257) * 1bdc3a4 Actually make MobileBERT run in the test. (#5264) * 2e05313 Add support for module almost_eq check for f16 type (#5261) COPYBARA_INTEGRATE_REVIEW=#5321 from NatashaKnk:main-to-google 6bd5658 PiperOrigin-RevId: 366926967
* 6bd5658 Merge google -> main (#5319) * 2e5257d Merge branch 'main' into google-to-main * 6936ee7 Patch VMLA performance by reserving vector size before pushing to it. (#5316) * f2f0041 NFC: Cleanup ConcretizeTileAmongstWorkgroupsPass. (#5297) * f96726a Add tests to run few other (smaller) models with Linalg on tensors path. (#5306) * fd64070 Revert "Add wasm-micro-runtime submodule and get building with CMake." (#5312) * ce0285f Continue pruning abseil usage: switch from absl::InlinedVector to std::vector... * 71e24b6 Removing hal.buffer.fill and hal.buffer.copy. (#5307) * 3c611d3 Add Mako benchmark config template file. (#5200) * 4d1a394 Fix RFFT bugs in VMLA. (#5308) * 0d55c95 Add configure_bazel.py step to TensorFlow getting started doc. * 1386d2c Switch simple_embedding_test to include drivers explicitly. (#5304) * 402550b Add StripAsserts pass and handle tf.Identity ops on tensor lists. (#5294) * fbdb4ef Add new metrics to MobileNetV2 benchmarks. (#5301) * 99c8eac Implementing Vulkan dispatch tracing. (#5287) * 2681dff Insert clones prior to mutation and not where it originates. (#5292) * aeafd9e Fix CUDA HAL bug and enable more execution tests (#5296) * 2801780 [CUDA Codegen] Enable tiling and vectorization for MatMulOp (#5293) * c61fefe Extend AffineMin canonicalization to support scf.parallel (#5289) * e0ee3f3 Add directory for microbenchmarking (#5260) * b8da32c Set wasm-export-name attributes on exported functions again. (#5286) * e2a2f81 Canonicalize affine min before applying tile-and-vecotrize passes (#5285) * 23861f7 [CUDA codegen] add vectorization infrastructure (#5278) * 6f443c4 Drop deps on Abseil's core_headers, synchronization, macros. (#5275) * e5b9e8a Actually run MobileNet with fake weights to check correctness (#5284) * e56db9a Remove dead code in LinalgToSPIRV (#5281) * 8863aa1 [NFC] Fix typos in variable names. (#5279) * 9cd93ba Turn vectorization on by default for linalg on tensors path (#5280) * 894dac6 Merge google -> main #5276 * b738162 Changing HAL dialect syntax to express all types. (#5239) * 1ba4e88 Merge branch 'main' into google-to-main * 531c73e Fix yml syntax (#5274) * 494fe32 Bumping the tracy version to 0.7.7 (WIP). (#5272) * 3616323 Disable Vulkan float16 tests on Pixel4 (#5273) * ade7ff1 Disable running BERT on Vulkan (see Issue #5268) (#5269) * 25ddc10 Add tracing to allocations made from VMA. (#5271) * df454f4 Changing iree_vm_list_resize to grow by 2x. (#5270) * bd9a113 Adding command buffer queue affinity. (#5265) * de834ae Make status matcher print the message when it fails. (#5266) * 10f5eaf Add f16 e2e tests for vulkan (#5257) * 1bdc3a4 Actually make MobileBERT run in the test. (#5264) * 2e05313 Add support for module almost_eq check for f16 type (#5261) PiperOrigin-RevId: 366926967
This needs definitely requires more iteration for documentation, improve scripts...etc
but for now IMO we can start with something simple for reproducibility and iterate ?