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
GPU benchmarks do not reflect the real performance. #5248
compiler/dialectsRelating to the IREE compiler dialects (flow, hal, vm)performance ⚡Performance/optimization related work across the compiler and runtime
We are using batch mode (which was introduced in #5012) to benchmark MobileBert and MobileNetV2. This can help us to amortize overhead. However, the numbers are much smaller in many cases, especially when increasing the batch size. We think that this is because of missing barriers. Instead of duplicating hal.command_buffer.dispatch ops, we should probably submit the command buffer multiple times. If this works, it will address the issue (see #5052) of enabling batch mode on Pixel 4.
I think it's likely because we duplicate dispatches without inserting any barriers. That essentially means increasing the number of warps for each dispatch to help filling the GPU. After dividing by the repeat count, we are getting a better number than it should be. There are certain dispatches in both models that are just working on small scale problem size; increasing warp count hides and "improves" the latency for them. Instead of duplicating dispatches, I think we want to submit the command buffer multiple times and average at that level. It will help to keep the original dispatch structure intact.
This also blocks adding mobile-bert f16 version to Mako benchmark, see #5204
One sample run with batch_size=16 for MobilBert f16.
-------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------------------------------
BM_serving_default/process_time/real_time 157 ms 37.7 ms 16
BM_serving_default/process_time/real_time 90.3 ms 29.8 ms 16
BM_serving_default/process_time/real_time 91.3 ms 31.5 ms 16
BM_serving_default/process_time/real_time 87.7 ms 27.8 ms 16
BM_serving_default/process_time/real_time 89.5 ms 27.6 ms 16
BM_serving_default/process_time/real_time 88.8 ms 28.5 ms 16
BM_serving_default/process_time/real_time 90.1 ms 29.6 ms 16
BM_serving_default/process_time/real_time 90.2 ms 29.8 ms 16
BM_serving_default/process_time/real_time 90.4 ms 29.9 ms 16
BM_serving_default/process_time/real_time 150 ms 30.9 ms 16
BM_serving_default/process_time/real_time 89.9 ms 29.6 ms 16
BM_serving_default/process_time/real_time 89.9 ms 29.6 ms 16
BM_serving_default/process_time/real_time 89.7 ms 29.9 ms 16
BM_serving_default/process_time/real_time 150 ms 31.5 ms 16
BM_serving_default/process_time/real_time 89.5 ms 29.5 ms 16
BM_serving_default/process_time/real_time 91.1 ms 30.9 ms 16
BM_serving_default/process_time/real_time 148 ms 29.0 ms 16
BM_serving_default/process_time/real_time 86.7 ms 26.6 ms 16
BM_serving_default/process_time/real_time 86.5 ms 26.2 ms 16
BM_serving_default/process_time/real_time 87.5 ms 27.2 ms 16
BM_serving_default/process_time/real_time_mean 102 ms 29.7 ms 20
BM_serving_default/process_time/real_time_median 90.0 ms 29.6 ms 20
BM_serving_default/process_time/real_time_stddev 25.6 ms 2.44 ms 20
To submit the command buffer multiple times, I think we just need to drop the OneShot when creating the command buffer, and extend hal.ex.submit_and_wait to take multiple command buffers. Seems quite straightforward. @benvanik please correct me if I missed something. :D
I believe only one-shot command buffers are supported right now, though I've been meaning to support reusable ones. It requires some work on the CPU side to make work.
I'm doing some other cleanup on the HAL and can work on removing the submit_and_wait and replacing it with proper submission, in which case you'd be able to submit multiple command buffers (the same multiple times, or multiple ones that were recorded). I'll file an issue!
(oh to clarify on those issues - I wanted to track them but I consider those/this issue lower priority than getting tracy support for vulkan working - I've always warned that this approach to measuring individual dispatches as being deceptive and brittle, and for pure interactive profiling the tracy approach will work better)
Update as I integrate tracy timestamps: tracy will only work with oneshot command buffers (as it must record timestamps unique per submission) - since tracing is most interesting for performance work it would not be great to require reusable command buffers for the benchmarks :)
Re-recording the command buffer would be a workaround. If the pass for benchmarking found all flow streams and put them in an scf.for that would (probably, when all of that's implemented) work.
Or we just create some benchmarks by hand and leave the automation of per-dispatch microbenchmarks out (my vote :)
update to the update: I think with some trickery tracy could work with reusable command buffers - it'd be a bigger implementation though and I won't be able to do it in the first go (of the same style of complexity as the timeline semaphore emulation).
(oh to clarify on those issues - I wanted to track them but I consider those/this issue lower priority than getting tracy support for vulkan working - I've always warned that this approach to measuring individual dispatches as being deceptive and brittle, and for pure interactive profiling the tracy approach will work better)
Point taken. IMO, there are two different use scenarios:
Having an overall number to show where we are regarding GPU performance on certain models. This is primarily for per-commit automated benchmarking and status tracking. There should be no manual work involved.
Looking at the details of all the dispatches in a model and figure out what's the performance bottleneck and why some regression reported by 1. There are manual work involved for sure because we need somebody staring at the charts/figures. :)
I see Tracy provides a great solution to 2. This issue is mostly for 1. Both are great to have. :)
compiler/dialectsRelating to the IREE compiler dialects (flow, hal, vm)performance ⚡Performance/optimization related work across the compiler and runtime
Activity
hanhanW commentedon Mar 30, 2021
This also blocks adding mobile-bert f16 version to Mako benchmark, see #5204
One sample run with batch_size=16 for MobilBert f16.
antiagainst commentedon Mar 30, 2021
To submit the command buffer multiple times, I think we just need to drop the
OneShotwhen creating the command buffer, and extendhal.ex.submit_and_waitto take multiple command buffers. Seems quite straightforward. @benvanik please correct me if I missed something. :Dbenvanik commentedon Mar 30, 2021
I believe only one-shot command buffers are supported right now, though I've been meaning to support reusable ones. It requires some work on the CPU side to make work.
I'm doing some other cleanup on the HAL and can work on removing the submit_and_wait and replacing it with proper submission, in which case you'd be able to submit multiple command buffers (the same multiple times, or multiple ones that were recorded). I'll file an issue!
benvanik commentedon Mar 30, 2021
filed: #5249 #5250
benvanik commentedon Mar 30, 2021
(oh to clarify on those issues - I wanted to track them but I consider those/this issue lower priority than getting tracy support for vulkan working - I've always warned that this approach to measuring individual dispatches as being deceptive and brittle, and for pure interactive profiling the tracy approach will work better)
benvanik commentedon Mar 31, 2021
Update as I integrate tracy timestamps: tracy will only work with oneshot command buffers (as it must record timestamps unique per submission) - since tracing is most interesting for performance work it would not be great to require reusable command buffers for the benchmarks :)
Re-recording the command buffer would be a workaround. If the pass for benchmarking found all flow streams and put them in an scf.for that would (probably, when all of that's implemented) work.
Or we just create some benchmarks by hand and leave the automation of per-dispatch microbenchmarks out (my vote :)
benvanik commentedon Mar 31, 2021
update to the update: I think with some trickery tracy could work with reusable command buffers - it'd be a bigger implementation though and I won't be able to do it in the first go (of the same style of complexity as the timeline semaphore emulation).
antiagainst commentedon Mar 31, 2021
Point taken. IMO, there are two different use scenarios:
I see Tracy provides a great solution to 2. This issue is mostly for 1. Both are great to have. :)
Add mobile-bert f16 version to Mako benchmark. (#5204)
[ci] Avoid batching for Vulkan benchmarks
Drop batch mode for Mako benchmarks.
Drop batch mode for Mako benchmarks. (#5606)
Add barrier after duplicated dispatches for benchmarking (#5919)
antiagainst commentedon Sep 3, 2021
With #5919 and batching we have a temporary solution reflecting the kernel execution time for existing models. So closing this for now.