Fix RPC get_worker_info for rank=0 (#52804)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52804

`rpc.get_worker_info` used to only take string in v1.6. We recently
allow it to accept `int` and `WorkerInfo`, but the previous check
on `worker_name` is no longer correct. This commit adds explicit
`not None` check.

Test Plan: Imported from OSS

Reviewed By: rohan-varma

Differential Revision: D26655089

Pulled By: mrshenli

fbshipit-source-id: fa1545bd6dd2b33bc1e919de46b94e799ab9719c
This commit is contained in:
Shen Li
2021-02-25 08:13:12 -08:00
committed by Facebook GitHub Bot
parent f71d9e28f9
commit 1ac59d9db3
2 changed files with 11 additions and 1 deletions

View File

@ -347,7 +347,7 @@ def get_worker_info(worker_name=None):
``worker_name`` or :class:`~torch.distributed.rpc.WorkerInfo` of the
current worker if ``worker_name`` is ``None``.
"""
if worker_name:
if worker_name is not None:
return _get_current_rpc_agent().get_worker_info(worker_name)
else:
return _get_current_rpc_agent().get_worker_info()