Skip to content
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 FutureNCCL's completed() disagreeing with wait() #48503

Closed
wants to merge 9 commits into from
9 changes: 1 addition & 8 deletions torch/lib/c10d/ProcessGroupNCCL.hpp
Expand Up @@ -339,15 +339,8 @@ class ProcessGroupNCCL : public ProcessGroup {
return fut;
}

// Checks cudaEventQuery with cudaEvents. Returns true if a FutureError was
// recorded or the entire operation is completed on the GPU.
bool completed() const override {
if (error_) {
return true;
}
// Checking the work's corresponding CUDA events' status
auto ret = cudaEventQuery((*cudaEvents_)[0]);
return ret != cudaErrorNotReady || ret == cudaSuccess;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no regression here, and I agree that user code won't trigger any problem. But C++ code can still use the second ctor of FutureNCCL to create an empty future without marking it as completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct. As I mentioned earlier, the second constructor is "meant" to be private and only invoked by then(). If you want we can make that explicit. However, in #48505 we'll fix this issue for good by having FutureNCCL share the same logic as ivalue::Future (and thus have a real complete-vs-incomplete status).

}

bool hasValue() const override {
Expand Down