| 214 | } |
| 215 | |
| 216 | void releaseParam(long ds_id, long n_users) |
| 217 | { |
| 218 | const DSParam& param = param_registry_->getParam(ds_id); |
| 219 | |
| 220 | assert(hasKey(param_use_count_, ds_id)); |
| 221 | if (param_use_count_[ds_id] == 0) { param_use_count_[ds_id] = n_users; } |
| 222 | param_use_count_[ds_id]--; |
| 223 | |
| 224 | if (param_use_count_[ds_id] == 0 && !param.isPersistent()) { |
| 225 | at::Tensor gathered_param = param_registry_->getGatheredParam(ds_id); |
| 226 | |
| 227 | if (gathered_param.defined()) { // gathered param is undefined while profiling |
| 228 | auto storage = gathered_param.storage(); |
| 229 | if (storage.nbytes() > 0) { |
| 230 | // Required so the caching allocator defers reuse for consumer-stream kernels |
| 231 | // queued behind wait_allgather. |
| 232 | gathered_param.record_stream(at::cuda::getCurrentCUDAStream()); |
| 233 | at::native::resize_bytes_cuda(storage.unsafeGetStorageImpl(), 0); |
| 234 | } |
| 235 | |
| 236 | const auto options = gathered_param.options(); |
| 237 | at::Tensor empty_buffer = torch::empty({0}, options); |
| 238 | gathered_param.set_data(empty_buffer); |
| 239 | } |
| 240 | |
| 241 | param_registry_->unregisterGatheredParam(ds_id); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | at::Tensor waitAllgather(at::Tensor v, long ds_id) |
| 246 | { |
no test coverage detected