Repository navigation
[Common] CGEMM stream ID logging #3727
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
Open
jberchtold-nvidia
wants to merge
6
commits into
NVIDIA:main
Choose a base branch
from
jberchtold-nvidia:jberchtold/cgemm-stream-id-logging
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e35b4bc
CGEMM Stream ID logging
jberchtold-nvidia 4383a83
Document collective GEMM stream ID logging
jberchtold-nvidia 82ce4c7
Isolate collective GEMM stream logging test
jberchtold-nvidia fe9222e
Fix collective GEMM test copyright header
jberchtold-nvidia 63225a2
Link collective GEMM stream logging test against Python
jberchtold-nvidia 6131e85
Merge branch 'main' into jberchtold/cgemm-stream-id-logging
jberchtold-nvidia 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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /************************************************************************* | ||
| * Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * | ||
| * See LICENSE for license information. | ||
| ************************************************************************/ | ||
|
|
||
| #include <cuda_runtime.h> | ||
| #include <gtest/gtest.h> | ||
| #include <mpi.h> | ||
| #include <nccl.h> | ||
| #include <transformer_engine/comm_gemm.h> | ||
|
|
||
| #include <cstdlib> | ||
| #include <string> | ||
|
|
||
| #define CHECK_MPI(expr) \ | ||
| do { \ | ||
| int err = (expr); \ | ||
| if (err != MPI_SUCCESS) { \ | ||
| char err_str[MPI_MAX_ERROR_STRING + 1]{}; \ | ||
| int len{}; \ | ||
| MPI_Error_string(err, err_str, &len); \ | ||
| EXPECT_TRUE(false) << "MPI error: " << err << ": " << err_str; \ | ||
| } \ | ||
| } while (false) | ||
|
|
||
| #define CHECK_NCCL(expr) \ | ||
| do { \ | ||
| ncclResult_t err = (expr); \ | ||
| if (err != ncclSuccess) { \ | ||
| EXPECT_TRUE(false) << "NCCL error: " << err << ": " << ncclGetErrorString(err); \ | ||
| } \ | ||
| } while (false) | ||
|
|
||
| int main(int argc, char* argv[]) { | ||
| ::testing::InitGoogleTest(&argc, argv); | ||
| CHECK_MPI(MPI_Init(&argc, &argv)); | ||
| auto ret = RUN_ALL_TESTS(); | ||
| CHECK_MPI(MPI_Finalize()); | ||
| return ret; | ||
| } | ||
|
|
||
| TEST(CommGemmStreamLogging, LogsStreamIdToStdout) { | ||
| int nranks{}; | ||
| int rank{}; | ||
| CHECK_MPI(MPI_Comm_size(MPI_COMM_WORLD, &nranks)); | ||
| CHECK_MPI(MPI_Comm_rank(MPI_COMM_WORLD, &rank)); | ||
| ASSERT_EQ(cudaSetDevice(rank), cudaSuccess); | ||
|
|
||
| ncclUniqueId id{}; | ||
| if (rank == 0) CHECK_NCCL(ncclGetUniqueId(&id)); | ||
| CHECK_MPI(MPI_Bcast(&id, sizeof(id), MPI_BYTE, 0, MPI_COMM_WORLD)); | ||
|
|
||
| ncclComm_t comm{}; | ||
| CHECK_NCCL(ncclCommInitRank(&comm, nranks, id, rank)); | ||
| ASSERT_EQ(setenv("NVTE_LOG_COLLECTIVE_GEMM_STREAM_IDS", "1", 1), 0); | ||
|
|
||
| testing::internal::CaptureStdout(); | ||
| NVTECommGemmCtx* ctx = nvte_comm_gemm_ctx_create(comm, nranks, rank); | ||
| const std::string output = testing::internal::GetCapturedStdout(); | ||
|
|
||
| const std::string prefix = | ||
| "NVTE collective GEMM stream ID (rank " + std::to_string(rank) + "): "; | ||
| EXPECT_NE(output.find(prefix), std::string::npos) << "Captured stdout: " << output; | ||
|
|
||
| nvte_comm_gemm_ctx_destroy(ctx); | ||
| CHECK_NCCL(ncclCommDestroy(comm)); | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test calls
nvte_comm_gemm_ctx_createwithout checkingnvte_built_with_cublasmp(). WithNVTE_WITH_CUBLASMPdisabled—the default—the call throws instead of skipping. The QA script launches this test whenever four GPUs are available, so builds without cuBLASMp now fail this suite.Add the same early skip used by
test_comm_gemm.cu, before creating the NCCL communicator.