From: agray3 Date: Tue, 4 Jun 2024 20:06:49 +0000 (+0100) Subject: Allow number of nodes in CUDA graph to change (llama/7738) X-Git-Tag: upstream/0.0.1642~610 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a524d3f0ca02c83f40a36b514e902260190d53b0;p=pkg%2Fggml%2Fsources%2Fggml Allow number of nodes in CUDA graph to change (llama/7738) Previously the code would have failed to cope in the case that the number of nodes changes in an existing CUDA graph. This fixes the issue by removing an unnecessary conditional. --- diff --git a/src/ggml-cuda.cu b/src/ggml-cuda.cu index daaa0cd6..c81c6a0d 100644 --- a/src/ggml-cuda.cu +++ b/src/ggml-cuda.cu @@ -2702,10 +2702,8 @@ GGML_CALL static enum ggml_status ggml_backend_cuda_graph_compute(ggml_backend_t if (cuda_graph_update_required) { // Extract nodes from graph - if (cuda_ctx->cuda_graph->num_nodes == 0) { - // First call with null argument gets number of nodes in graph - CUDA_CHECK(cudaGraphGetNodes(cuda_ctx->cuda_graph->graph, nullptr, &cuda_ctx->cuda_graph->num_nodes)); - } + // First call with null argument gets number of nodes in graph + CUDA_CHECK(cudaGraphGetNodes(cuda_ctx->cuda_graph->graph, nullptr, &cuda_ctx->cuda_graph->num_nodes)); // Subsequent call with non-null argument gets nodes cuda_ctx->cuda_graph->nodes.resize(cuda_ctx->cuda_graph->num_nodes); cuda_ctx->cuda_graph->params.resize(cuda_ctx->cuda_graph->num_nodes);