-
Notifications
You must be signed in to change notification settings - Fork 15.6k
ggml-cuda: check for srcs outside the cgraph #18583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2973,15 +2973,16 @@ static bool is_cuda_graph_update_required(ggml_backend_cuda_context * cuda_ctx, | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Check if the graph size has changed | ||||||||||||||
| if (cuda_ctx->cuda_graph->ggml_graph_properties.size() != (size_t)cgraph->n_nodes) { | ||||||||||||||
| if (cuda_ctx->cuda_graph->ggml_graph_properties.size() != (size_t)cgraph->n_nodes + cgraph->n_leafs) { | ||||||||||||||
| cuda_graph_update_required = true; | ||||||||||||||
| cuda_ctx->cuda_graph->ggml_graph_properties.resize(cgraph->n_nodes); | ||||||||||||||
| cuda_ctx->cuda_graph->ggml_graph_properties.resize(cgraph->n_nodes + cgraph->n_leafs); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Loop over nodes in GGML graph to determine if CUDA graph update is required | ||||||||||||||
| // and store properties to allow this comparison for the next token | ||||||||||||||
| for (int i = 0; i < cgraph->n_nodes; i++) { | ||||||||||||||
| bool has_matching_properties = true; | ||||||||||||||
|
|
||||||||||||||
| if (!cuda_graph_update_required) { | ||||||||||||||
| has_matching_properties = ggml_graph_node_has_matching_properties(cgraph->nodes[i], &cuda_ctx->cuda_graph->ggml_graph_properties[i]); | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -2991,6 +2992,17 @@ static bool is_cuda_graph_update_required(ggml_backend_cuda_context * cuda_ctx, | |||||||||||||
| set_ggml_graph_node_properties(cgraph->nodes[i], &cuda_ctx->cuda_graph->ggml_graph_properties[i]); | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we move this setting inside the if condition as well? (see comment below) |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| for (int i = 0; i < cgraph->n_leafs; i++) { | ||||||||||||||
| bool has_matching_properties = true; | ||||||||||||||
| if (!cuda_graph_update_required) { | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of this check?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it skips calling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant to ask whether it is relevant for program correctness but based on your answer I guess not. |
||||||||||||||
| has_matching_properties = ggml_graph_node_has_matching_properties(cgraph->leafs[i], &cuda_ctx->cuda_graph->ggml_graph_properties[cgraph->n_nodes + i]); | ||||||||||||||
| } | ||||||||||||||
| if (!has_matching_properties) { | ||||||||||||||
| cuda_graph_update_required = true; | ||||||||||||||
| } | ||||||||||||||
| set_ggml_graph_node_properties(cgraph->leafs[i], &cuda_ctx->cuda_graph->ggml_graph_properties[cgraph->n_nodes + i]); | ||||||||||||||
|
Comment on lines
+3001
to
+3003
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Shouldn't we have to update the node properties only if they are not matching? Or do we set something with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, just following the existing pattern here. Will address in the refactor |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return cuda_graph_update_required; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer used