KEMBAR78
Simplify expr before getting implications in _maybe_evaluate_static by bobrenjc93 · Pull Request #135499 · pytorch/pytorch · GitHub
Skip to content

Conversation

@bobrenjc93
Copy link
Contributor

@bobrenjc93 bobrenjc93 commented Sep 9, 2024

Stack from ghstack (oldest at bottom):

Fixes #134268

Previously we weren't simplifying these expressions before calling get_implications, resulting in inconsistent application of FloorDiv/CleanDiv. See #134268 for more details.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames @rec

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 9, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 65b574e with merge base 356f14e (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

Fixes #134268 

Previously we weren't simplifying these expressions before turning them into runtime asserts, resulting in inconsistent application of FloorDiv/CleanDiv. See #134268  for more details.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
@bobrenjc93 bobrenjc93 changed the title Simplify expr before converting to runtime assert Simplify expr before getting implications in _maybe_evaluate_static Sep 9, 2024
…te_static"


Fixes #134268 

Previously we weren't simplifying these expressions before calling get_implications, resulting in inconsistent application of FloorDiv/CleanDiv. See #134268  for more details.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
…te_static"


Fixes #134268 

Previously we weren't simplifying these expressions before calling get_implications, resulting in inconsistent application of FloorDiv/CleanDiv. See #134268  for more details.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 9, 2024
ghstack-source-id: 3f5965d
Pull Request resolved: #135499
@bobrenjc93 bobrenjc93 marked this pull request as ready for review September 9, 2024 22:29
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Nice, thank you.

@ezyang
Copy link
Contributor

ezyang commented Sep 10, 2024

One downside to this approach is that I have a performance optimization pass that avoids having to continuously rebuild implications by maintaining a dict of axioms that is added to as we discover new guards. Here, I can't conveniently simplify the expr before getting implications, because I'm no longer continuously rebuilding the dict.

@bobrenjc93
Copy link
Contributor Author

@ezyang Do you have a link to that PR? The trickiness stems from the dependence on self.divisible within simplify. My intuition tells me the optimal answer may involve a dependency graph. Naively perhaps every time we update self.divisible, we would update the dict of axioms? Or perhaps there is some smarter finer grain fanout calculation that can be done.

I'm open to a trying different approach if you have one in mind. I'll defer to you w.r.t. the importance of correctness vs performance, but intuitively it seems we should ensure the former over the latter. Or in other words it might make sense to land this as is and in the optimization diff we can rework the implementation and keep the test?

Let me know how you'd like to proceed!

@ezyang
Copy link
Contributor

ezyang commented Sep 11, 2024

This #135429

I don't mind landing this first. I don't have a clear picture what I would prefer for reconciling these two. Your proposal of manually adding new axioms when divisibility updates is probably the easiest thing to do.

cc @isuruf here if you have any other ideas.

@bobrenjc93
Copy link
Contributor Author

@pytorchbot merge

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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-py3-arm64 / build

Details for Dev Infra team Raised by workflow job

…te_static"


Fixes #134268 

Previously we weren't simplifying these expressions before calling get_implications, resulting in inconsistent application of FloorDiv/CleanDiv. See #134268  for more details.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 11, 2024
ghstack-source-id: 40a85dd
Pull Request resolved: #135499
@bobrenjc93
Copy link
Contributor Author

@pytorchbot merge

@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

@ezyang
Copy link
Contributor

ezyang commented Sep 12, 2024

This durably regresses instruction count on update_hint_regression by 2.2% (https://fburl.com/unidash/v36uhdz4), which is not surprising as we're doing more simplification than we did before. Since this is a correctness fix I think we'll eat it but it's something to keep an eye on. cc @isuruf

@isuruf
Copy link
Collaborator

isuruf commented Sep 12, 2024

#135863 might help

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
…ytorch#135499)

Fixes pytorch#134268

Previously we weren't simplifying these expressions before calling get_implications, resulting in inconsistent application of FloorDiv/CleanDiv. See pytorch#134268  for more details.

Pull Request resolved: pytorch#135499
Approved by: https://github.com/ezyang
@github-actions github-actions bot deleted the gh/bobrenjc93/10/head branch October 13, 2024 02:08
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 module: dynamo release notes: fx release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants