Skip to content

Commit b7f366f

Browse files
committed
Fix faulty consecutive updates handling.
1 parent 5c89e8d commit b7f366f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ggml/src/ggml-cuda/common.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ struct ggml_cuda_graph {
941941
std::vector<cudaGraphNode_t> nodes;
942942
std::vector<cudaKernelNodeParams> params;
943943
int number_consecutive_updates = 0;
944+
int number_consecutive_computes = 0;
944945
std::vector<ggml_graph_node_properties> ggml_graph_properties;
945946
#endif
946947
};

ggml/src/ggml-cuda/ggml-cuda.cu

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,8 +3149,7 @@ static void ggml_backend_cuda_graph_plan_update(ggml_backend_t backend, ggml_bac
31493149
} else {
31503150
cuda_graph_update_required = true;
31513151
}
3152-
} else {
3153-
cuda_graph->number_consecutive_updates = 0;
3152+
cuda_graph->number_consecutive_computes = 0;
31543153
}
31553154

31563155
if (use_cuda_graph && cuda_graph_update_required) {
@@ -3175,6 +3174,11 @@ static enum ggml_status ggml_backend_cuda_graph_plan_compute(ggml_backend_t back
31753174

31763175
ggml_cuda_set_device(cuda_ctx->device);
31773176

3177+
cuda_graph->number_consecutive_computes++;
3178+
if (cuda_graph->number_consecutive_computes > 1) {
3179+
cuda_graph->number_consecutive_updates = 0;
3180+
}
3181+
31783182
if (cuda_graph->instance) {
31793183
CUDA_CHECK(cudaGraphLaunch(cuda_graph->instance, cuda_ctx->stream()));
31803184
} else {

0 commit comments

Comments
 (0)