MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / init

Function init

csrc/compile/deepcompile.cpp:142–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142void init(c10::intrusive_ptr<c10d::ProcessGroup> pg,
143 pybind11::object& config,
144 int64_t initial_reduce_bucket_size)
145{
146 process_group = pg;
147
148 ncclUniqueId ncclID;
149 ncclGetUniqueId(&ncclID);
150
151 // ProcessGroup doesn't have an API to get the CUDA stream for comm calls.
152 // So we create a NCCL communicator and call NCCL APIs directly.
153 auto vec = std::vector<uint8_t>(reinterpret_cast<uint8_t*>(&ncclID),
154 reinterpret_cast<uint8_t*>(&ncclID) + NCCL_UNIQUE_ID_BYTES);
155 auto device = torch::Device(torch::kCUDA);
156 at::Tensor tensor = torch::from_blob(vec.data(), {static_cast<long>(vec.size())}, torch::kUInt8)
157 .to(torch::Device(torch::kCUDA));
158 std::vector<at::Tensor> bcast_input = {tensor};
159
160 process_group->broadcast(bcast_input, c10d::BroadcastOptions())->wait();
161
162 // create a new nccl communicator
163 std::memcpy(&ncclID, tensor.to(torch::Device(torch::kCPU)).data_ptr(), NCCL_UNIQUE_ID_BYTES);
164 ncclCommInitRank(&nccl_comm, process_group->getSize(), ncclID, process_group->getRank());
165 nccl_comm_initialized = true;
166
167 param_registry = std::make_shared<DSParamRegistry>();
168 reduce_buckets = std::make_shared<DoubleBufferedReduceBucket>(
169 initial_reduce_bucket_size, get_config<bool>(config, "double_buffer"));
170 use_symm_mem = get_config<bool>(config, "symmetric_memory");
171 free_activation_threshold = get_config<int64_t>(config, "free_activation_threshold");
172
173 sync_before_reduce = get_config<bool>(config, "sync_before_reduce");
174 sync_after_reduce = get_config<bool>(config, "sync_after_reduce");
175 sync_before_allgather = get_config<bool>(config, "sync_before_allgather");
176 sync_after_allgather = get_config<bool>(config, "sync_after_allgather");
177 offload_activation_pin_memory = get_config<bool>(config, "offload_activation_pin_memory");
178}
179
180void start_forward()
181{

Callers

nothing calls this directly

Calls 7

dataMethod · 0.80
getSizeMethod · 0.80
toMethod · 0.45
sizeMethod · 0.45
waitMethod · 0.45
broadcastMethod · 0.45
data_ptrMethod · 0.45

Tested by

no test coverage detected