diff --git a/ggml/src/ggml-cuda/common.cuh b/ggml/src/ggml-cuda/common.cuh index fea1cf9c406d..330f6abfc7d1 100644 --- a/ggml/src/ggml-cuda/common.cuh +++ b/ggml/src/ggml-cuda/common.cuh @@ -1471,7 +1471,7 @@ struct ggml_backend_cuda_context { if (time_now - last_graph_eviction_sweep >= 5'000'000) { last_graph_eviction_sweep = time_now; for (auto it = cuda_graphs.begin(); it != cuda_graphs.end(); ) { - if (time_now - it->second->last_used_time >= 10'000'000) { + if (it->first != first_node_ptr && time_now - it->second->last_used_time >= 10'000'000) { it = cuda_graphs.erase(it); } else { ++it;