Open
Conversation
Tcc0403
reviewed
Jul 17, 2025
| W: (H,) | ||
| """ | ||
| Y, X, RSTD, BLOCK_SIZE, num_warps, casting_mode = rms_norm_forward(X, W, eps, offset, casting_mode, row_mode) | ||
| num_stages = calculate_num_stages() |
Collaborator
There was a problem hiding this comment.
nit: We can just return num_stages from rms_norm_forward() like num_warps to avoid calling it again.
| } | ||
|
|
||
|
|
||
| def calculate_num_stages(): |
Collaborator
There was a problem hiding this comment.
Is there a table where we can look up these properties?
| ), | ||
| ], | ||
| ) | ||
| def test_large_64k_softmax_correctness(dtype, atol, rtol): |
Collaborator
There was a problem hiding this comment.
Is there any considerations of not just adding a test case to original tests?
| (GemmaRMSNorm, 1.0, "gemma"), | ||
| ], | ||
| ) | ||
| def test_large_64k_correctness(dtype, atol, rtol, reference, offset, casting_mode): |
Comment on lines
+130
to
+131
| device = torch.cuda.current_device() | ||
| torch_device_props = torch.cuda.get_device_properties(device) |
Collaborator
There was a problem hiding this comment.
We should make it xpu compatible
https://docs.pytorch.org/docs/stable/generated/torch.xpu.get_device_properties.html#torch.xpu.get_device_properties
|
|
||
| num_warps = 4 | ||
| if BLOCK_SIZE >= 32768: | ||
| if BLOCK_SIZE >= 65536: |
Collaborator
There was a problem hiding this comment.
By the way, I'm always wondering why we don't take element_size into account. Do you have any idea?
Collaborator
|
Can you show some plots comparing the perf before/after? |
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.
Summary
Optimizing Softmax and RMSNorm runtime performance on hidden_size >= 64k
Testing Done
Added large tests for 64K dim
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence