pytorch/torch
Shen Li 06aaf8c20d Add set_device_map to TensorPipeOptions to support GPU args (#42637)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/42637

This commit enables sending non-CPU tensors through RPC using
TensorPipe backend. Users can configure device mappings by calling
set_map_location on `TensorPipeRpcBackendOptions`. Internally,
the `init_rpc` API verifies the correctness of device mappings. It
will shutdown RPC if the check failed, or proceed and pass global
mappings to `TensorPipeAgent` if the check was successful. For serde,
we added a device indices field to TensorPipe read and write buffers,
which should be either empty (all tensors must be on CPU) or match
the tensors in order and number in the RPC message. This commit
does not yet avoid zero-copy, the tensor is always moved to CPU
on the sender and then moved to the specified device on the receiver.

Test Plan: Imported from OSS

Reviewed By: izdeby

Differential Revision: D23011572

Pulled By: mrshenli

fbshipit-source-id: 62b617eed91237d4e9926bc8551db78b822a1187
2020-08-14 18:46:55 -07:00
..
_C Fix type annotations for a number of torch.utils submodules (#42711) 2020-08-14 18:12:48 -07:00
autograd Don't materialize output grads (#41821) 2020-08-11 04:27:07 -07:00
backends [reland] Enable TF32 support for cuBLAS (#41498) 2020-07-15 21:00:55 -07:00
contrib remediation of S205607 2020-07-17 17:19:47 -07:00
csrc Add set_device_map to TensorPipeOptions to support GPU args (#42637) 2020-08-14 18:46:55 -07:00
cuda Update cuda init docstring to improve clarity (#42923) 2020-08-12 15:41:28 -07:00
distributed Add set_device_map to TensorPipeOptions to support GPU args (#42637) 2020-08-14 18:46:55 -07:00
distributions clamp Categorical logit from -inf to min_fifo when calculating entropy (#41002) 2020-07-14 16:21:12 -07:00
fft Adds fft namespace (#41911) 2020-08-06 00:20:50 -07:00
for_onnx
futures Add done() API to Future (#42013) 2020-07-24 14:13:41 -07:00
fx [fx] split Node into Node/Proxy (#42991) 2020-08-14 16:45:21 -07:00
jit [JIT] Add property support to TorchScript classes (#42389) 2020-08-14 12:56:57 -07:00
legacy
lib [c10d] Template computeLengthsAndOffsets() (#42706) 2020-08-10 19:21:46 -07:00
linalg Adds linalg.det alias, fixes outer alias, updates alias testing (#42802) 2020-08-11 21:48:31 -07:00
multiprocessing
nn Embed torch.nn typing annotations (#43044) 2020-08-14 13:24:58 -07:00
onnx [Resending] [ONNX] Add eliminate_unused_items pass (#42743) 2020-08-11 20:30:50 -07:00
optim Fix "non-negative integer" error messages (#42734) 2020-08-10 19:39:37 -07:00
quantization Clearer Semantics and Naming for Customized Quantization Range Initialization in Observer (#42602) 2020-08-13 21:15:23 -07:00
sparse typo fixes (#41632) 2020-07-20 07:23:00 -07:00
testing Add set_device_map to TensorPipeOptions to support GPU args (#42637) 2020-08-14 18:46:55 -07:00
utils Fix type annotations for a number of torch.utils submodules (#42711) 2020-08-14 18:12:48 -07:00
__config__.py
__future__.py
__init__.py Adds torch.linalg namespace (#42664) 2020-08-07 10:18:30 -07:00
_appdirs.py Delete Python <= 3.5 specific checks from the code (#39879) 2020-06-15 08:16:06 -07:00
_classes.py
_jit_internal.py [JIT] Fix typing.Final for python 3.8 (#39568) 2020-08-11 08:51:46 -07:00
_linalg_utils.py Support custom exception message (#41907) 2020-08-01 13:03:45 -07:00
_lobpcg.py Add __torch_function__ for methods (#37091) 2020-08-05 20:44:13 -07:00
_lowrank.py Add __torch_function__ for methods (#37091) 2020-08-05 20:44:13 -07:00
_namedtensor_internals.py
_ops.py move misc implementation out of jit/__init__.py (#41154) 2020-07-13 16:59:55 -07:00
_six.py Add typing support to torch._six (#42232) 2020-07-30 12:12:46 -07:00
_storage_docs.py Python API for Complex Storage and storage copy logic (#35771) 2020-05-01 11:47:22 -07:00
_tensor_docs.py Implement torch.nextafter (#42580) 2020-08-14 00:35:30 -07:00
_tensor_str.py [quant] Create PerRowQuantizer for floating point scale and zero_point (#42612) 2020-08-13 11:20:53 -07:00
_torch_docs.py Add polygamma where n >= 2 (#42499) 2020-08-14 17:00:24 -07:00
_utils_internal.py Fix get_writable_path (#42895) 2020-08-12 09:38:24 -07:00
_utils.py Decouple DataParallel/DistributedDataParallel from CUDA (#38454) 2020-07-07 12:48:16 -07:00
_VF.py Delete torch/__init__.pyi, deferring to direct extension stubs (#38157) 2020-05-11 07:20:13 -07:00
_vmap_internals.py vmap: temporarily disable support for random functions (#42617) 2020-08-11 07:19:51 -07:00
abi-check.cpp
CMakeLists.txt Guard TensorPipe agent by USE_TENSORPIPE (#42682) 2020-08-14 02:57:36 -07:00
custom_class_detail.h Test BC for built-in torchbind methods (#38560) 2020-05-15 19:06:59 -07:00
custom_class.h avoid redundant isCustomClassRegistered() checks (#42852) 2020-08-11 21:53:19 -07:00
extension.h
functional.py Add __torch_function__ for methods (#37091) 2020-08-05 20:44:13 -07:00
hub.py Add typing annotations to hub.py and _jit_internal.py (#42252) 2020-08-04 08:20:44 -07:00
library.h Add reference documentation for torch/library.h (#41470) 2020-07-17 10:05:16 -07:00
overrides.py Implement torch.nextafter (#42580) 2020-08-14 00:35:30 -07:00
py.typed remediation of S205607 2020-07-17 17:19:47 -07:00
quasirandom.py Fix HTTP links in documentation to HTTPS (#40878) 2020-07-06 20:05:21 -07:00
random.py Fix manual seed to unpack unsigned long (#42206) 2020-08-11 18:05:34 -07:00
README.txt
script.h
serialization.py DOC: fail to build if there are warnings (#41335) 2020-07-28 22:33:44 -07:00
storage.py [testing] Dont use zipfile for storage __reduce__ (#39893) 2020-06-12 16:48:12 -07:00
tensor.py Add complex tensor dtypes for the __cuda_array_interface__ spec (#42918) 2020-08-14 10:26:23 -07:00
types.py Fix type annotations for a number of torch.utils submodules (#42711) 2020-08-14 18:12:48 -07:00

Note [TH abstraction violation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TH/THC provide some hpp headers, which are proper C++ headers rather than
C headers.  These headers serve double duty as *internal implementation
detail* headers, whose contents should largely not be used by external
clients.

Ideally, we would not install these headers at all; instead, you should
use public functions (in headers like `THTensor.h`, NOT `THTensor.hpp`)
to manipulate these structs.  However, there are a few places
in torch/csrc where we violate this abstraction.  They are marked with
a pointer to this note.  Each of those sites will have to be refactored
when we refactor the guts of THTensor and related structures.