Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Check the device count only after the GPU topology reduction
If cudaGetDeviceCount fails on one rank, RAFT_CUDA_TRY throws before that
rank reaches the MPI_Allreduce in MPIEnvironment::SetUp, and the other
ranks block in the reduction. Count a failed query as an unusable
topology, and raise the CUDA error only after every rank has finished the
reduction.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
  • Loading branch information
0z5a committed Nov 8, 2026
commit 5fac2a8dadf6594ec48f7e0d97dc81559327c235
13 changes: 8 additions & 5 deletions cpp/tests/mg/test_opg_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@ class MPIEnvironment : public ::testing::Environment {
int local_rank, local_size;
get_node_local_rank_size(local_rank, local_size);

int nGpus;
RAFT_CUDA_TRY(cudaGetDeviceCount(&nGpus));
int nGpus = 0;
cudaError_t const device_count_status = cudaGetDeviceCount(&nGpus);

// A rank that leaves SetUp while the others enter a collective leaves the whole job
// hanging, so every rank has to agree on whether the topology can be used.
int insufficient_local_gpus = nGpus < local_size ? 1 : 0;
int insufficient_gpus = 0;
// hanging, so every rank has to agree on whether the topology can be used. A failed
// device query counts as unusable too, and is only raised after the reduction.
int insufficient_local_gpus =
(device_count_status != cudaSuccess || nGpus < local_size) ? 1 : 0;
int insufficient_gpus = 0;
MPI_Allreduce(
&insufficient_local_gpus, &insufficient_gpus, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

RAFT_CUDA_TRY(device_count_status);
ASSERT(!insufficient_gpus,
"Number of GPUs are lesser than local MPI ranks! ngpus=%d, local_ranks=%d",
nGpus,
Expand Down
Loading