Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Apr 29, 2019

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

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.
@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: internals Related to internal abstractions in c10 and ATen module: pybind Related to our Python bindings / interactions with other Python libraries labels Apr 29, 2019
suo added 3 commits April 28, 2019 21:26
[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
@suo suo requested a review from zdevito May 7, 2019 17:40
[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
Copy link
Contributor

@zdevito zdevito left a 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;
}

/**
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Member Author

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

@zou3519 zou3519 deleted the gh/suo/33/head branch May 8, 2019 05:50
zdevito pushed a commit to zdevito/ATen that referenced this pull request May 8, 2019
Summary:
Pull Request resolved: pytorch/pytorch#19903
ghimport-source-id: deadf59f469ad620d0ee10b089dfc9bb92171710

Differential Revision: D15118978

Pulled By: suo

fbshipit-source-id: f2b487fd65520d1b7f45cb74145634d334ef1614
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in 26dd65e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: internals Related to internal abstractions in c10 and ATen module: pybind Related to our Python bindings / interactions with other Python libraries oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants