Improve NEST GPU Utilization 4/N: 250x Faster Masking on GPU#15739
Improve NEST GPU Utilization 4/N: 250x Faster Masking on GPU#15739MahmoudAshraf97 wants to merge 2 commits into
Conversation
Refactor forward methods Signed-off-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
|
Thanks for the PR. We also have some optimization on masking and quantization in https://github.com/NVIDIA-NeMo/NeMo/tree/heh/ssl-v2 and the draft PR #15589. Need to compare the two before deciding which one to merge. |
I looked at the draft PR, I noticed that it still uses the old implementation core, where it basically uses python for loops so it will have the same issues, given that it does change the masking logic, we can use my implementation as a starting point and implement the new logic on top of the vectorized implementation |
stevehuang52
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the improvement~!
|
/ok to test df56f3d |
|
The two failing tests are not related to the code, please retry again or skip if unnecessary |
|
/ok to test ac242b3 |
Important
The
Update branchbutton must only be pressed in very rare occassions.An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.
What does this PR do ?
SSL training requires feature masking which uses python for loops on gpu hot path, this causes poor utilization since the masking function execution time grows linearly with batch size
This PR vectorizes the masking functions and gains 250x speedup using
block_size=48,masking_prob=0.01, andinput_shape=[32,80,2000], 41ms down to 0.16ms, I did test higher batch sizes, but the utilization tanks for both implementations because the dataloader is the bottleneck at that stage, so I use grad accumulation for higher global batch sizes if neededWe get around 18% speedup E2E and 10-15% higher GPU utilization, I have verified that the masking distribution is the same in the overlapping path, and two training runs for 5k steps converged to the same loss
Collection: [Note which collection this PR will affect]
Changelog
Usage
# Add a code snippet demonstrating how to use thisGitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".
Before your PR is "Ready for review"
Pre checks:
PR Type:
If you haven't finished some of the above items you can still open "Draft" PR.
Who can review?
cc @stevehuang52 @pzelasko
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information