Repository navigation
perf(rccl): tune gfx950 2-node AllReduce, AllGather and ReduceScatter #14722
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
aduforest
wants to merge
2
commits into
develop
Choose a base branch
from
users/aduforest/intellitune-gfx950-2n-allreduce-row
base: develop
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
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| #include <cstdio> | ||
| #include <cstdlib> | ||
| #include <cstring> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <vector> | ||
| #include <sys/stat.h> | ||
|
|
@@ -152,6 +153,32 @@ class CsvTunerMicrotest : public ::testing::Test { | |
| ctx->configs = nullptr; | ||
| } | ||
|
|
||
| static void ExpectTuning(void* context, ncclFunc_t collective, size_t bytes, int pipeOps, int regBuff, | ||
| int expectedAlgorithm, int expectedProtocol, int expectedChannels, | ||
| int ignoredAlgorithm = -1, int ignoredProtocol = -1) { | ||
| SCOPED_TRACE(::testing::Message() << "collective=" << collective << " bytes=" << bytes | ||
| << " pipeOps=" << pipeOps << " regBuff=" << regBuff); | ||
| float table[NCCL_NUM_ALGORITHMS][NCCL_NUM_PROTOCOLS]; | ||
| for (auto& row : table) { | ||
| for (float& cost : row) cost = 1.0f; | ||
| } | ||
| if (ignoredAlgorithm >= 0) table[ignoredAlgorithm][ignoredProtocol] = NCCL_ALGO_PROTO_IGNORE; | ||
|
|
||
| int channels = -1; | ||
| ASSERT_EQ(ncclSuccess, csvTunerGetCollInfo(context, collective, bytes, pipeOps, (float**)table, | ||
| NCCL_NUM_ALGORITHMS, NCCL_NUM_PROTOCOLS, regBuff, &channels)); | ||
| EXPECT_EQ(expectedChannels, channels); | ||
| for (int algorithm = 0; algorithm < NCCL_NUM_ALGORITHMS; algorithm++) { | ||
| for (int protocol = 0; protocol < NCCL_NUM_PROTOCOLS; protocol++) { | ||
| const float expected = algorithm == ignoredAlgorithm && protocol == ignoredProtocol | ||
| ? NCCL_ALGO_PROTO_IGNORE | ||
| : algorithm == expectedAlgorithm && protocol == expectedProtocol ? 0.0f : 1.0f; | ||
| EXPECT_FLOAT_EQ(expected, table[algorithm][protocol]) | ||
| << "algorithm=" << algorithm << " protocol=" << protocol; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Field-wise, not memcmp: the structs come from malloc, so their padding | ||
| // bytes are whatever the allocator last left there. | ||
| static void ExpectSameConfig(const CsvTuningConfig& a, const CsvTuningConfig& b, const std::string& what) { | ||
|
|
@@ -227,6 +254,103 @@ TEST_F(CsvTunerMicrotest, EmbeddedAndFileParseIdentically) { | |
| } | ||
| } | ||
|
|
||
| TEST_F(CsvTunerMicrotest, EveryEmbeddedDataRowIsParsed) { | ||
| const auto& embedded = rcclCsvTunerEmbeddedConfigs(); | ||
| ASSERT_FALSE(embedded.empty()); | ||
| for (const auto& entry : embedded) { | ||
| std::istringstream contents(entry.second); | ||
| std::string line; | ||
| int dataRows = 0; | ||
| while (std::getline(contents, line)) { | ||
| const size_t first = line.find_first_not_of(" \t\r"); | ||
| if (first != std::string::npos && line[first] != '#') dataRows++; | ||
| } | ||
| CsvTunerContext context = MakeContext(16, 2); | ||
| ASSERT_EQ(ncclSuccess, loadConfigFromBuffer(&context, entry.second.c_str(), entry.first.c_str())); | ||
| EXPECT_EQ(dataRows, context.numConfigs) << entry.first; | ||
| FreeContext(&context); | ||
| } | ||
| } | ||
|
|
||
| TEST_F(CsvTunerMicrotest, Gfx950TwoNodeTuningBoundariesAndTopology) { | ||
| const char* source = rcclCsvTunerFindConfig("gfx950"); | ||
| ASSERT_NE(nullptr, source); | ||
| ASSERT_STREQ("<embedded>/rccl_tuner_gfx950.csv", source); | ||
| struct Probe { | ||
| ncclFunc_t collective; | ||
| size_t bytes; | ||
| int algorithm; | ||
| int protocol; | ||
| int channels; | ||
| }; | ||
| const Probe probes[] = { | ||
| {ncclFuncAllReduce, 16777215, -1, -1, 0}, | ||
| {ncclFuncAllReduce, 16777216, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 33554431, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 33554432, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 54525951, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 54525952, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 117440511, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 117440512, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 150994943, NCCL_ALGO_TREE, NCCL_PROTO_LL128, 64}, | ||
| {ncclFuncAllReduce, 150994944, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 48}, | ||
| {ncclFuncAllReduce, 234881024, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 48}, | ||
| {ncclFuncAllReduce, 234881025, -1, -1, 0}, | ||
| {ncclFuncAllGather, 150994943, -1, -1, 0}, | ||
| {ncclFuncAllGather, 150994944, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 48}, | ||
| {ncclFuncAllGather, 234881023, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 48}, | ||
| {ncclFuncAllGather, 234881024, -1, -1, 0}, | ||
| {ncclFuncReduceScatter, 142606335, -1, -1, 0}, | ||
| {ncclFuncReduceScatter, 142606336, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 32}, | ||
| {ncclFuncReduceScatter, 176160767, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 32}, | ||
| {ncclFuncReduceScatter, 176160768, -1, -1, 0}, | ||
| {ncclFuncBroadcast, 16777216, -1, -1, 0}, | ||
| {ncclFuncReduce, 16777216, -1, -1, 0}, | ||
| }; | ||
| struct Topology { | ||
| size_t ranks; | ||
| size_t nodes; | ||
| }; | ||
| const Topology topologies[] = {{16, 2}, {8, 1}, {16, 1}, {8, 2}, {32, 2}, {16, 4}}; | ||
| for (const auto& topology : topologies) { | ||
| SCOPED_TRACE(::testing::Message() << "ranks=" << topology.ranks << " nodes=" << topology.nodes); | ||
| void* context = nullptr; | ||
| ASSERT_EQ(ncclSuccess, csvTunerInit(&context, 0, topology.ranks, topology.nodes, nullptr, nullptr, nullptr)); | ||
| ASSERT_NE(nullptr, context); | ||
| const bool matches = topology.ranks == 16 && topology.nodes == 2; | ||
| for (const auto& probe : probes) { | ||
| for (int pipeOps : {1, 4}) { | ||
| for (int regBuff : {0, 1, 2}) { | ||
| ExpectTuning(context, probe.collective, probe.bytes, pipeOps, regBuff, | ||
| matches ? probe.algorithm : -1, matches ? probe.protocol : -1, | ||
| matches ? probe.channels : 0); | ||
| } | ||
| } | ||
| } | ||
| EXPECT_EQ(ncclSuccess, csvTunerFinalize(context)); | ||
| } | ||
| } | ||
|
|
||
| TEST_F(CsvTunerMicrotest, Gfx950TwoNodeTuningPreservesUnavailableProtocolFallbacks) { | ||
| ASSERT_NE(nullptr, rcclCsvTunerFindConfig("gfx950")); | ||
| void* context = nullptr; | ||
| ASSERT_EQ(ncclSuccess, csvTunerInit(&context, 0, 16, 2, nullptr, nullptr, nullptr)); | ||
| ASSERT_NE(nullptr, context); | ||
| ExpectTuning(context, ncclFuncAllReduce, 16777216, 1, 0, -1, -1, 0, | ||
| NCCL_ALGO_TREE, NCCL_PROTO_LL128); | ||
| ExpectTuning(context, ncclFuncAllReduce, 33554432, 1, 0, NCCL_ALGO_RING, NCCL_PROTO_LL128, 64, | ||
| NCCL_ALGO_TREE, NCCL_PROTO_LL128); | ||
| ExpectTuning(context, ncclFuncAllReduce, 54525952, 1, 0, NCCL_ALGO_TREE, NCCL_PROTO_SIMPLE, 64, | ||
| NCCL_ALGO_TREE, NCCL_PROTO_LL128); | ||
| ExpectTuning(context, ncclFuncAllReduce, 117440512, 1, 0, NCCL_ALGO_RING, NCCL_PROTO_SIMPLE, 48, | ||
| NCCL_ALGO_TREE, NCCL_PROTO_LL128); | ||
| ExpectTuning(context, ncclFuncAllGather, 150994944, 1, 0, -1, -1, 0, | ||
| NCCL_ALGO_RING, NCCL_PROTO_SIMPLE); | ||
| ExpectTuning(context, ncclFuncReduceScatter, 142606336, 1, 0, -1, -1, 0, | ||
| NCCL_ALGO_RING, NCCL_PROTO_SIMPLE); | ||
| EXPECT_EQ(ncclSuccess, csvTunerFinalize(context)); | ||
|
Comment on lines
+335
to
+351
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. Same suggestion as above. |
||
| } | ||
|
|
||
| TEST_F(CsvTunerMicrotest, ResolvesArchSpecificEmbeddedConfig) { | ||
| const std::string arch = FirstEmbeddedArch(); | ||
| if (arch.empty()) GTEST_SKIP() << "no arch-specific config embedded"; | ||
|
|
||
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.
I feel the test should test the functionality without being prescriptive to the exact content. Every time the tuning changes, this test will need to (or we will want it to) change, when really we just want to ensure it always parses an arbitrary file correctly.
Recommend crafting a test-specific CSV along with specific probes that exercises the various functionality, and redirect to it from this test.