Skip to content

add support for hint_override in mark_unbacked#162652

Closed
bobrenjc93 wants to merge 14 commits intogh/bobrenjc93/558/basefrom
gh/bobrenjc93/558/head
Closed

add support for hint_override in mark_unbacked#162652
bobrenjc93 wants to merge 14 commits intogh/bobrenjc93/558/basefrom
gh/bobrenjc93/558/head

Conversation

@bobrenjc93
Copy link
Contributor

@bobrenjc93 bobrenjc93 commented Sep 10, 2025

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 10, 2025

🔗 Helpful Links

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

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

✅ No Failures

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

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

bobrenjc93 added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: e480eba
Pull Request resolved: #162652
@pytorch-bot pytorch-bot bot added module: inductor release notes: fx release notes category labels Sep 10, 2025
@bobrenjc93 bobrenjc93 added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 10, 2025
cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: fc14aee
Pull Request resolved: #162652
@bobrenjc93 bobrenjc93 marked this pull request as ready for review September 10, 2025 22:35
@bobrenjc93 bobrenjc93 added the topic: not user facing topic category label Sep 10, 2025
Very similar to #161007 except now for mark_unbacked.

This consolidates the approach to only use the hint override for size hints in contrast to the original approach which actually allowed guarding on the hint_override.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: 07fee16
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

This consolidates the approach to only use the hint override for size hints in contrast to the original approach which actually allowed guarding on the hint_override.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: 4ef303d
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

This consolidates the approach to only use the hint override for size hints in contrast to the original approach which actually allowed guarding on the hint_override.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: 327d8f5
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

This consolidates the approach to only use the hint override for size hints in contrast to the original approach which actually allowed guarding on the hint_override.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 11, 2025
ghstack-source-id: c31786b
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

This consolidates the approach to only use the hint override for size hints in contrast to the original approach which actually allowed guarding on the hint_override.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 11, 2025
ghstack-source-id: c1ba857
Pull Request resolved: #162652
@laithsakka
Copy link
Contributor

another thing to think about is this:
in this API

V.graph.sizevars.size_hint(rnumel, fallback=config.unbacked_symint_fallback)

people used to depend on the fact that they pass fallback or else it would throw
i.e: V.graph.sizevars.size_hint_or_throw exepcted to throw for unbacked

now with your change if hint is overriden it will just be no throw always implicitly on unbacked
cc @ColinPeppler

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.

Help me understand why this prevents people from guarding/adding runtime asserts based on the hints. It seems unsafe to allow arbitrary queries to symbolic_hint to rely on this. You need to make some assertion at the use site that you promise to ONLY use this in a heuristic nature, and that your output is sound even if it varies the full range.

Very similar to #161007 except now for mark_unbacked.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 12, 2025
ghstack-source-id: 29604d5
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 12, 2025
ghstack-source-id: a3111a2
Pull Request resolved: #162652
@laithsakka
Copy link
Contributor

laithsakka commented Sep 12, 2025

Help me understand why this prevents people from guarding/adding runtime asserts based on the hints. It seems unsafe to allow arbitrary queries to symbolic_hint to rely on this. You need to make some assertion at the use site that you promise to ONLY use this in a heuristic nature, and that your output is sound even if it varies the full range.

I agree we discussed creating a new API or adding an to argument symbolic_hint that allow reading overrides with a comment that say you can only use it in a heuristic nature.

The alternative as is (is people have to understand this is playing as actual hint that can implicitly control any inductor decisions including guarding (runtime assertions in this case).

but i like the special API/Args to control when those are used better.

@ezyang
Copy link
Contributor

ezyang commented Sep 12, 2025

The problem I'd specifically like to avoid is when we could have reported an error at compile time, but instead it got baked in as a runtime assert and you have to run it to see it overspecialized.

Very similar to #161007 except now for mark_unbacked.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 12, 2025
ghstack-source-id: a02a323
Pull Request resolved: #162652
@bobrenjc93
Copy link
Contributor Author

You need to make some assertion at the use site that you promise to ONLY use this in a heuristic nature, and that your output is sound even if it varies the full range.

Apologies for the late response, I've been battling a pretty bad illness over the past few days. I agree with your concern and have updated the PR to include a flag requiring explicit opt-in to this behavior.

@bobrenjc93 bobrenjc93 requested a review from ezyang September 12, 2025 21:48
@ezyang
Copy link
Contributor

ezyang commented Sep 13, 2025

Thanks, and hope you are feeling better. My puzzlement now is, why is this flag not implied by the fallback argument at all these call sites?

@bobrenjc93
Copy link
Contributor Author

why is this flag not implied by the fallback argument at all these call sites?

My intuition is against muddying the waters since fallback is a global fallback (all unbacked symints get the same value) whereas the use_user_provided_hint_override flag opts into a unique user provided value on a per-unbacked basis.

Are you implying deriving use_user_provided_hint_override via use_user_provided_hint_override=fallback is not None? I just worry that can be a confusing API since a user might pass in fallback=0 and be surprised when autotuning happens with a different value. Admittedly this is still the case with fallback=0 && use_user_provided_hint_override=True but, at least in mind, it's much easier to reason through since the flags are separate.

Or perhaps I'm misunderstanding? If you have a cleaner API proposal, I'm all ears!

Very similar to #161007 except now for mark_unbacked.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 16, 2025
ghstack-source-id: 8c9ee95
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 16, 2025
ghstack-source-id: b5f44c3
Pull Request resolved: #162652
Very similar to #161007 except now for mark_unbacked.

cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv voznesenskym penguinwu Guobing-Chen XiaobingSuper zhuhaozhe blzheng jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov coconutruben Lucaskabela

[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Sep 16, 2025
ghstack-source-id: 1f0b764
Pull Request resolved: #162652
@bobrenjc93
Copy link
Contributor Author

Synced with @ezyang offline and collectively decided to consolidate on the fallback kwarg.

@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

mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
Very similar to pytorch#161007 except now for mark_unbacked.

Pull Request resolved: pytorch#162652
Approved by: https://github.com/laithsakka
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
Very similar to pytorch#161007 except now for mark_unbacked.

Pull Request resolved: pytorch#162652
Approved by: https://github.com/laithsakka
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
Very similar to pytorch#161007 except now for mark_unbacked.

Pull Request resolved: pytorch#162652
Approved by: https://github.com/laithsakka
@github-actions github-actions bot deleted the gh/bobrenjc93/558/head branch October 18, 2025 02:06
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.

5 participants