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
MobileBert Performance Regression on Pixel 4 CPU at 8d74bfa28dd35203fba700aa1f1d88c200c848cd #4686
This is the expected regression from disabling executable linking that was fixed in 1321588. I'll get a trace from my desktop to confirm the current main is fine - if you have traces from the android devices then you can check them.
The pictures look really awesome! I will try to get them from an Android device. (I haven't tried tracy on Android yet) Which tool did you use to run the model? Was it iree-run-module or iree-benchmark-module or other tool?
I'm curious that what are outside EvaluateFunctions? Is it an end-to-end run, or there are other things?
We benchmarked the model with iree-benchmark-module tool, and the numbers were come from the report. Do we want to exclude something from the measurement?
This was iree-run-mlir - because I'm lazy and when switching branches/etc it's much easier to not have to recompile models/etc and just have one command to run - but otherwise it's the same as iree-translate + iree-run-module :)
The numbers I quoted were the ones that actually matter (total execution time), vs init/shutdown. Total end to end (on my machine) is ~440ms with threading and no significant change from prior to the rewrite (it's still decompressing the dylib and allocating a thousand buffers/etc).
iree-benchmark-module is measuring this end to end time of a single invocation, which excludes the __init and shutdown so just this highlighted region of 380ms:
Which is basically buffer allocation, command buffer recording, actual command buffer execution time, and cleanup. The only thing the hal rewrite (which included multithreading) changes is that it reduces the overhead of per-command recording and makes the command buffer execution time much lower due to threading - the same number of buffers are allocated, same number number of commands are recorded, etc.
So if you see a time increase on Android (at main, after the linking fix went in) it's likely just something tunable (like, we are only using one thread because the thread selection logic is TODO, or we are using 32 threads on a 4 core machine and oversubscribing, etc etc). Traces are the best way to see what's happening.
(my goal, once I can flush this tflite stuff from my queue, is to take the buffer allocation/free time to 0, and then future changes will cache the command buffer recording such that each invocation is pure command buffer execution time - until then, treat everything besides the actual command buffer execution as a fixed cost that will go to ~zero!)
So if you see a time increase on Android (at main, after the linking fix went in) it's likely just something tunable (like, we are only using one thread because the thread selection logic is TODO, or we are using 32 threads on a 4 core machine and oversubscribing, etc etc). Traces are the best way to see what's happening.
Yep! It's untuned in many ways (like, a lot of ways), but if there are things that get dispatched with multiple workgroups they should parallelize. I'm waiting to do a big tuning push until we have more workloads to test with that are properly distributed - and I think tuning distribution is a good next step after the initial linalg-on-tensors port is in. We can do another little mini burndown :)
Thanks @hanhanW for tracking this. As @benvanik mentioned the best way to capture two traces and 1:1 compare them. We can also start by looking at traces executing single op (e.g matmul) and see if there is a significant increase at vm_iree_invoke and slice it
Yep! It's untuned in many ways (like, a lot of ways), but if there are things that get dispatched with multiple workgroups they should parallelize. I'm waiting to do a big tuning push until we have more workloads to test with that are properly distributed - and I think tuning distribution is a good next step after the initial linalg-on-tensors port is in. We can do another little mini burndown :)
I think that might be the regression then =). On ARM with little cores, different cache behaviors..eg its easy to go down 2.7x doing by parallelization without tuning.
To have a fair comparison we need to still execute the benchmarks on single thread (Core - 7).
Yep yep - #4654 is tracking doing better thread count/affinity selection (right now it's literally 🤷 :) which should help this.
Having both benchmarks would be useful - as we start to tune workgroup distribution we need to be able to see what the timings are. Single threaded is useful for benchmarking the insides of single kernel invocations in isolation and multi-threaded is useful for benchmarking the interaction between invocations of kernels.
Activity
benvanik commentedon Feb 2, 2021
This is the expected regression from disabling executable linking that was fixed in 1321588. I'll get a trace from my desktop to confirm the current main is fine - if you have traces from the android devices then you can check them.
ScottTodd commentedon Feb 2, 2021
If I'm reading Mako's (sparse and confusing) UI correctly, this is the benchmark run at the commit that re-enabled linking: https://mako.dev/run?run_key=4838305951645696&~cpu=1&~vmla=1&~vlk=1 (see
Hover Text: | 1321588580053ba26d75a3dc495572508cda0bc3). That still shows a performance regression.benvanik commentedon Feb 2, 2021
Ugh yeah I freaking hate that UI. VMLA and SPIR-V didn't regress, only dylib - which still makes me suspect linking-related. Still trying to confirm.
benvanik commentedon Feb 2, 2021
Nope, trace looks great to me - I'm not sure I trust that graph.
Single executable:

And the time is now only 263ms for execution thanks to threading:

benvanik commentedon Feb 2, 2021
And the same timing I was getting before with --dylib_worker_count=1 (single threaded):

benvanik commentedon Feb 2, 2021
Would need a new trace captured at main from an Android device to say anything more concrete, but I suspect benchmarking issues/age.
hanhanW commentedon Feb 2, 2021
The pictures look really awesome! I will try to get them from an Android device. (I haven't tried tracy on Android yet) Which tool did you use to run the model? Was it
iree-run-moduleoriree-benchmark-moduleor other tool?I'm curious that what are outside
EvaluateFunctions? Is it an end-to-end run, or there are other things?We benchmarked the model with
iree-benchmark-moduletool, and the numbers were come from the report. Do we want to exclude something from the measurement?https://github.com/google/iree/blob/3679141eb4e0cc0db4cc21239ef23df293126b6f/iree/tools/iree-benchmark-module-main.cc#L60-L79
benvanik commentedon Feb 2, 2021
This was iree-run-mlir - because I'm lazy and when switching branches/etc it's much easier to not have to recompile models/etc and just have one command to run - but otherwise it's the same as iree-translate + iree-run-module :)
The numbers I quoted were the ones that actually matter (total execution time), vs init/shutdown. Total end to end (on my machine) is ~440ms with threading and no significant change from prior to the rewrite (it's still decompressing the dylib and allocating a thousand buffers/etc).

iree-benchmark-module is measuring this end to end time of a single invocation, which excludes the __init and shutdown so just this highlighted region of 380ms:

Which is basically buffer allocation, command buffer recording, actual command buffer execution time, and cleanup. The only thing the hal rewrite (which included multithreading) changes is that it reduces the overhead of per-command recording and makes the command buffer execution time much lower due to threading - the same number of buffers are allocated, same number number of commands are recorded, etc.
So if you see a time increase on Android (at main, after the linking fix went in) it's likely just something tunable (like, we are only using one thread because the thread selection logic is TODO, or we are using 32 threads on a 4 core machine and oversubscribing, etc etc). Traces are the best way to see what's happening.
benvanik commentedon Feb 2, 2021
(my goal, once I can flush this tflite stuff from my queue, is to take the buffer allocation/free time to 0, and then future changes will cache the command buffer recording such that each invocation is pure command buffer execution time - until then, treat everything besides the actual command buffer execution as a fixed cost that will go to ~zero!)
asaadaldien commentedon Feb 3, 2021
Is the multithreaded HAL on by default now ?
benvanik commentedon Feb 3, 2021
Yep! It's untuned in many ways (like, a lot of ways), but if there are things that get dispatched with multiple workgroups they should parallelize. I'm waiting to do a big tuning push until we have more workloads to test with that are properly distributed - and I think tuning distribution is a good next step after the initial linalg-on-tensors port is in. We can do another little mini burndown :)
asaadaldien commentedon Feb 3, 2021
Thanks @hanhanW for tracking this. As @benvanik mentioned the best way to capture two traces and 1:1 compare them. We can also start by looking at traces executing single op (e.g matmul) and see if there is a significant increase at
vm_iree_invokeand slice itasaadaldien commentedon Feb 3, 2021
I think that might be the regression then =). On ARM with little cores, different cache behaviors..eg its easy to go down 2.7x doing by parallelization without tuning.
To have a fair comparison we need to still execute the benchmarks on single thread (Core - 7).
benvanik commentedon Feb 3, 2021
flags are here: https://github.com/google/iree/blob/6ef847398348eb967063f019de73fb6d0e40f9eb/iree/hal/dylib/registration/driver_module.cc#L30-L33
have at it :)
benvanik commentedon Feb 3, 2021
(also, there's zero ambiguity with a trace - in general for things like this we should trace first and then analyze)
hanhanW commentedon Feb 5, 2021
I got some trace here. I complied the module and run
With
taskset 80Multi-thread (2.53 sec)
Single-thread (880 ms)
Without
taskset 80Multi-thread (2.48 sec)
Single-thread (1.12 sec)
hanhanW commentedon Feb 5, 2021
It looks like we don't have regression, the old config is still 880 ms (which is single thread with +
taskset 80).hanhanW commentedon Feb 5, 2021
@asaadaldien @benvanik Do you want me to make it benchmark on single thread +
taskset 80? It is run on multi thread by default after merging 8d74bfa.benvanik commentedon Feb 5, 2021
Yep yep - #4654 is tracking doing better thread count/affinity selection (right now it's literally 🤷 :) which should help this.
Having both benchmarks would be useful - as we start to tune workgroup distribution we need to be able to see what the timings are. Single threaded is useful for benchmarking the insides of single kernel invocations in isolation and multi-threaded is useful for benchmarking the interaction between invocations of kernels.
Force CPU benchmark to run on single thread.
Force CPU benchmark to run on single thread.
Force CPU benchmark to run on single thread. (#4751)
Force CPU benchmark to run on single thread. (iree-org#4751)