Skip to content

Commit ad27a9c

Browse files
committed
Fix set_device_map docs (#53508)
Summary: Pull Request resolved: #53508 closes #53501 Differential Revision: D26885263 Test Plan: Imported from OSS Reviewed By: H-Huang Pulled By: mrshenli fbshipit-source-id: dd0493e6f179d93b518af8f082399cacb1c7cba6
1 parent 30712fc commit ad27a9c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

torch/distributed/rpc/options.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ def set_device_map(self, to: str, device_map: Dict):
7373
>>> # on worker 0
7474
>>> options = TensorPipeRpcBackendOptions(
7575
>>> num_worker_threads=8,
76-
>>> device_maps={"worker1": {0, 1}}
76+
>>> device_maps={"worker1": {0: 1}}
7777
>>> # maps worker0's cuda:0 to worker1's cuda:1
7878
>>> )
79-
>>> options.set_device_map("worker1", {1, 2})
79+
>>> options.set_device_map("worker1", {1: 2})
8080
>>> # maps worker0's cuda:1 to worker1's cuda:2
8181
>>>
8282
>>> rpc.init_rpc(
8383
>>> "worker0",
8484
>>> rank=0,
85-
>>> world_size=2
85+
>>> world_size=2,
8686
>>> backend=rpc.BackendType.TENSORPIPE,
8787
>>> rpc_backend_options=options
8888
>>> )
@@ -94,7 +94,7 @@ def set_device_map(self, to: str, device_map: Dict):
9494
>>> # the device map, and hence will be moved back to cuda:0 and
9595
>>> # cuda:1 on worker0
9696
>>> print(rets[0]) # tensor([2., 2.], device='cuda:0')
97-
>>> print(rets[0]) # tensor([2., 2.], device='cuda:1')
97+
>>> print(rets[1]) # tensor([2., 2.], device='cuda:1')
9898
"""
9999
device_index_map = {}
100100
curr_device_maps = super().device_maps

0 commit comments

Comments
 (0)