Skip to content

[dynamo] Track mutated_sources on SideEffects for precise mutation detection#176477

Closed
anijain2305 wants to merge 6 commits intogh/anijain2305/1060/basefrom
gh/anijain2305/1060/head
Closed

[dynamo] Track mutated_sources on SideEffects for precise mutation detection#176477
anijain2305 wants to merge 6 commits intogh/anijain2305/1060/basefrom
gh/anijain2305/1060/head

Conversation

@anijain2305
Copy link
Contributor

@anijain2305 anijain2305 commented Mar 4, 2026

Stack from ghstack (oldest at bottom):

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

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

…tection

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 4, 2026

🔗 Helpful Links

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

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

❌ 1 New Failure, 4 Unrelated Failures

As of commit 85a9638 with merge base b633f26 (image):

NEW FAILURE - The following job has failed:

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

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 job is marked as unstable, possibly due to flakiness on trunk:

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

@pytorch-bot
Copy link

pytorch-bot bot commented Mar 4, 2026

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.

Copy link
Member

@williamwen42 williamwen42 left a comment

Choose a reason for hiding this comment

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

There seems like there could be some overlap with _capture_user_stack? Could we investigate if we can combine _capture_user_stack and self.mutated_sources?

…mutation detection"

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

[ghstack-poisoned]
…mutation detection"

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

[ghstack-poisoned]
…mutation detection"

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

[ghstack-poisoned]
…mutation detection"

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

[ghstack-poisoned]
@anijain2305 anijain2305 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Mar 5, 2026
@anijain2305
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

@pytorchmergebot
Copy link
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@anijain2305
Copy link
Contributor Author

@pytorchbot merge

@anijain2305
Copy link
Contributor Author

@pytorchbot merge -i

…mutation detection"

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

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

[ghstack-poisoned]
@anijain2305
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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-py3-arm64 / test (default, 3, 3, macos-m1-stable)

Details for Dev Infra team Raised by workflow job

@anijain2305
Copy link
Contributor Author

@pytorchbot merge -i

@pytorchmergebot
Copy link
Collaborator

pytorchmergebot pushed a commit that referenced this pull request Mar 6, 2026
Add a dispatch table that maps guard type names to extract/check handler
pairs. This lets invoke_subgraph_cache evaluate guards at cache-lookup
time without duplicating per-guard-type logic in parallel if/elif chains.

Pull Request resolved: #176033
Approved by: https://github.com/zou3519
ghstack dependencies: #176477
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 12, 2026
…tection

Record the exact source (AttrSource for store_attr, var.source for
value mutations) into an OrderedSet on SideEffects. This enables
invoke_subgraph reuse to detect mutations via a simple set
intersection with traced_sources instead of walking source chains,
and is more precise -- mutating mod.d no longer invalidates a
subgraph that only read mod.c.

Authored with Claude.

ghstack-source-id: fc82832
Pull Request resolved: pytorch/pytorch#176477
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.

4 participants