-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Fix BackendType repr in doc #30243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix BackendType repr in doc #30243
Conversation
[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]
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
rohan-varma
left a comment
There was a problem hiding this 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?
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work?
It looks to me unexpeted keyword args are dropped by this asterisk.
There was a problem hiding this comment.
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]
xush6528
left a comment
There was a problem hiding this 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]
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
|
@mrshenli I see a couple of issues with the docs:
|
Where is that link? |
I agree. This is irrelevant to this PR though, add fix in a followup PR |
|
Addressed @pritamdamania87's comments in #30259 |

Stack from ghstack:
Before this commit, rpc docs shows init_rpc as the following:
It unnecessarily leaks implementation details. This commit adds a
repr function to BackendType Enum class to address this problem.
closes #29905
Differential Revision: D18641559