diff --git a/ggml/src/ggml-cuda/allreduce.cu b/ggml/src/ggml-cuda/allreduce.cu index c1df8d8d2c..270a3d0e7f 100644 --- a/ggml/src/ggml-cuda/allreduce.cu +++ b/ggml/src/ggml-cuda/allreduce.cu @@ -322,8 +322,11 @@ static void ggml_cuda_ar_wdog_thread(ggml_cuda_ar_pipeline * p) { // --------------------------------------------------------------------------- ggml_cuda_ar_pipeline * ggml_cuda_ar_pipeline_init( - const int * devices, int n_devices, size_t max_bytes) { - GGML_ASSERT(n_devices >= 2 && n_devices <= GGML_CUDA_MAX_DEVICES); + const int * devices, size_t n_devices, size_t max_bytes) { + + if ((n_devices != 2) || (n_devices > GGML_CUDA_MAX_DEVICES)) { + return nullptr; + } auto * p = new ggml_cuda_ar_pipeline{}; p->n_devices = n_devices; diff --git a/ggml/src/ggml-cuda/allreduce.cuh b/ggml/src/ggml-cuda/allreduce.cuh index 4c2be43962..a30a4f8c28 100644 --- a/ggml/src/ggml-cuda/allreduce.cuh +++ b/ggml/src/ggml-cuda/allreduce.cuh @@ -18,7 +18,7 @@ struct ggml_cuda_ar_pipeline; // as the largest tensor that will be reduced. // Returns nullptr on allocation failure. ggml_cuda_ar_pipeline * ggml_cuda_ar_pipeline_init( - const int * devices, int n_devices, size_t max_bytes); + const int * devices, size_t n_devices, size_t max_bytes); // Release all resources owned by the pipeline. void ggml_cuda_ar_pipeline_free(ggml_cuda_ar_pipeline * pipeline); diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cu index 9a4dd062aa..498679daa6 100644 --- a/ggml/src/ggml-cuda/ggml-cuda.cu +++ b/ggml/src/ggml-cuda/ggml-cuda.cu @@ -1234,7 +1234,7 @@ static void * ggml_backend_cuda_comm_init(ggml_backend_t * backends, size_t n_ba if (provider == GGML_CUDA_ALLREDUCE_INTERNAL) { ret->ar_pipeline = ggml_cuda_ar_pipeline_init( - dev_ids.data(), static_cast(n_backends), GGML_CUDA_AR_MAX_BYTES); + dev_ids.data(), n_backends, GGML_CUDA_AR_MAX_BYTES); if (ret->ar_pipeline != nullptr) { return ret; } @@ -1388,13 +1388,15 @@ static ggml_cuda_comm_allreduce_result ggml_backend_cuda_comm_try_allreduce_inte return GGML_CUDA_COMM_ALLREDUCE_FAILED; } if (!ggml_is_contiguously_allocated(tensors[i])) { - GGML_LOG_WARN("%s: internal tensor[%zu] is not contiguously allocated: ne=%" PRId64 " nbytes=%zu packed=%zu type=%d\n", + GGML_LOG_WARN("%s: internal unsupported: tensor[%zu] is not contiguously allocated: ne=%" PRId64 " nbytes=%zu packed=%zu type=%d\n", __func__, i, ne, ggml_nbytes(tensors[i]), (size_t) ne * ggml_type_size(type) / ggml_blck_size(type), (int) type); + return GGML_CUDA_COMM_ALLREDUCE_UNSUPPORTED; } if (((uintptr_t) tensors[i]->data & 0xF) != 0) { - GGML_LOG_WARN("%s: internal tensor[%zu] data pointer is not 16-byte aligned: %p type=%d ne=%" PRId64 "\n", + GGML_LOG_WARN("%s: internal unsupported: tensor[%zu] data pointer is not 16-byte aligned: %p type=%d ne=%" PRId64 "\n", __func__, i, tensors[i]->data, (int) type, ne); + return GGML_CUDA_COMM_ALLREDUCE_UNSUPPORTED; } }