Skip to content

Conversation

@mrshenli
Copy link
Contributor

@mrshenli mrshenli commented Nov 21, 2019

Stack from ghstack:

Before this commit, rpc docs shows init_rpc as the following:

torch.distributed.rpc.init_rpc(
   name,
   backend=<BackendType.PROCESS_GROUP: BackendValue(
     construct_rpc_agent_options_handler=<function _process_group_construct_rpc_agent_options_handler>,
     init_backend_handler=<function _process_group_init_backend_handler>)>,
   init_method=None,
   rank=-1,
   world_size=None,
   rpc_agent_options=None
)

It unnecessarily leaks implementation details. This commit adds a
repr function to BackendType Enum class to address this problem.

closes #29905

Differential Revision: D18641559

[ghstack-poisoned]
Before this commit, rpc docs shows init_rpc as the following:

> torch.distributed.rpc.init_rpc(
>   name,
>   backend=<BackendType.PROCESS_GROUP: BackendValue(
>     construct_rpc_agent_options_handler=<function _process_group_construct_rpc_agent_options_handler>,
>     init_backend_handler=<function _process_group_init_backend_handler>)>,
>   init_method=None,
>   rank=-1,
>   world_size=None,
>   rpc_agent_options=None
> )

It unnecessarily leaks implementation details. This commit adds a
__repr__ function to BackendType Enum class to address this problem.

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 21, 2019
Before this commit, rpc docs shows init_rpc as the following:

> torch.distributed.rpc.init_rpc(
>   name,
>   backend=<BackendType.PROCESS_GROUP: BackendValue(
>     construct_rpc_agent_options_handler=<function _process_group_construct_rpc_agent_options_handler>,
>     init_backend_handler=<function _process_group_init_backend_handler>)>,
>   init_method=None,
>   rank=-1,
>   world_size=None,
>   rpc_agent_options=None
> )

It unnecessarily leaks implementation details. This commit adds a
__repr__ function to BackendType Enum class to address this problem.

ghstack-source-id: 71a95e7
Pull Request resolved: #30243
@mrshenli
Copy link
Contributor Author

Screen Shot 2019-11-21 at 1 54 45 PM

Copy link
Contributor

@rohan-varma rohan-varma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Does BackendType show up in docs? Would we need it to show up so users know about BackendType.ProcessGroup?

@mrshenli
Copy link
Contributor Author

Looks good. Does BackendType show up in docs? Would we need it to show up so users know about BackendType.ProcessGroup?

Good point, it does not yet, and we should have it. Let me try in a followup PR.

BackendType = enum.Enum(
value="BackendType",
names={},
__repr__=_backend_type_repr
Copy link
Contributor

@xush6528 xush6528 Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes you are right! I was doing BackendType .__repr__ = _backend_type_repr when generating the figure and then switched to this afterward. It was showing the same result, but I should have make clean the docs, after that I started to see errors. Let me update.

Before this commit, rpc docs shows init_rpc as the following:

```python
torch.distributed.rpc.init_rpc(
   name,
   backend=<BackendType.PROCESS_GROUP: BackendValue(
     construct_rpc_agent_options_handler=<function _process_group_construct_rpc_agent_options_handler>,
     init_backend_handler=<function _process_group_init_backend_handler>)>,
   init_method=None,
   rank=-1,
   world_size=None,
   rpc_agent_options=None
)
```

It unnecessarily leaks implementation details. This commit adds a
__repr__ function to BackendType Enum class to address this problem.

closes #29905

Differential Revision: [D18641559](https://our.internmc.facebook.com/intern/diff/D18641559)

[ghstack-poisoned]
Copy link
Contributor

@xush6528 xush6528 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel certain that this works!

Before this commit, rpc docs shows init_rpc as the following:

```python
torch.distributed.rpc.init_rpc(
   name,
   backend=<BackendType.PROCESS_GROUP: BackendValue(
     construct_rpc_agent_options_handler=<function _process_group_construct_rpc_agent_options_handler>,
     init_backend_handler=<function _process_group_init_backend_handler>)>,
   init_method=None,
   rank=-1,
   world_size=None,
   rpc_agent_options=None
)
```

It unnecessarily leaks implementation details. This commit adds a
__repr__ function to BackendType Enum class to address this problem.

closes #29905

Differential Revision: [D18641559](https://our.internmc.facebook.com/intern/diff/D18641559)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 21, 2019
Before this commit, rpc docs shows init_rpc as the following:

> torch.distributed.rpc.init_rpc(
>   name,
>   backend=<BackendType.PROCESS_GROUP: BackendValue(
>     construct_rpc_agent_options_handler=<function _process_group_construct_rpc_agent_options_handler>,
>     init_backend_handler=<function _process_group_init_backend_handler>)>,
>   init_method=None,
>   rank=-1,
>   world_size=None,
>   rpc_agent_options=None
> )

It unnecessarily leaks implementation details. This commit adds a
__repr__ function to BackendType Enum class to address this problem.

ghstack-source-id: 33cdabc
Pull Request resolved: #30243
@pritamdamania87
Copy link
Contributor

@mrshenli I see a couple of issues with the docs:

  1. init_rpc used to be a link to the method, now the link is lost.
  2. The following line doesn't seem right: "By default, this will also initialize the ProcessGroup (torch.distributed.Backend()) backend for RPC communication". We shouldn't link to torch.distributed.Backend (since this backend refers to gloo,nccl and mpi) for ProcessGroup. We should link to it when we specify that we use gloo for communication. If we do want a link for ProcessGroup, maybe we can link to https://pytorch.org/docs/master/distributed.html#torch.distributed.init_process_group for now?

@mrshenli
Copy link
Contributor Author

@pritamdamania87

  1. init_rpc used to be a link to the method, now the link is lost.

Where is that link?

@mrshenli
Copy link
Contributor Author

The following line doesn't seem right: "By default, this will also initialize the ProcessGroup (torch.distributed.Backend()) backend for RPC communication". We shouldn't link to torch.distributed.Backend (since this backend refers to gloo,nccl and mpi) for ProcessGroup. We should link to it when we specify that we use gloo for communication. If we do want a link for ProcessGroup, maybe we can link to https://pytorch.org/docs/master/distributed.html#torch.distributed.init_process_group for now?

I agree. This is irrelevant to this PR though, add fix in a followup PR

@mrshenli
Copy link
Contributor Author

Addressed @pritamdamania87's comments in #30259

@facebook-github-bot facebook-github-bot deleted the gh/mrshenli/65/head branch December 10, 2019 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants