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

[Decomposition] Trunc #109319

Closed
wants to merge 1 commit into from
Closed

Conversation

salilsdesai
Copy link
Contributor

@salilsdesai salilsdesai commented Sep 14, 2023

Summary:
Add Decomp for Trunc and add it to core_aten_decompositions

Differential Revision: D49042033

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @ngimel @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 14, 2023

🔗 Helpful Links

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

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

✅ You can merge normally! (7 Unrelated Failures)

As of commit 5f743af with merge base 70ca3ee (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

@github-actions
Copy link

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 16, 2023
Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 16, 2023
Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 17, 2023
Summary:
bypass-github-export-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 17, 2023
Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 18, 2023
Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 18, 2023
Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Reviewed By: SS-JIA, kirklandsign

Differential Revision: D49042033
salilsdesai added a commit to salilsdesai/pytorch that referenced this pull request Sep 18, 2023
Summary:
bypass-github-pytorch-ci-checks


 Add Decomp for Trunc and add it to core_aten_decompositions

Test Plan: Phabricator + OSS Tests

Reviewed By: SS-JIA, kirklandsign

Differential Revision: D49042033
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49042033

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 19, 2023
@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

@@ -4020,6 +4020,11 @@ def scaled_dot_product_flash_attention(
)


@register_decomposition([aten.trunc])
def trunc(self: Tensor, **kwargs) -> Tensor:
return torch.where(self > 0, torch.floor(self), torch.ceil(self))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we decomposing what is likely a hardware intrinsic operation into multiple operations? It seems to me that just because you can doesn't mean you should.

Copy link
Contributor

Choose a reason for hiding this comment

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

@peterbell10 makes sense. We will remove this decomp and promote this operator to core, and provide similar treatment to other operators that map cleanly to hardware intrinsics.

Copy link
Contributor

Choose a reason for hiding this comment

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

@peterbell10 to be sure I understand. If we were to do this decomp here it results in 1) perf loss and 2) potential numerics mismatch. Perf loss should be recoverable by pattern matching + fusion. 2 is a tough one and for that I agree with you that we should probably make this core aten op. But would you agree with me on 1?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should also be asking how many consumers do you expect would want to "re-compose" this operator. I suspect since this is a hardware intrinsic, most backends would want it to be specialized but now they have to pattern match it back into trunc first. So in the most common case I expect this to create more work, not save work.

On the other hand if you could show that most backends had a hard time implementing trunc and this would save a lot of maintenance then I could see the performance trade-off being worth it.

SS-JIA added a commit that referenced this pull request Sep 22, 2023
Following up from [this comment](#109319 (comment)). Remove the decomposition for `trunc`, and add it as a core operator.

Going forward, provide similar treatment for operators that map cleanly to hardware instructions.


[ghstack-poisoned]
SS-JIA added a commit that referenced this pull request Sep 22, 2023
Following up from [this comment](#109319 (comment)). Remove the decomposition for `trunc`, and add it as a core operator.

Going forward, provide similar treatment for operators that map cleanly to hardware instructions.


[ghstack-poisoned]
SS-JIA added a commit that referenced this pull request Sep 23, 2023
…c to core"


Following up from [this comment](#109319 (comment)). Remove the decomposition for `trunc`, and add it as a core operator.

Going forward, provide similar treatment for operators that map cleanly to hardware instructions.


cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
SS-JIA added a commit that referenced this pull request Sep 23, 2023
Following up from [this comment](#109319 (comment)). Remove the decomposition for `trunc`, and add it as a core operator.

Going forward, provide similar treatment for operators that map cleanly to hardware instructions.


cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Sep 25, 2023
Following up from [this comment](#109319 (comment)). Remove the decomposition for `trunc`, and add it as a core operator.

Going forward, provide similar treatment for operators that map cleanly to hardware instructions.

Pull Request resolved: #109902
Approved by: https://github.com/peterbell10
ringohoffman pushed a commit to ringohoffman/pytorch that referenced this pull request Sep 27, 2023
Following up from [this comment](pytorch#109319 (comment)). Remove the decomposition for `trunc`, and add it as a core operator.

Going forward, provide similar treatment for operators that map cleanly to hardware instructions.

Pull Request resolved: pytorch#109902
Approved by: https://github.com/peterbell10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants