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
[dynamo] Avoid eager imports of classes with custom VariableTrackers #112319
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/112319
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit e2d6ecd with merge base 493b52b (): FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the Class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! ghstack-source-id: fe3b46025be307284124bf252ff12c66ee2b7021 Pull Request resolved: #112319
Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the Class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! [ghstack-poisoned]
Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the Class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! ghstack-source-id: c660171c51a9207d92055a4634feef0a61805445 Pull Request resolved: #112319
…leTrackers" Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the Class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! ghstack-source-id: 01a33edff568568043f3a3bf2d5f655dd625e2fc Pull Request resolved: #112319
…leTrackers" Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
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.
LGTM as in "looks great to me" but we can wait for @voznesenskym see if he has any comments.
@@ -132,23 +132,6 @@ def remap_as_fn___rand__(*args): | |||
} | |||
|
|||
|
|||
try: |
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.
side effects at import time: 0/10
@voznesenskym ping |
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.
Very nice, thanks
@pytorchbot merge -r |
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
Rebase failed due to Command
Raised by https://github.com/pytorch/pytorch/actions/runs/6788481424 |
Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the Class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! ghstack-source-id: a77b1ca4d6259b7b89115737f79d1507ed9336c5 Pull Request resolved: #112319
…leTrackers" Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
@pytorchbot merge |
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge |
Merge startedYour 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 |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
@pytorchbot merge |
Merge startedYour 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 |
…ytorch#112319) Currently custom VariableTrackers exist for classes that live outside of pytorch. For these cases dynamo currently eagerly imports the module to get the class object to compare against. This instead uses `sys.modules.get("module.path")` such that the module is never imported by dynamo itself, but if the user has imported the module then we will still access the module and grab the type we need to compare against. I noticed this issue because importing `KeyedJaggedTensor` fails half-way through if `fbgemm_gpu` has been built with an incompatible PyTorch version, in which case it retries the import again each time! Pull Request resolved: pytorch#112319 Approved by: https://github.com/lezcano, https://github.com/ezyang
Stack from ghstack (oldest at bottom):
Currently custom VariableTrackers exist for classes that live outside of pytorch.
For these cases dynamo currently eagerly imports the module to get the class
object to compare against.
This instead uses
sys.modules.get("module.path")
such that the module is neverimported by dynamo itself, but if the user has imported the module then we will
still access the module and grab the type we need to compare against.
I noticed this issue because importing
KeyedJaggedTensor
fails half-waythrough if
fbgemm_gpu
has been built with an incompatible PyTorch version, inwhich case it retries the import again each time!
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng