Added Vectorized MinGRU Forward + Backward and test suites#553
Open
eshau wants to merge 2 commits intoPufferAI:4.0from
Open
Added Vectorized MinGRU Forward + Backward and test suites#553eshau wants to merge 2 commits intoPufferAI:4.0from
eshau wants to merge 2 commits intoPufferAI:4.0from
Conversation
…el selector depending on BTH
Merge with Main
|
Based. Should be considered for merge. I will not elaborate further. |
|
Obviously we can do further vectorization graphing on Kv values. But that's whatever nonsense I'm adding in as a fourth variable to this. |
|
For a layer and kernel? Now take it out to to the Q layer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi!
Summary
We created vectorized versions of the MinGRU forward / backward kernels in
src/models.cuthat are slightly faster for large enough (B, T, H). Essentially instead of doing serial work overTelements in each thread, we can do work overhconsecutive columns ofTelements. This is in practice better because we reduce the number of memory instructions (throughfloat2/float4loads and stores) and do vectorizedfloat2math for some operations at the cost of increased register pressure. We have three variations of this:vec32(load 32 bits / 2 bfloat16s),vec64(load 64 bits / 4 bfloat16s), andvec128(load 128 bits / 8 bfloat16s).Results
The following tables show the speedup over forward + backwards:

We also added a kernel selector that chooses the checkpoint interval as well as optimal forwards and backwards depending on (B, T, H). These are based on the following three depth-2 decision trees (all numbers are powers of 2):



The resulting selected forward + backward MinGRU kernels have the following speedups:

Tests
We have three different additional tests in
tests/profile_kernels.cu:fusedscan_correctness: Checks correctness ofvec32,vec64, andvec128over all (B, T, H) combinations.fusedscan_sweep: Benchmarks speed over all (B, T, H), checkpoint intervals, and kernel variantsfusedscan_selector_bench: Benchmarks speed over all (B, T, H) against baseline (scalar load with checkpoint interval 4)