Repository navigation
Fused RMSNorm implementation - #153666
Fused RMSNorm implementation#153666AaronWang04 wants to merge 48 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/153666
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (1 Unrelated Failure)As of commit f053b16 with merge base b4358c5 ( UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
Attention! native_functions.yaml was changedIf you are adding a new function or defaulted argument to native_functions.yaml, you cannot use it from pre-existing Python frontend code until our FC window passes (two weeks). Split your PR into two PRs, one which adds the new C++ functionality, and one that makes use of it from Python, and land them two weeks apart. See https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy#forwards-compatibility-fc for more info. Caused by: |
|
To add the ciflow label This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
To add the ciflow label This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
To add the ciflow label This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
To add the ciflow label This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot revert -c ghfirst -m "Sorry but this is breaking tests internally. @albanD can you please help land this change?You can follow the instructions here: https://fburl.com/fixing-ghfirst-reverts. See D78599667 for more info" |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@AaronWang04 your PR has been successfully reverted. |
Attention! PyTorch one of the C-stable API file was changedYou MUST NOT change existing function declarations in this, as this header defines a stable C ABI. If you need to change the signature for a function, introduce a new v2 version of the function and modify code generation to target the new version of the function. Caused by: |
|
The error seems to be: |
|
Hey @AaronWang04 |
|
@tianyu-l is there no test for DTensor in core CI? If not, how could we know that we're breaking it? |
|
IT probably doesn't have sufficient coverage |
I pushed a fix for this, it seems like a weird edge case where input.dtype != weight.dtype. I don't think layernorm supports this too hence the regression. |
yep it wasn't tested, I added a test for it |
albanD
left a comment
There was a problem hiding this comment.
Thanks for the update!
Everything looks green here!
|
@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 |
The reason is that before this PR, In the future, when we identify something is running with DTensor via decomposition, we should always add a test. |
tianyu-l
left a comment
There was a problem hiding this comment.
@AaronWang04
just to double check -- have you verified that TP in torchtitan works with this PR?
I built torchtitan from about 3 weeks ago (recent versions have some sort of import error?) and built pytorch with this PR and reproed the CI workflow that failed before and it completed with no error |
| if (weight_opt.has_value() && weight_opt.value().defined() && weight_opt.value().dtype() != input.dtype()) { | ||
| TORCH_WARN_ONCE( | ||
| "Mismatch dtype between input and module: input dtype = ", input.dtype(), | ||
| ", module dtype = ", weight_opt.value().dtype() |
There was a problem hiding this comment.
why is it module dtype and not weight dtype?
There was a problem hiding this comment.
when you define the nn.RMSNorm module you aren't passing in a weight tensor, it initializes a weight tensor with the dtype you pass into the module when elementwise_affine is true
should I write a longer warning message to clarify this?
There was a problem hiding this comment.
Just say weight dtype is wrong, this function doesn't have to be called through module, weight dtype is clear enough
Relevant #72643
cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta @ezyang @gchanan @ptrblck @msaroufim @eqy @jerryzh168 @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben
Benchmarked versus unfused torch implementation and torch.compile implementation. Around 9x speedup vs unfused implementation on cuda and slightly faster vs inductor compile on 5090.
Here are the triton compile tests ran on a 5090 (comparing this branch vs main)
main
current branch