Add isInitialized() API to TorchCommBackend and update TorchCommMCCL::reconfigure initialization state (#2071)#2071
Open
Scusemua wants to merge 1 commit intometa-pytorch:mainfrom
Open
Conversation
Contributor
|
@Scusemua has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100673963. |
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 14, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 14, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
231c3d6 to
591b242
Compare
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 14, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
591b242 to
8bc6040
Compare
Scusemua
pushed a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 14, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 14, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
Scusemua
pushed a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 14, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
pushed a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
pushed a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
pushed a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
added a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
Scusemua
pushed a commit
to Scusemua/torchcomms
that referenced
this pull request
Apr 15, 2026
…:reconfigure initialization state (meta-pytorch#2071) Summary: Pull Request resolved: meta-pytorch#2071 Add `isInitialized()` virtual method to `TorchCommBackend` so callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successful `reconfigure()` result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed. Specifically, we now set `initState_ = UNINITIALIZED` before calling `mccl_comm_->reconfigure()`, then only promote to `INITIALIZED` inside the existing success block (where `result->code == commSuccess`) alongside `rank_` and `commSize_` updates. Previously `initState_ = INITIALIZED` was set unconditionally after `createWork()`, which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure. **We also** reset `commSize_` to 0 instead of -1, and we move the reset of `commSize_` and `rank_` to be with the `initState_ = UNITIALIZED`. For one thing, -1 (as an int) silently becomes `SIZE_MAX` when cast to `size_t`, which caused a production SEV once already. And if `commSize_` ever leaks beyond these guards, then 0 is harmless, while -1 is catastrophic (can crash the workload/application). **Concession:** 0 is more of a soft sentinel insofar as it is a valid communicator size, and so you cannot distinguish "uninitialized" from "genuinely zero participants" by looking at `commSize_` alone. But you can just look at `initState_` for this. Differential Revision: D100673963
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add
isInitialized()virtual method toTorchCommBackendso callers can check whether a backend is ready for collective operations before issuing them. The MCCL implementation now correctly ties initialization state to a successfulreconfigure()result rather than unconditionally marking itself initialized, preventing use of a backend whose reconfigure failed.Specifically, we now set
initState_ = UNINITIALIZEDbefore callingmccl_comm_->reconfigure(), then only promote toINITIALIZEDinside the existing success block (whereresult->code == commSuccess) alongsiderank_andcommSize_updates. PreviouslyinitState_ = INITIALIZEDwas set unconditionally aftercreateWork(), which allowed subsequent operations to proceed on a broken communicator after a failed reconfigure.Differential Revision: D100673963