Skip to content

Commit

Permalink
[kineto] populate src/dst rank for p2p (pytorch#130812)
Browse files Browse the repository at this point in the history
Summary:
as title
populate src/dst rank (global rank) for p2p kernel

Differential Revision: D59794535

Pull Request resolved: pytorch#130812
Approved by: https://github.com/aaronenyeshi
  • Loading branch information
shengbao-zheng authored and pytorchmergebot committed Jul 25, 2024
1 parent 1c58aac commit 89bdd9c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion third_party/kineto
14 changes: 12 additions & 2 deletions torch/csrc/profiler/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ std::unordered_map<std::string, std::string> saveNcclMeta(
return map;
}

map.emplace(
kCommsName, fmt::format("\"{}\"", debugInfo->getCollectiveName()));
auto& collective_name = debugInfo->getCollectiveName();
map.emplace(kCommsName, fmt::format("\"{}\"", collective_name));
map.emplace(
kDtype, fmt::format("\"{}\"", c10::toString(debugInfo->getDType())));
map.emplace(kInMsgNelems, std::to_string(debugInfo->getInMessageNelems()));
Expand Down Expand Up @@ -411,6 +411,16 @@ std::unordered_map<std::string, std::string> saveNcclMeta(

auto rank = debugInfo->getRank();
map.emplace(kRank, std::to_string(rank));
int nRanks = static_cast<int>(groupRanks.size());
if (collective_name == "send") {
if (rank >= 0 && rank < nRanks) {
map.emplace(kP2pDst, std::to_string(groupRanks[rank]));
}
} else if (collective_name == "recv") {
if (rank >= 0 && rank < nRanks) {
map.emplace(kP2pSrc, std::to_string(groupRanks[rank]));
}
}
#endif // USE_DISTRIBUTED
return map;
}
Expand Down
2 changes: 2 additions & 0 deletions torch/csrc/profiler/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ constexpr auto kProcessGroupName = "Process Group Name";
constexpr auto kProcessGroupDesc = "Process Group Description";
constexpr auto kGroupRanks = "Process Group Ranks";
constexpr auto kRank = "Rank";
constexpr auto kP2pSrc = "Src Rank";
constexpr auto kP2pDst = "Dst Rank";
#endif // USE_DISTRIBUTED

} // namespace torch::profiler::impl

0 comments on commit 89bdd9c

Please sign in to comment.