Skip to content

Reworking stream.async.dispatch to allow for in-place allocation/concurrency scheduling. - #11173

Merged
benvanik merged 6 commits into
mainfrom
benvanik-emplace-allocations
Nov 17, 2022
Merged

benvanik merged 6 commits into
mainfrom
benvanik-emplace-allocations

Conversation

@benvanik

@benvanik benvanik commented Nov 15, 2022 •

Copy link
Copy Markdown
Collaborator

This adds subranges to stream.async.dispatch so that we can express the active regions of accesses without needing separate ops like stream.async.slice and stream.async.update. Though not currently done this will let us perform much more aggressive folding of ranges and not need to worry about breaking scheduling by hiding the ranges inside of dispatch regions. For now there's a simple iree-stream-emplace-allocations pass that runs after copy-on-write materialization to fold just update ranges in. Concurrency scheduling has been updated to use an extremely simple hazard analysis that is aware of the subrange accesses - future changes can extend that to support more involved non-local analysis.

I'm not happy with the asm syntax but given that it's an internal layer and does not proliferate outside of the stream dialect lit tests I'm ok with this state.

On models with concats from the frontend peak memory consumption will drop by the sum of the concatenated values; for example mobilebertsquad drops 12386304B (~12.4MB) -> 9437184B (~9.4MB). More importantly we'll now avoid the serialized copies that originated from the subrange updates and drop the total number of commands issued at runtime by O(concated values) - for example 197 in mobilebertsquad. This removes the pipeline bubbles when measuring end-to-end latency - relatively small bits but it all adds up: mobilebertsquad on my nvidia GPU goes from 32ms -> 28ms, with nearly all time now in dispatches. MobileSSD transient usage doesn't change size because the peak usage is dominated by padding fills/copies, but it does lose 15 serialized copies.

Example bubbles before change with serialized copies:
image
After change with no copies, no bubble (just normal dispatch overhead):
image
Corresponding IR:
image

Progress on #6972 (now have the ranges tracked per op but nothing eliding updates yet).
Fixes #7729.

@benvanik benvanik added compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) performance ⚡ Performance/optimization related work across the compiler and runtime labels Nov 15, 2022
@benvanik
benvanik force-pushed the benvanik-emplace-allocations branch 5 times, most recently from 0ac0328 to fd7e3ac Compare November 16, 2022 06:10
@benvanik
benvanik force-pushed the benvanik-emplace-allocations branch from fd7e3ac to 90dc549 Compare November 16, 2022 20:17
@iree-github-actions-bot

iree-github-actions-bot commented Nov 16, 2022 •

Copy link
Copy Markdown
Contributor

Abbreviated Benchmark Summary

@ commit 5703ac8c05fe0984973ae6bd00c2b1c6ffdc41ac (vs. base 7b2e4ef995305b56776cfc2b8c7a1dec7f2ff176)

Regressed Latencies 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
DeepLabV3 [fp32] (TFLite) 4-thread,little-core,full-inference,default-flags with IREE-LLVM-CPU @ Pixel-6-Pro (CPU-ARMv8.2-A) 140.775 (vs. 127.197, 10.68%↑) 141.087 2.007
PoseNet [fp32] (TFLite) 4-thread,big-core,full-inference,default-flags with IREE-LLVM-CPU @ Pixel-4 (CPU-ARMv8.2-A) 80.030 (vs. 73.851, 8.37%↑) 80.089 1.109

Improved Latencies 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileBertSquad [fp16] (TFLite) full-inference,experimental-flags with IREE-Vulkan @ Pixel-6-Pro (GPU-Mali-G78) 140.524 (vs. 152.724, 7.99%↓) 140.702 0.367
MobileBertSquad [fp32] (TFLite) full-inference,default-flags with IREE-Vulkan @ Pixel-6-Pro (GPU-Mali-G78) 114.010 (vs. 123.615, 7.77%↓) 113.887 0.664
MobileBertSquad [fp32] (TFLite) 1-thread,little-core,full-inference,default-flags with IREE-LLVM-CPU @ Pixel-6-Pro (CPU-ARMv8.2-A) 3490.326 (vs. 3782.966, 7.74%↓) 3473.916 50.332

[Top 3 out of 8 results showed]

No improved or regressed compilation metrics 🏖️

For more information:

@benvanik
benvanik requested a review from ScottTodd November 16, 2022 21:55
@benvanik

Copy link
Copy Markdown
Collaborator Author

Need to write some tests for the emplace path but otherwise this should be ready for review!

@benvanik
benvanik marked this pull request as ready for review November 16, 2022 21:56
@benvanik
benvanik force-pushed the benvanik-emplace-allocations branch from 90dc549 to ae6b570 Compare November 17, 2022 04:17
@benvanik
benvanik force-pushed the benvanik-emplace-allocations branch from ae6b570 to 5703ac8 Compare November 17, 2022 18:46
@benvanik
benvanik merged commit 952aeca into main Nov 17, 2022
@benvanik
benvanik deleted the benvanik-emplace-allocations branch November 17, 2022 21:00
@antiagainst

Copy link
Copy Markdown
Member

Yay, thanks Ben! Great to see the ~10% latency drop for mobilebert! :D https://perf.iree.dev/serie?IREE?MobileBertSquad%20%5Bfp32%5D%20(TFLite)%20full-inference%2Cdefault-flags%20with%20IREE-Vulkan%20%40%20Pixel-6-Pro%20(GPU-Mali-G78)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) performance ⚡ Performance/optimization related work across the compiler and runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize split+work+concat patterns in the streams dialect.

4 participants