- Notifications
You must be signed in to change notification settings - Fork26.3k
Avoid circular imports in tracing_state_functions#150325
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
pytorch-botbot commentedMar 31, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This pull request aims to avoid circular imports in tracing_state_functions by converting a statically defined mapping into a function.
- The mapping for tracing state functions is now returned through a function.
- The decorator now calls the function to unpack the mapping keys dynamically.
Comments suppressed due to low confidence (1)
torch/_dynamo/variables/torch.py:171
- [nitpick] Consider renaming 'tracing_state_functions' to 'get_tracing_state_functions' to more clearly indicate that it returns a mapping. Optionally, if the mapping is static, memoizing the result could avoid repeated instantiation.
def tracing_state_functions():torch.onnx.is_in_onnx_export fromtracing_state_functionstorch.onnx.is_in_onnx_export fromtracing_state_functionsjustinchuby commentedMar 31, 2025
@pytorchbot rebase |
pytorchmergebot commentedMar 31, 2025
@pytorchbot started a rebase job ontorefs/remotes/origin/viable/strict. Check the current statushere |
pytorchmergebot commentedMar 31, 2025
Successfully rebased |
bb3092b toa986851Comparetorch/_dynamo/variables/torch.py Outdated
| torch.compiler.is_exporting:True, | ||
| torch.nn.modules.activation._is_make_fx_tracing:False, | ||
| } | ||
| deftracing_state_functions(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you toss an lru_cache(None) on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done, please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Uh oh!
There was an error while loading.Please reload this page.
justinchuby commentedApr 9, 2025
@pytorchbot rebase |
pytorchmergebot commentedApr 9, 2025
@pytorchbot started a rebase job ontorefs/remotes/origin/viable/strict. Check the current statushere |
pytorchmergebot commentedApr 9, 2025
Successfully rebased |
eafff40 toecd03fdComparejustinchuby commentedApr 9, 2025
@pytorchbot merge -i |
pytorchmergebot commentedApr 9, 2025
pytorchmergebot commentedApr 9, 2025
Merge failedReason: 1 jobs have failed, first few of them are:linux-binary-manywheel / manywheel-py3_9-cuda12_6-test / test Details for Dev Infra teamRaised byworkflow job |
justinchuby commentedApr 9, 2025
@pytorchbot merge -f "unrelated failures in cuda build" |
pytorchmergebot commentedApr 9, 2025
Merge startedYour change will be merged immediately since you used the force (-f) flag,bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in thewiki. Questions? Feedback? Please reach out to thePyTorch DevX Team |
tracing_state_functions references some torch functions from submodules like `torch.onnx.is_in_onnx_export` that could trigger module initialization & circular imports. I turned the mapping into a function so that the dictionary is not initialized at torch import.(discovered inpytorch#149646)Pull Requestresolved:pytorch#150325Approved by:https://github.com/zou3519
tracing_state_functions references some torch functions from submodules like `torch.onnx.is_in_onnx_export` that could trigger module initialization & circular imports. I turned the mapping into a function so that the dictionary is not initialized at torch import.(discovered inpytorch#149646)Pull Requestresolved:pytorch#150325Approved by:https://github.com/zou3519
Uh oh!
There was an error while loading.Please reload this page.
tracing_state_functions references some torch functions from submodules like
torch.onnx.is_in_onnx_exportthat could trigger module initialization & circular imports. I turned the mapping into a function so that the dictionary is not initialized at torch import.(discovered in#149646)
cc@voznesenskym@penguinwu@EikanWang@jgong5@Guobing-Chen@XiaobingSuper@zhuhaozhe@blzheng@wenzhe-nrv@jiayisunx@chenyang78@kadeng@chauhang@amjames