Skip to content
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

Add custom kernel for RMS normalization #16

Merged
merged 4 commits into from
Mar 31, 2023
Merged

Add custom kernel for RMS normalization #16

merged 4 commits into from
Mar 31, 2023

Conversation

WoosukKwon
Copy link
Collaborator

This PR adds a custom CUDA kernel for RMS normalization, which is used in LLaMA models. The kernel removes the inefficient data movement in the current PyTorch implementation.

Performance (fp16):

* num_tokens=7, hidden_size=1024
Kernel: 9 us
PyTorch: 93 us

* num_tokens=128, hidden_size=1024
Kernel: 5 us
PyTorch: 84 us

* num_tokens=2048, hidden_size=5120
Kernel: 60 us
PyTorch: 353 us

Tested models:

  • LLaMA-7B
  • LLaMA-13B

Tested GPUs:

  • A100

@WoosukKwon WoosukKwon requested a review from zhuohan123 March 31, 2023 01:25
Copy link
Member

@zhuohan123 zhuohan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhuohan123 zhuohan123 merged commit 09e9245 into main Mar 31, 2023
@WoosukKwon WoosukKwon deleted the rms-norm branch March 31, 2023 16:51
hongxiayang pushed a commit to hongxiayang/vllm that referenced this pull request Feb 13, 2024
AdrianAbeyta added a commit to AdrianAbeyta/vllm that referenced this pull request Mar 8, 2024
Generalizing KV scales JSON to updated schema
luo-cheng2021 pushed a commit to luo-cheng2021/vllm that referenced this pull request Apr 1, 2024
z103cb added a commit to dtrifiro/vllm that referenced this pull request May 8, 2024
fxmarty pushed a commit to fxmarty/vllm-public that referenced this pull request May 31, 2024
yukavio pushed a commit to yukavio/vllm that referenced this pull request Jul 3, 2024
SUMMARY:
- Fix bug whereby 2:4 is not being invoked
- Eschew SparseTensor based implementation

TESTING:
- examples/offline_inference_semi_structured_sparse.py

---------

Co-authored-by: Lucas Wilkinson <[email protected]>
yukavio pushed a commit to yukavio/vllm that referenced this pull request Jul 3, 2024
SUMMARY:
- Fix bug whereby 2:4 is not being invoked
- Eschew SparseTensor based implementation

TESTING:
- examples/offline_inference_semi_structured_sparse.py

---------

Co-authored-by: Lucas Wilkinson <[email protected]>
@alixiaodi alixiaodi mentioned this pull request Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants