-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement and use cuda graph plans #16548
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
Open
wishstudio
wants to merge
9
commits into
ggml-org:master
Choose a base branch
from
wishstudio:cuda_graph_plan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+358
−193
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
34b473c
Implement and use cuda graph plans.
wishstudio c17f8b5
Merge remote-tracking branch 'upstream' into cuda_graph_plan
wishstudio 4bbe5b1
Merge branch 'master' into cuda_graph_plan
wishstudio 3afbd9f
Fix cuda graph update logic.
wishstudio d6e97a0
Merge remote-tracking branch 'upstream/master' into cuda_graph_plan
wishstudio 5c89e8d
Fix wording.
wishstudio b7f366f
Fix faulty consecutive updates handling.
wishstudio 5586c67
Fix editorconfig check.
wishstudio de031bc
Forward declaration for ggml_backend_supports_graph_plan and ggml_bac…
wishstudio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
imo, we should actually check for the full equivalence of the generated splits (i.e. the
ggml_cgraphobjects contained in the splits & plans instead of just their backends)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.
The current check is a bare minimum for ensuring correctness. It basically says "if the number of splits or backend of any split is changed we rebuilt everything". If only the interior of a split is changed, it will be delegated to the backend's graph update routine to handle the change (code is just next paragraph below this check). In current CUDA backend, if the graph change is too large the
cudaGraphExecUpdatewill fail andcudaGraphInstantiatewill be called to reinstantiate a new executable graph. I think this will not generate too much overhead as thecudaGraphInstantiateis inevitable and only thecudaGraphExecUpdatecall can be saved.In order to improve this, I guess something like the enhanced API in #14514 needs to be implemented. It passes more information to help the backend make an informed decision on recreate vs update. Anyway I believe most scaffolds are missing so this would be out of scope for this PR.
Uh oh!
There was an error while loading. Please reload this page.
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.
By the way, if the split graph is indeed identical, the CUDA backend will find out via the
is_cuda_graph_update_requiredfast path. I don't think it's a good idea to move the checks up to the backend scheduler as different backends could have different definition of equivalence depending on various factors as discussed in #14514. We may calculate these factors in the scheduler but the ultimate decision is still better be done in the backend.