-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] Namespace isolation for classes #19903
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
Conversation
Previously class types were owned by a global registry. That causes isolation issues when you want to load two models into C++ but they define classes of the same name. To solve this, we make classes compilation unit-local. Classes defined by loaded models are defined on the main module's compilation unit. For Python, we have a single global compilation unit (similar to what we had before). This isn't ideal but is hard to fix until we refactor compilation unit ownership semantics more broadly.
[jit] Namespace isolation for classes Previously class types were owned by a global registry. That causes isolation issues when you want to load two models into C++ but they define classes of the same name. To solve this, we make classes compilation unit-local. Classes defined by loaded models are defined on the main module's compilation unit. For Python, we have a single global compilation unit (similar to what we had before). This isn't ideal but is hard to fix until we refactor compilation unit ownership semantics more broadly. gh-metadata: pytorch pytorch 19903 gh/suo/33/head
[jit] Namespace isolation for classes Previously class types were owned by a global registry. That causes isolation issues when you want to load two models into C++ but they define classes of the same name. To solve this, we make classes compilation unit-local. Classes defined by loaded models are defined on the main module's compilation unit. For Python, we have a single global compilation unit (similar to what we had before). This isn't ideal but is hard to fix until we refactor compilation unit ownership semantics more broadly. gh-metadata: pytorch pytorch 19903 gh/suo/33/head
[jit] Namespace isolation for classes Previously class types were owned by a global registry. That causes isolation issues when you want to load two models into C++ but they define classes of the same name. To solve this, we make classes compilation unit-local. Classes defined by loaded models are defined on the main module's compilation unit. For Python, we have a single global compilation unit (similar to what we had before). This isn't ideal but is hard to fix until we refactor compilation unit ownership semantics more broadly. gh-metadata: pytorch pytorch 19903 gh/suo/33/head
[jit] Namespace isolation for classes Previously class types were owned by a global registry. That causes isolation issues when you want to load two models into C++ but they define classes of the same name. To solve this, we make classes compilation unit-local. Classes defined by loaded models are defined on the main module's compilation unit. For Python, we have a single global compilation unit (similar to what we had before). This isn't ideal but is hard to fix until we refactor compilation unit ownership semantics more broadly. gh-metadata: pytorch pytorch 19903 gh/suo/33/head
zdevito
left a comment
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.
Looks good. Right now if you cross use a Class with the same qualified name then export is going to end up with name conflicts, right? Thats fine for now.
| return nullptr; | ||
| } | ||
|
|
||
| /** |
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.
I feel like this should be in a python-only compilation unit, for clarity.
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.
Maybe python_sugared_value.cpp
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.
Unfortunately because of dependency stuff I can't move this cleanly; I'll follow up with the change in another PR
Summary: Pull Request resolved: pytorch/pytorch#19903 ghimport-source-id: deadf59f469ad620d0ee10b089dfc9bb92171710 Differential Revision: D15118978 Pulled By: suo fbshipit-source-id: f2b487fd65520d1b7f45cb74145634d334ef1614
Stack from ghstack:
Previously class types were owned by a global registry. That causes
isolation issues when you want to load two models into C++ but they
define classes of the same name.
To solve this, we make classes compilation unit-local. Classes defined
by loaded models are defined on the main module's compilation unit.
For Python, we have a single global compilation unit (similar to what we
had before). This isn't ideal but is hard to fix until we refactor
compilation unit ownership semantics more broadly.
Differential Revision: D15118978