Skip to content

[Inductor] support mixed dtype in the native_layer_norm_backward meta function#159830

Closed
markc-614 wants to merge 3 commits intopytorch:mainfrom
markc-614:mashaobin/inductor/fix-ln-decompostion
Closed

[Inductor] support mixed dtype in the native_layer_norm_backward meta function#159830
markc-614 wants to merge 3 commits intopytorch:mainfrom
markc-614:mashaobin/inductor/fix-ln-decompostion

Conversation

@markc-614
Copy link
Contributor

Fixes #159829

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159830

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 1 Pending

As of commit b257578 with merge base df4ebdd (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 5, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@markc-614 markc-614 force-pushed the mashaobin/inductor/fix-ln-decompostion branch 2 times, most recently from b10aba6 to 8da3c4f Compare August 5, 2025 01:41
@markc-614 markc-614 force-pushed the mashaobin/inductor/fix-ln-decompostion branch from 8da3c4f to 51fa8ee Compare August 5, 2025 01:53
@markc-614
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Aug 5, 2025
@markc-614 markc-614 changed the title fix(inductor): support native_layer_norm_backward mixed dtype for privateuse1 [INDUCTOR] support native_layer_norm_backward mixed dtype for privateuse1 Aug 5, 2025
@markc-614 markc-614 changed the title [INDUCTOR] support native_layer_norm_backward mixed dtype for privateuse1 [Inductor] support native_layer_norm_backward mixed dtype for privateuse1 Aug 5, 2025
@markc-614
Copy link
Contributor Author

@masnesral please help to review this, thank you

@jerryzh168 jerryzh168 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 13, 2025
@markc-614 markc-614 marked this pull request as draft August 13, 2025 09:41
@markc-614 markc-614 marked this pull request as ready for review August 13, 2025 09:44
@markc-614
Copy link
Contributor Author

@eellison @ysiraichi please help to review this, thank you

@eellison eellison requested a review from albanD August 25, 2025 12:32
_maybe_cast(d_input, input.dtype),
_maybe_cast(d_weight, input.dtype),
_maybe_cast(d_bias, input.dtype),
_maybe_cast(d_weight, weight.dtype if weight is not None else None),
Copy link
Contributor

Choose a reason for hiding this comment

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

@albanD is this right ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes it is correct.
It's because the weight and bias are optional. But when they're not there, both these gradients will be None anyways so no cast is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@albanD thanks for your reply. @eellison please help to review this. thanks.

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM

_maybe_cast(d_input, input.dtype),
_maybe_cast(d_weight, input.dtype),
_maybe_cast(d_bias, input.dtype),
_maybe_cast(d_weight, weight.dtype if weight is not None else None),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes it is correct.
It's because the weight and bias are optional. But when they're not there, both these gradients will be None anyways so no cast is needed.

@albanD
Copy link
Collaborator

albanD commented Sep 16, 2025

@markc-614 can you rebase on top of the latest main branch so we get CI signal please?

@albanD
Copy link
Collaborator

albanD commented Sep 16, 2025

Also @markc-614 I think it would be great to test the privateuse1 integration in compile a bit more in core to make it more stable.
We have a few items in #158917 related to the compiler and I think it would be a great addition to the OpenReg in-core testing!
FYI @fffrog

@markc-614 markc-614 force-pushed the mashaobin/inductor/fix-ln-decompostion branch from 6fe8bc7 to 72d0714 Compare September 17, 2025 01:30
@markc-614
Copy link
Contributor Author

@markc-614 can you rebase on top of the latest main branch so we get CI signal please?

@albanD done

@markc-614
Copy link
Contributor Author

Also @markc-614 I think it would be great to test the privateuse1 integration in compile a bit more in core to make it more stable. We have a few items in #158917 related to the compiler and I think it would be a great addition to the OpenReg in-core testing! FYI @fffrog

@albanD do we need to add test cases to torch_openreg?

@fffrog
Copy link
Collaborator

fffrog commented Sep 17, 2025

We have a few items in #158917 related to the compiler and I think it would be a great addition to the OpenReg in-core testing!
FYI @fffrog

Thank you for your reminder, I will add this to the OpenReg to-do list.

@fffrog
Copy link
Collaborator

fffrog commented Sep 17, 2025

@albanD do we need to add test cases to torch_openreg?

@markc-614 These changes aren't specific to PrivateUse1, they apply to the general logic for all accelerators in PyTorch, right? Also, torch_openreg currently doesn't support torch.compiler, so you can merge this PR into the main branch first. I'll keep track of this issue and add it to the torch_openreg to-do list.

Any other suggestions @albanD :D

@markc-614
Copy link
Contributor Author

@fffrog Yes, exactly.

@fffrog
Copy link
Collaborator

fffrog commented Sep 17, 2025

@fffrog Yes, exactly.

Thank you, it would be even better if you could modify the title of this PR and remove the "for privateuse1" suffix.

@markc-614 markc-614 changed the title [Inductor] support native_layer_norm_backward mixed dtype for privateuse1 [Inductor] support native_layer_norm_backward mixed dtype Sep 17, 2025
@markc-614 markc-614 changed the title [Inductor] support native_layer_norm_backward mixed dtype [Inductor] support mixed dtype in the native_layer_norm_backward meta function Sep 17, 2025
@markc-614
Copy link
Contributor Author

@fffrog Yes, exactly.

Thank you, it would be even better if you could modify the title of this PR and remove the "for privateuse1" suffix.

@fffrog Done. I have updated the PR title.

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Sounds good thanks!

@albanD
Copy link
Collaborator

albanD commented Sep 17, 2025

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 17, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

native_layer_norm_backward supports mixed precision for PrivateUse1

7 participants