Repository navigation
[RCCL][test] Fix illegal MPI_Cancel on Ibarrier in MPIEnvironment tea… #9322
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
Merged
JhaShweta1
merged 1 commit into
users/corey-derochie-amd/aicomrccl-1281-sync-nccl-2.30.7
from
users/shwetjha/test_harness_fix
Jul 27, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| #ifdef MPI_TESTS_ENABLED | ||
|
|
||
| #include <chrono> | ||
| #include <cstdlib> | ||
| #include <thread> | ||
|
|
||
| /** | ||
|
|
@@ -237,12 +238,22 @@ void MPIEnvironment::TearDown() | |
| if(barrier_result == MPI_SUCCESS) | ||
| { | ||
| // Wait for barrier with a timeout. | ||
| // 3 s: ncclCommDestroy is now explicitly called (and MPI-barrier'd) inside | ||
| // cleanupTestCommunicator before TearDown runs, so the only remaining rank | ||
| // skew here is log-file I/O (RCCL_MPI_LOG_ALL_RANKS) which is fast. | ||
| int flag = 0; | ||
| auto timeout_start = std::chrono::steady_clock::now(); | ||
| const auto timeout_duration = std::chrono::seconds(3); | ||
| // ncclCommDestroy is now explicitly called (and MPI-barrier'd) inside | ||
| // cleanupTestCommunicator before TearDown runs, so the common remaining rank | ||
| // skew here is log-file I/O (RCCL_MPI_LOG_ALL_RANKS). However, heavy | ||
| // multi-phase tests (e.g. GrowMPITest, NetIbMPITest CtsDepthStress) can have | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we see failures in these tests without this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes: GrowMPITest, NetIbMPITest are passing now. |
||
| // ranks reach TearDown more than a few seconds apart even on success, so a | ||
| // 3 s timeout produced false "out of sync" aborts. Use a more tolerant default | ||
| // and allow override via RCCL_TEST_TEARDOWN_TIMEOUT_SEC. | ||
| int flag = 0; | ||
| auto timeout_start = std::chrono::steady_clock::now(); | ||
| int timeout_sec = 60; | ||
| if(const char* env = std::getenv("RCCL_TEST_TEARDOWN_TIMEOUT_SEC")) | ||
| { | ||
| int v = std::atoi(env); | ||
| if(v > 0) timeout_sec = v; | ||
| } | ||
| const auto timeout_duration = std::chrono::seconds(timeout_sec); | ||
|
|
||
| while(!flag) | ||
| { | ||
|
|
@@ -254,18 +265,21 @@ void MPIEnvironment::TearDown() | |
| auto elapsed = std::chrono::steady_clock::now() - timeout_start; | ||
| if(elapsed > timeout_duration) | ||
| { | ||
| // Timeout - ranks are out of sync! | ||
| // Timeout - ranks are genuinely out of sync (e.g. a rank died or | ||
| // deadlocked in the test body). Force abort. | ||
| std::fprintf( | ||
| stderr, | ||
| "Rank %d: TIMEOUT in TearDown barrier - ranks out of sync, forcing abort\n", | ||
| world_rank); | ||
| "Rank %d: TIMEOUT (%ds) in TearDown barrier - ranks out of sync, forcing abort\n", | ||
| world_rank, | ||
| timeout_sec); | ||
| std::fflush(stderr); | ||
|
|
||
| // Cancel the barrier request | ||
| MPI_Cancel(&barrier_req); | ||
| MPI_Request_free(&barrier_req); | ||
|
|
||
| // Force abort - can't safely continue | ||
| // NOTE: Do NOT MPI_Cancel(&barrier_req) here. Cancelling a | ||
| // nonblocking *collective* request (MPI_Ibarrier) is forbidden by | ||
| // the MPI standard; OpenMPI returns MPI_ERR_REQUEST, and because | ||
| // MPI_COMM_WORLD uses MPI_ERRORS_ARE_FATAL that call aborts the job | ||
| // itself with a misleading error before we reach MPI_Abort. Since | ||
| // MPI_Abort tears the whole job down anyway, just call it directly. | ||
| MPI_Abort(MPI_COMM_WORLD, 1); | ||
| return; | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.