New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cuda] vectorized gamma and beta loading in vectorized_layer_norm #107287
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/107287
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 19d91ad with merge base 8298720 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
cc: @malfet |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-focal-rocm5.6-py3.8 / test (default, 3, 3, linux.rocm.gpu) Details for Dev Infra teamRaised by workflow job |
Also found this blog post on optimizing LayerNorm perf: https://oneflow2020.medium.com/how-to-implement-an-efficient-layernorm-cuda-kernel-oneflow-performance-optimization-731e91a285b8 (from the end of 2021) Not sure if the results still stand, but it showed that FusedLayerNorm from apex was still faster that PyTorch, and that their impl is even faster than apex (so this oneflow was 2x faster than pytorch). If this is the case, worth borrowing their impl? And yep, they are also using vectorized loads for CUDA. Their code is licensed Apache2 and is available at https://github.com/Oneflow-Inc/oneflow/blob/2d24fe08be1b1bedcc22fb409c5d688924ce89fc/oneflow/user/kernels/layer_norm_gpu_kernel.cu Related: |
Thanks for the pointer. I'll take a look to see if it's applicable and follow-up. |
@pytorchbot rebase -b main |
@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here |
Successfully rebased |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 2 jobs have failed, first few of them are: trunk / linux-focal-rocm5.6-py3.8 / test (default, 2, 3, linux.rocm.gpu), trunk / linux-focal-rocm5.6-py3.8 / test (default, 3, 3, linux.rocm.gpu) Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Improves the performance of
vectorized_layer_norm
by vectorizing access togamma
andbeta
buffers. This uses 128 bit load instructions which improves memory bandwidth. The speedup is ~3% on average and there are no obvious regressions on any problem sizes.Used the following code to test: