fix case where a given tensor has not been computed

This commit is contained in:
Scott Cutler
2026-04-23 19:15:08 -07:00
parent 2573b7b379
commit 4d7736c761

View File

@@ -548,10 +548,17 @@ bool ggml_cuda_ar_allreduce(
ggml_cuda_set_device(p->devices[i]);
auto * cuda_ctx = static_cast<ggml_backend_cuda_context *>(backends[i]->context);
ggml_cuda_ar_event_slot & ev = p->ev_pool[i][slot];
const bool compute = (tensors[i]->flags & GGML_TENSOR_FLAG_COMPUTE) != 0;
CUDA_CHECK(cudaEventRecord(ev.app, cuda_ctx->stream()));
CUDA_CHECK(cudaStreamWaitEvent(p->streams[i], ev.app));
// Match the NCCL and meta-backend semantics: inactive shards
// contribute zeros to the reduction.
if (!compute) {
CUDA_CHECK(cudaMemsetAsync(tensors[i]->data, 0, bytes, p->streams[i]));
}
#if GGML_CUDA_AR_WATCHDOG
#define GGML_CUDA_AR_WDOG_EXTRA_ARGS , p->debug_ring[i], p->wdog_max_spin, i, slot
#else