@@ -285,7 +285,11 @@ distinguish their role. Rank 0 is always the agent, and all other ranks are
285285observers. As agent as server as master, repeatedly call ``run_episode `` and
286286``finish_episode `` until the running reward surpasses the reward threshold
287287specified by the environment. All observers just passively waiting for commands
288- from the agent.
288+ from the agent. The code is wrapped by
289+ `rpc.init_rpc <https://pytorch.org/docs/master/rpc.html#torch.distributed.rpc.init_rpc >`__ and
290+ `rpc.shutdown <https://pytorch.org/docs/master/rpc.html#torch.distributed.rpc.shutdown >`__,
291+ which initializes and terminates RPC instances respectively. More details are
292+ available in the API page.
289293
290294
291295.. code :: python
@@ -319,6 +323,8 @@ from the agent.
319323 # other ranks are the observer
320324 rpc.init_rpc(OBSERVER_NAME .format(rank), rank = rank, world_size = world_size)
321325 # observers passively waiting for instructions from the agent
326+
327+ # block until all rpcs finish, and shutdown the RPC instance
322328 rpc.shutdown()
323329
324330
@@ -334,7 +340,7 @@ In this example, we show how to use RPC as the communication vehicle to pass
334340date across workers, and how to use RRef to reference remote objects. It is true
335341that you could build the entire structure directly on top of ``ProcessGroup ``
336342``send `` and ``recv `` APIs or use other communication/RPC libraries. However,
337- by using `torch.dstributed .rpc `, you can get the native support plus
343+ by using `torch.distributed .rpc `, you can get the native support plus
338344continuously optimized performance under the hood.
339345
340346Next, we will show how to combine RPC and RRef with distributed autograd and
@@ -539,7 +545,7 @@ processes.
539545
540546 func()
541547
542- # block until all rpcs finish
548+ # block until all rpcs finish, and shutdown the RPC instance
543549 rpc.shutdown()
544550
545551 mp.set_start_method(' spawn' )
0 commit comments