MSCCL Multithreaded regression root cause fix (#1347)

* Make sure the target device is used for MSCCL

* Enable single process mode by default to use MSCCL in MT

* Create a per-rank state when GPUs share a thread

[ROCm/rccl commit: 03a3ef3c34]
Этот коммит содержится в:
Mustafa Abduljabbar
2024-09-25 15:24:25 -04:00
коммит произвёл GitHub
родитель 21a3b242bf
Коммит ef6d75b3ee
3 изменённых файлов: 15 добавлений и 5 удалений
+1 -1
Просмотреть файл
@@ -28,7 +28,7 @@
RCCL_PARAM(MscclEnabled, "MSCCL_ENABLE", 1);
RCCL_PARAM(MscclForceEnabled, "MSCCL_FORCE_ENABLE", 0);
RCCL_PARAM(MscclEnableSingleProcess, "MSCCL_ENABLE_SINGLE_PROCESS", 0);
RCCL_PARAM(MscclEnableSingleProcess, "MSCCL_ENABLE_SINGLE_PROCESS", 1);
static const char* mscclAlgoFilePathEnv = "MSCCL_ALGO_FILE_PATH";
bool mscclEnabled() {
+6 -4
Просмотреть файл
@@ -27,9 +27,9 @@ static mutex rankStatesMutex;
static unordered_map<int, shared_ptr<mscclRankState>> rankStates;
static inline mscclRankState& mscclGetRankState(int rank) {
static thread_local shared_ptr<mscclRankState> threadRankState = make_shared<mscclRankState>();
// In the unlikely case of negative rank, return a per-thread state
if (rank < 0) {
static thread_local shared_ptr<mscclRankState> threadRankState(new mscclRankState());
return *threadRankState;
}
@@ -37,8 +37,10 @@ static inline mscclRankState& mscclGetRankState(int rank) {
auto rankStateIt = rankStates.find(rank);
if (rankStateIt == rankStates.end()) {
rankStateIt = rankStates.insert(make_pair(rank, make_shared<mscclRankState>(*threadRankState))).first;
rankStateIt->second->rank = rank;
// Create a per rank threadRankState rather than per thread
shared_ptr<mscclRankState> newthreadRankState(new mscclRankState());
newthreadRankState->rank = rank;
rankStateIt = rankStates.insert(make_pair(rank, newthreadRankState)).first;
}
return *(rankStateIt->second);
}