-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Export TorchScript Classes as TorchScript code #46944
Comments
facebook-github-bot
added
the
oncall: jit
Add this issue/PR to JIT oncall triage queue
label
Oct 27, 2020
Anyone’s working on this? If not I could take a stab. |
I'm gradually polishing #44324 to close this. |
SplitInfinity
pushed a commit
that referenced
this issue
Apr 16, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 16, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 16, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 16, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 20, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 20, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 20, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 20, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 21, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 21, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 21, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 21, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 29, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 29, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 29, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Apr 29, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
May 4, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
May 4, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
May 4, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
May 4, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Jun 28, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Jun 28, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Jun 29, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Jun 29, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Jun 29, 2021
…pt classes" **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
SplitInfinity
pushed a commit
that referenced
this issue
Jun 29, 2021
**Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421, #46944. Differential Revision: [D24912807](https://our.internmc.facebook.com/intern/diff/D24912807) [ghstack-poisoned]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🚀 Feature
Add an option to export TorchScript classes as TorchScript code when
torch.jit.save
-ing a module. That way, the resulting file will be hermetically sealed, without relying on any particular code versioning to get it to execute.Motivation
Right now, if you
torch.jit.script
a class, PyTorch relies on the actual class code to being available aftertorch.jit.load
-ing the model for instance, in the code below I cannot actually execute myModule
without having access to theA
classThis creates a really unfortunate coupling between the code defining the
A
class and the code need to run theModule
class. This is also quite unintuitive, b/c scripted modules do not rely referencing code -- the code dependence seems only to beh ere for TorchScript non-module classes.In our particular use case, we are using a
TorchScript
class as a "tuple but with some simple helper methods". Unfortunately, this dependence on our code is preventing us from refactoring our classes in our codebase (e.g. adding new fields) b/c of backwards compatibility with older models we've already serialized.Pitch
Add an option to export the
A
class's code into the serialized torchscript module. This would allowtorch.jit.script
to produce hermetically sealed modules that don't need anything except PyTorch to execute correctly (which would massively simplify deployment for us).Alternatives
If we don't do this, I think we should clearly document this behavior in the TorchScript classes section -- as I said earlier, b/c serializing a custom
nn.Module
does not require the underlying class definition, this code dependence came as a surprise to us.cc @gmagogsfm
The text was updated successfully, but these errors were encountered: