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

Add timeout for distributed tests. #10315

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/collective/coll.cu
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Result BroadcastAllgatherV(NCCLComm const* comm, common::Span<std::int8_t const>
for (std::int32_t r = 0; r < comm->World(); ++r) {
auto as_bytes = sizes[r];
auto rc = stub->Broadcast(data.data(), recv.subspan(offset, as_bytes).data(), as_bytes,
ncclInt8, r, comm->Handle(), dh::DefaultStream());
ncclInt8, r, comm->Handle(), comm->Stream());
if (!rc.OK()) {
return rc;
}
Expand Down
20 changes: 13 additions & 7 deletions tests/cpp/collective/test_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ inline auto MakeDistributedTestConfig(std::string host, std::int32_t port,
}

template <typename WorkerFn>
void TestDistributedGlobal(std::int32_t n_workers, WorkerFn worker_fn, bool need_finalize = true) {
void TestDistributedGlobal(std::int32_t n_workers, WorkerFn worker_fn, bool need_finalize = true,
std::chrono::seconds test_timeout = std::chrono::seconds{30}) {
system::SocketStartup();
std::chrono::seconds timeout{1};

Expand All @@ -163,12 +164,17 @@ void TestDistributedGlobal(std::int32_t n_workers, WorkerFn worker_fn, bool need

for (std::int32_t i = 0; i < n_workers; ++i) {
workers.emplace_back([=] {
auto config = MakeDistributedTestConfig(host, port, timeout, i);
Init(config);
worker_fn();
if (need_finalize) {
Finalize();
}
auto fut = std::async(std::launch::async, [=] {
auto config = MakeDistributedTestConfig(host, port, timeout, i);
Init(config);
worker_fn();
if (need_finalize) {
Finalize();
}
});
auto status = fut.wait_for(test_timeout);
CHECK(status == std::future_status::ready) << "Test timeout";
fut.get();
});
}

Expand Down
Loading