def test_set_rpc_timeout(self): timeout = timedelta(seconds=1) rpc.init_rpc(self_name="worker{}".format(self.rank), backend=self.rpc_backend, init_method=self.init_method, self_rank=self.rank, worker_name_to_id=self.worker_name_to_id, rpc_timeout=timeout) set_timeout = rpc.get_rpc_timeout() self.assertEqual(timeout, set_timeout) rpc.join_rpc()
def test_set_rpc_timeout(self): timeout = timedelta(seconds=1) rpc.init_model_parallel(self_name="worker{}".format(self.rank), backend=rpc.backend_registry.BackendType[ TEST_CONFIG.rpc_backend_name], init_method=self.init_method, self_rank=self.rank, worker_name_to_id=self.worker_name_to_id, rpc_timeout=timeout) set_timeout = rpc.get_rpc_timeout() self.assertEqual(timeout, set_timeout) rpc.join_rpc()
def rpc_async_on_role(role: str, func, args=None, kwargs=None, timeout=None) -> Dict[str, torch_rpc.Future]: # can't use rpc.UNSET_RPC_TIMEOUT (only available in torch 1.6.0+) # reproduce the same behavior by getting the timeout if one is not passed if timeout is None: # pyre-fixme[16]: Module `torch_rpc` has no attribute `get_rpc_timeout`. timeout = torch_rpc.get_rpc_timeout() futures = {} for name in get_worker_names(role): fut = torch_rpc.rpc_async(name, func, args, kwargs, timeout) futures[name] = fut return futures
def test_get_rpc_timeout(self): timeout = timedelta(seconds=1) # A new `RpcBackendOptions` is constructed # when accessing `self.rpc_backend_options`. rpc_backend_options = self.rpc_backend_options rpc_backend_options.rpc_timeout = timeout rpc.init_rpc( name="worker{}".format(self.rank), backend=self.rpc_backend, rank=self.rank, world_size=self.world_size, rpc_backend_options=rpc_backend_options, ) set_timeout = rpc.get_rpc_timeout() self.assertEqual(timeout, set_timeout) rpc.shutdown()
def test_get_rpc_timeout(self): timeout = timedelta(seconds=1) # A new `RpcAgentOptions` is constructed # when accessing `self.rpc_agent_options`. rpc_agent_options = self.rpc_agent_options rpc_agent_options.rpc_timeout = timeout rpc.init_rpc( name="worker{}".format(self.rank), backend=self.rpc_backend, init_method=self.init_method, rank=self.rank, world_size=self.world_size, rpc_agent_options=rpc_agent_options, ) set_timeout = rpc.get_rpc_timeout() self.assertEqual(timeout, set_timeout) rpc.wait_all_workers()
def test_get_default_rpc_timeout(self): timeout = rpc.get_rpc_timeout() self.assertEqual(timeout, rpc.constants.DEFAULT_RPC_TIMEOUT)