Skip to content

[dynamo] Add GUARD_VALUE_DISPATCH table for guard evaluation#176033

Closed
anijain2305 wants to merge 34 commits intogh/anijain2305/1037/basefrom
gh/anijain2305/1037/head
Closed

[dynamo] Add GUARD_VALUE_DISPATCH table for guard evaluation#176033
anijain2305 wants to merge 34 commits intogh/anijain2305/1037/basefrom
gh/anijain2305/1037/head

Conversation

@anijain2305
Copy link
Contributor

@anijain2305 anijain2305 commented Feb 28, 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.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 28, 2026

🔗 Helpful Links

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

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

✅ You can merge normally! (5 Unrelated Failures)

As of commit fc5aedd with merge base b633f26 (image):

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 Feb 28, 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.

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.

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

[ghstack-poisoned]
@anijain2305 anijain2305 changed the title [dynamo] Add GUARD_VALUE_DISPATCH table for guard evaluation [wip][dynamo] Add GUARD_VALUE_DISPATCH table for guard evaluation Feb 28, 2026
…luation"

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.

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

[ghstack-poisoned]
…luation"

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.

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

[ghstack-poisoned]
…luation"

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.

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

[ghstack-poisoned]
time using a fresh value and the previously saved info.
"""

extract: Any
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace extract with extract_fn

"""

extract: Any
check: Any
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace check with eval_fn

Comment on lines 2458 to 2464
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is code duplication here with extract_opaque_obj.

This pattern is also common with DTensor guards, can you reuse the helper even inside the guard methods.

guard.create_fn.keywords["attr"],
hasattr(value, guard.create_fn.keywords["attr"]),
),
check=lambda value, expected: hasattr(value, expected[0]) == expected[1],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe expected should be renamed metadata - expected[0], expected[1] sound confusing

guard.user_stack,
)

@skip_guard_check_spec
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a comment why its ok to skip here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not convinced with the comment - but the right thing here is to use unsupported_guard_check_spec with the comment that we dont expect DICT_VERSION guard - even if it exists, it will fail for the second source. So, for now, lets use unsupported_guard_check_spec

…luation"

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.

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

[ghstack-poisoned]
…luation"

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.

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

[ghstack-poisoned]
…luation"

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.

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

[ghstack-poisoned]
…luation"

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.

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

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 6, 2026
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 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.

Details for Dev Infra team Raised by workflow job

@pytorch-bot
Copy link

pytorch-bot bot commented Mar 6, 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.

@anijain2305 anijain2305 added the topic: not user facing topic category label Mar 6, 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

@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

sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 12, 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.

ghstack-source-id: bc16897
Pull Request resolved: pytorch/pytorch#176033
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 12, 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.

ghstack-source-id: 6c2006a
Pull Request resolved: pytorch/pytorch#176033
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 12, 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.

ghstack-source-id: 44a49cf
Pull Request resolved: pytorch/pytorch#176033
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 12, 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.

ghstack-source-id: 9583a4e
Pull Request resolved: pytorch/pytorch#176033
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 12, 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.

ghstack-source-id: d2bd0d9
Pull Request resolved: pytorch/pytorch#176033
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 13, 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.

ghstack-source-id: d82dd9c
Pull Request resolved: pytorch/pytorch#176033
sandy-gags pushed a commit to sandy-gags/pytorch that referenced this pull request Mar 13, 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.

ghstack-source-id: 93fbee0
Pull Request resolved: pytorch/pytorch#176033
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.

3 participants