8000 Introduce unsafe way to mark functions as cacheable by oulgen · Pull Request #151603 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Introduce unsafe way to mark functions as cacheable #151603

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

Closed
wants to merge 5 commits into from

Conversation

@oulgen oulgen requested a review from bdhirsh as a code owner April 17, 2025 19:57
Copy link
pytorch-bot bot commented Apr 17, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 Cancelled Job, 12 Unrelated Failures

As of commit 83e2d32 with merge base c3a7278 (image):

CANCELLED JOB - The following job was cancelled. Please retry:

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.

oulgen added a commit that referenced this pull request Apr 17, 2025
ghstack-source-id: 5281e69
Pull Request resolved: #151603
@oulgen oulgen requested review from jamesjwu and zou3519 April 17, 2025 19:59
@oulgen oulgen added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Apr 17, 2025
cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

[ghstack-poisoned]
cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

[ghstack-poisoned]
Comment on lines 348 to 349
"unsafe_marked_cacheable_functions",
["torch.ops.higher_order.tag_activation_checkpoint"],
Copy link
Contributor

Choose a reason for hiding this comment

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

does this work with non-HOPs?

The way to test this is to create a new function, then use torch._dynamo.allow_in_graph on it (so it shows up in the Dynamo graph), and then try to see if it can be cached

return (
self._cacheable
or f"{self.__module__}.{self.__name__}"
in torch._inductor.config.unsafe_marked_cacheable_functions
Copy link
Contributor
@bdhirsh bdhirsh Apr 18, 2025

Choose a reason for hiding this comment

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

Just a thought - I'm a bit worried about a situation like:

(1) end user is running torch.compile

(2) their compiled code uses some 3rd-party library code that (incorrectly) marks a bad function as cache-safe

(3) they get silent correctness and report it to us.

One obvious debugging step would be to ask them to find any of these functions that have been marked cache-safe and turn off caching for them, so we can easily tell if it's our fault (general caching bug) or someone else's fault (3rd party lib doing unsafe things).

This will be a pain to do in the current setup - since even if we tell the user to set unsafe_marked_cacheable_functions=[], the user doesn't have an easy way of ensuring that they can update this config last, after any 3rd party libs add to the config.

Given this setup - what do you think of adding (yet another) config to "ignore" these markings?

oulgen added 2 commits April 20, 2025 10:48
cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

[ghstack-poisoned]
cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov

[ghstack-poisoned]
oulgen added a commit that referenced this pull request Apr 21, 2025
ghstack-source-id: 0f5c426
Pull Request resolved: #151603
@oulgen
Copy link
Contributor Author
oulgen commented Apr 21, 2025

@pytorchbot merge -f "ci says it is safe to land"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

@github-actions github-actions bot deleted the gh/oulgen/28/head branch May 28, 2025 02:21
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
0