Skip to content

[RPC] Create local RRef<ModuleInterface> remotely in Python, use it remotely in TorchScript #34183

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

Closed
wants to merge 10 commits into from

Conversation

xush6528
Copy link
Contributor

@xush6528 xush6528 commented Mar 4, 2020

Stack from ghstack:

#33263 enhanced the RRef Python constructor to infer most types, by jit::tryToInferType(..).

But this helper function can't infer ScriptModule type due to ScriptModule's special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained ScriptModule.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified ModuleInterface type.

We added an optional argument type_hint for users to set an RRef for what ModuleInterface type it's holds.

Differential Revision: D7065050

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Mar 4, 2020
xush6528 added a commit that referenced this pull request Mar 4, 2020
`

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

ghstack-source-id: 99451392
Pull Request resolved: #34183
@dr-ci
Copy link

dr-ci bot commented Mar 4, 2020

💊 CircleCI build failures summary and remediations

As of commit 1da85ab (more details on the Dr. CI page):


Commit 1da85ab was recently pushed. Waiting for builds...


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 22 times.

@xush6528 xush6528 requested review from wanchaol and zzzwen March 4, 2020 23:19
Copy link
Contributor

@zzzwen zzzwen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Can you add a test again "torchscript class interface"? not sure if this is the correct name, but the code is something like this

@torch.jit.interface
class Interface(object):

…rchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to track the type of the `ScriptModule` it holds..

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more helpful to mark it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
xush6528 added a commit that referenced this pull request Mar 5, 2020
Pull Request resolved: #34183

#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`.

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to track the type of the `ScriptModule` it holds..

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more helpful to mark it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

ghstack-source-id: 99536698

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)
@xush6528 xush6528 changed the title [RPC] Create RRef<ModuleInterface> in Python, use it in TorchScript [RPC] Create RRef<ModuleInterface> locally in Python, use it remotely in TorchScript Mar 5, 2020
…it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
xush6528 added a commit that referenced this pull request Mar 5, 2020
… in TorchScript

Pull Request resolved: #34183

#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`.

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

ghstack-source-id: 99563605

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)
Copy link
Contributor

@mrshenli mrshenli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for adding this!

Copy link
Collaborator

@wanchaol wanchaol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There're several type check/ user facing error message we should fix before we merge this.

…it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
…it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
…it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
xush6528 added a commit that referenced this pull request Mar 5, 2020
… in TorchScript

Pull Request resolved: #34183

#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`.

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

ghstack-source-id: 99619039

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)
Copy link
Collaborator

@wanchaol wanchaol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good, some nits and some questions.

…it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
xush6528 added a commit that referenced this pull request Mar 6, 2020
… in TorchScript

Pull Request resolved: #34183

#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`.

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

ghstack-source-id: 99630694

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)
@xush6528 xush6528 requested a review from wanchaol March 6, 2020 01:11
Copy link
Collaborator

@wanchaol wanchaol 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! one minor suggestion on merging two checks.

…it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
xush6528 added a commit that referenced this pull request Mar 6, 2020
… in TorchScript

Pull Request resolved: #34183

#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`.

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

ghstack-source-id: 99648617

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)
@xush6528 xush6528 changed the title [RPC] Create RRef<ModuleInterface> locally in Python, use it remotely in TorchScript Create local RRef<ModuleInterface> remotely in Python, use it remotely in TorchScript Mar 6, 2020
@xush6528 xush6528 changed the title Create local RRef<ModuleInterface> remotely in Python, use it remotely in TorchScript [RPC] Create local RRef<ModuleInterface> remotely in Python, use it remotely in TorchScript Mar 6, 2020
…n, use it remotely in TorchScript"


#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`. 

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to set an `RRef` for what `ModuleInterface` type it's holds.

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)

[ghstack-poisoned]
xush6528 added a commit that referenced this pull request Mar 6, 2020
…emotely in TorchScript

Pull Request resolved: #34183

#33263 enhanced the RRef Python constructor to infer most types, by `jit::tryToInferType(..)`.

But this helper function can't infer `ScriptModule` type due to `ScriptModule`'s special per-Module type singleton logic, so it's still not possible for an Python-created RRef to know the JIT type of it's contained `ScriptModule`.

Instead of inferring the specific type of a Module, which could leads to too many candidate types (due to Module's multiple inheritance possibility), it's more straightforward to set it's type as a user-specified `ModuleInterface` type.

We added an optional argument `type_hint` for users to mark an `RRef` for what `ModuleInterface` type it's holds.

ghstack-source-id: 99649379

Differential Revision: [D7065050](https://our.internmc.facebook.com/intern/diff/D7065050/)
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 17ceb69.

@facebook-github-bot facebook-github-bot deleted the gh/xush6528/75/head branch March 10, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants