-
Notifications
You must be signed in to change notification settings - Fork 56
[Spyre-Next] [Feature] rms_norm rework with vLLM IR #877
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
Closed
Closed
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8b1962a
WIP: vLLM IR integration for rms_norm
bohnstingl 91d803b
WIP: before rework
bohnstingl 963c64f
WIP: before rework
bohnstingl 2be7e5c
Cleanup
bohnstingl 529ca83
Cleanup of rms_norm
bohnstingl fc9bc0d
Integrated rework from #872
bohnstingl 96dfaaf
Enabled direct dispatch for rms_norm
bohnstingl 2de9b77
Reverted rms_norm test file
bohnstingl 172e63a
Merge branch 'main' of github.com:vllm-project/vllm-spyre into vllm_I…
bohnstingl 555cd5d
Some reformatting
bohnstingl f27eb7b
Minor cleanup
bohnstingl 60cb9a3
Reintroduced opaque wrapping layer
bohnstingl 10a2a07
Reverting silu_and_mul; formatting
bohnstingl 056dd2b
Merge branch 'main' of github.com:vllm-project/vllm-spyre into vllm_I…
bohnstingl aa33fbf
Rework of rms_norm provider
bohnstingl eb9efeb
Merge branch 'main' of github.com:vllm-project/vllm-spyre into vllm_I…
bohnstingl 2405ea4
Removed padding
bohnstingl ec7d388
Merge branch 'main' of github.com:vllm-project/vllm-spyre into vllm_I…
bohnstingl d25c5f3
Moved dtype conversion into _supports_spyre
bohnstingl 3d26458
Removed unnecessary settings
bohnstingl 1fcfcd1
Merge branch 'main' of github.com:vllm-project/vllm-spyre into vllm_I…
bohnstingl f39edb6
Merge branch 'vllm_IR_integration' of github.com:bohnstingl/vllm-spyr…
bohnstingl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
3 changes: 3 additions & 0 deletions
3
vllm_spyre_next/vllm_spyre_next/custom_ops/kernels/__init__.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| """Spyre IR provider registrations.""" | ||
|
|
||
| from . import rms_norm as _rms_norm # noqa: F401 |
33 changes: 33 additions & 0 deletions
33
vllm_spyre_next/vllm_spyre_next/custom_ops/kernels/rms_norm.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| """Spyre IR provider for rms_norm.""" | ||
|
|
||
| import torch | ||
|
|
||
| from vllm import ir | ||
|
|
||
| _supports_spyre = lambda x, weight, epsilon, variance_size=None: (x.device.type == "spyre") | ||
| """Spyre provider handles tensors already on Spyre device""" | ||
|
|
||
|
|
||
| # Register with vLLM IR system | ||
| @ir.ops.rms_norm.register_impl("spyre", supports_args=_supports_spyre, supported=True) | ||
| def spyre_rms_norm( | ||
| x: torch.Tensor, | ||
| weight: torch.Tensor | None, | ||
| epsilon: float, | ||
| variance_size: int | None = None, | ||
| ) -> torch.Tensor: | ||
| """Spyre IR provider for rms_norm. | ||
|
|
||
| Spyre-specific implementation details: | ||
| - Epsilon as tensor: scalar broadcast limited, expand via torch.full() | ||
| - No dtype promotion: torch-spyre limitation, stays in input dtype | ||
| - variance_size: parameter currently not used | ||
| """ | ||
| eps_tensor = torch.full(x.shape, epsilon, dtype=x.dtype, device=x.device) | ||
|
|
||
| variance = x.pow(2).mean(dim=-1, keepdim=True) | ||
| x = x * torch.rsqrt(variance + eps_tensor) | ||
|
|
||
| if weight is not None: | ||
| x = x * weight | ||
| return x | ||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand and agree with these constraints and I think we should proceed with this PR as is.
However, if we want to reduce the custom code for spyre even further, couldn't we reuse the upstream RMS norm if we automate the first two steps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider this once we fully utilize torch.compile for our provider, see my comment below. In a sense, currently our provider function is not traced, and thus no graph is created and thus we can't do any of the custom passes.