@@ -13,8 +13,6 @@ int GetEnvAsInt(const std::string &name, int default_value) {
1313 return value ? std::atoi (value) : default_value;
1414}
1515
16- bool HasEnv (const std::string &name) { return std::getenv (name.c_str ()) != nullptr ; }
17-
1816} // namespace
1917
2018namespace infini_train ::nn::parallel::global {
@@ -94,21 +92,15 @@ void GlobalEnv::Init(int nthread_per_process, int tensor_parallel_size, bool seq
9492
9593 CHECK (!initialized_) << " Repeated initialization of GlobalEnv!" ;
9694
97- const int proc_world_size = GetEnvAsInt (" PROC_WORLD_SIZE " , GetEnvAsInt (" WORLD_SIZE " , 1 ));
98- nproc_per_node_ = GetEnvAsInt (" NPROC_PER_NODE " , GetEnvAsInt (" LOCAL_WORLD_SIZE " , 1 ));
95+ const int proc_world_size = GetEnvAsInt (" WORLD_SIZE " , GetEnvAsInt (" PROC_WORLD_SIZE " , 1 ));
96+ nproc_per_node_ = GetEnvAsInt (" LOCAL_WORLD_SIZE " , GetEnvAsInt (" NPROC_PER_NODE " , 1 ));
9997 CHECK_GT (nproc_per_node_, 0 ) << " NPROC_PER_NODE/LOCAL_WORLD_SIZE must be positive" ;
10098 CHECK_GT (proc_world_size, 0 ) << " PROC_WORLD_SIZE/WORLD_SIZE must be positive" ;
10199 CHECK_EQ (proc_world_size % nproc_per_node_, 0 )
102100 << " PROC_WORLD_SIZE/WORLD_SIZE must be divisible by NPROC_PER_NODE/LOCAL_WORLD_SIZE" ;
103- const bool nnodes_env_set = HasEnv (" NNODES" );
104- nnodes_ = GetEnvAsInt (" NNODES" , proc_world_size / nproc_per_node_);
105- CHECK_GT (nnodes_, 0 ) << " NNODES must be positive" ;
106- if (nnodes_env_set) {
107- CHECK_EQ (nnodes_ * nproc_per_node_, proc_world_size)
108- << " NNODES * NPROC_PER_NODE/LOCAL_WORLD_SIZE must equal PROC_WORLD_SIZE/WORLD_SIZE" ;
109- }
110- global_proc_rank_ = GetEnvAsInt (" GLOBAL_PROC_RANK" , GetEnvAsInt (" RANK" , 0 ));
111- local_proc_rank_ = GetEnvAsInt (" LOCAL_PROC_RANK" , GetEnvAsInt (" LOCAL_RANK" , 0 ));
101+ nnodes_ = proc_world_size / nproc_per_node_;
102+ global_proc_rank_ = GetEnvAsInt (" RANK" , GetEnvAsInt (" GLOBAL_PROC_RANK" , 0 ));
103+ local_proc_rank_ = GetEnvAsInt (" LOCAL_RANK" , GetEnvAsInt (" LOCAL_PROC_RANK" , 0 ));
112104 CHECK_GE (global_proc_rank_, 0 ) << " GLOBAL_PROC_RANK/RANK must be non-negative" ;
113105 CHECK_LT (global_proc_rank_, proc_world_size)
114106 << " GLOBAL_PROC_RANK/RANK must be less than PROC_WORLD_SIZE/WORLD_SIZE" ;
0 commit comments