Skip to content

[wip] Add isolated parameter to torch.compile for independent Dynamo caches - #178347

Closed
anijain2305 wants to merge 1 commit into
gh/anijain2305/1113/basefrom
gh/anijain2305/1113/head
Closed

anijain2305 wants to merge 1 commit into
gh/anijain2305/1113/basefrom
gh/anijain2305/1113/head

Conversation

@anijain2305

@anijain2305 anijain2305 commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

When multiple torch.compile calls target the same function, they share
a Dynamo cache on fn.__code__ which can cause cache thrashing and shared
recompile limit exhaustion. The new isolated=True parameter creates a
fresh code object (via code.replace()) for each compiled version, giving
each its own independent ExtraState with separate cache entries,
recompile limits, and frame_state.

Authored with Claude.

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

When multiple torch.compile calls target the same function, they share
a Dynamo cache on fn.__code__ which can cause cache thrashing and shared
recompile limit exhaustion. The new isolated=True parameter creates a
fresh code object (via code.replace()) for each compiled version, giving
each its own independent ExtraState with separate cache entries,
recompile limits, and frame_state.

Authored with Claude.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 3 Unrelated Failures

As of commit 835463e with merge base c032b7d (image):

NEW FAILURE - The following job has failed:

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

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

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

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

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Mar 24, 2026
@pytorch-bot

pytorch-bot Bot commented Mar 24, 2026

Copy link
Copy Markdown

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.

anijain2305 added a commit that referenced this pull request Mar 24, 2026
When multiple torch.compile calls target the same function, they share
a Dynamo cache on fn.__code__ which can cause cache thrashing and shared
recompile limit exhaustion. The new isolated=True parameter creates a
fresh code object (via code.replace()) for each compiled version, giving
each its own independent ExtraState with separate cache entries,
recompile limits, and frame_state.

Authored with Claude.

ghstack-source-id: 9d67168
Pull Request resolved: #178347
@anijain2305

anijain2305 commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude review
image

@anijain2305 anijain2305 changed the title Add isolated parameter to torch.compile for independent Dynamo caches [wip] Add isolated parameter to torch.compile for independent Dynamo caches Mar 25, 2026
@anijain2305
anijain2305 marked this pull request as draft March 25, 2026 22:16
@github-actions
github-actions Bot deleted the gh/anijain2305/1113/head branch April 30, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant