pytorch/torch/testing/_internal
Shihao Xu 17ceb6941f [RPC] Create local RRef<ModuleInterface> remotely in Python, use it remotely in TorchScript (#34183)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34183

https://github.com/pytorch/pytorch/pull/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

(Note: this ignores all push blocking failures!)

Test Plan:
Aspects that need to be confirmed in the test cases

https://fb.quip.com/aGxRAh2lCg05

```
buck test mode/dev-nosan //caffe2/test/distributed/rpc/jit:rpc_fork

buck build mode/dev-nosan //caffe2/test/distributed/rpc/jit:rpc_fork \
&& buck-out/gen/caffe2/test/distributed/rpc/jit/rpc_fork\#binary.par -r test_create_local_script_class_rref

buck build mode/dev-nosan //caffe2/test/distributed/rpc/jit:rpc_fork \
&& buck-out/gen/caffe2/test/distributed/rpc/jit/rpc_fork\#binary.par -r test_create_local_script_module_rref

buck build mode/dev-nosan //caffe2/test/distributed/rpc/jit:rpc_fork \
&& buck-out/gen/caffe2/test/distributed/rpc/jit/rpc_fork\#binary.par -r test_return_local_script_class_rref_in_py_and_use_in_script

buck build mode/dev-nosan //caffe2/test/distributed/rpc/jit:rpc_fork \
&& buck-out/gen/caffe2/test/distributed/rpc/jit/rpc_fork\#binary.par -r test_return_local_script_module_rref_in_py_and_use_in_script

buck build mode/dev-nosan //caffe2/test/distributed/rpc/jit:rpc_fork \
&& buck-out/gen/caffe2/test/distributed/rpc/jit/rpc_fork\#binary.par -r test_torchscript_function_exception
```

Differential Revision: D7065050

fbshipit-source-id: e10210c0996622969e499e4a35b0659b36787c1c
2020-03-06 08:28:22 -08:00
..
data
distributed [RPC] Create local RRef<ModuleInterface> remotely in Python, use it remotely in TorchScript (#34183) 2020-03-06 08:28:22 -08:00
test_module
__init__.py
common_cuda.py
common_device_type.py Turn on strict dtype checking for test_torch.py (#33825) 2020-03-03 14:45:53 -08:00
common_distributed.py Enable test_distributed for ROCm but only with nccl backend [REDUX] (#32551) 2020-02-10 12:42:36 -08:00
common_methods_invocations.py Turn on strict dtype checking for test_torch.py (#33825) 2020-03-03 14:45:53 -08:00
common_nn.py Tests for verifying behaviour of BatchNorm using 0-dim batch sizes. (#32384) 2020-02-03 16:58:23 -08:00
common_quantization.py Enable inplace relu fusion for training (#33105) 2020-02-14 12:15:58 -08:00
common_quantized.py Add operator support for dynamic quant on mobile (#32479) 2020-01-24 17:51:54 -08:00
common_utils.py Turn on strict dtype checking for test_torch.py (#33825) 2020-03-03 14:45:53 -08:00
dist_utils.py Fixed the flaky test_rref_context_debug_info (#32749) 2020-01-31 16:53:18 -08:00
expecttest.py
hypothesis_utils.py Update hypothesis_utils.py (#33739) 2020-02-24 20:56:42 -08:00
jit_utils.py [quant][graphmode] Observing input/output values in call site (#33277) 2020-03-03 10:53:24 -08:00