CUDA: always create events for split buffers#10185
Merged
JohannesGaessler merged 1 commit intoggml-org:masterfrom Nov 14, 2024
Merged
CUDA: always create events for split buffers#10185JohannesGaessler merged 1 commit intoggml-org:masterfrom
JohannesGaessler merged 1 commit intoggml-org:masterfrom
Conversation
bde4116 to
38d11f5
Compare
Member
|
Qwen2.5-0.5B does not work with this change alone, it still crashes in the memcpy later: |
Member
|
It would also be possible to prevent using a split buffer entirely if the matrix is too small by returning |
38d11f5 to
e151321
Compare
slaren
reviewed
Nov 9, 2024
Comment on lines
+2981
to
+2991
| // only use row split if the weight matrix is large enough for every GPU to get data (this solves some edge cases) | ||
| // also for small matrices the overhead is very large anyways so splitting is slow | ||
| if (a->buffer && ggml_backend_buft_is_cuda_split(a->buffer->buft)) { | ||
| ggml_backend_cuda_split_buffer_type_context * buft_ctx = (ggml_backend_cuda_split_buffer_type_context *) a->buffer->buft->context; | ||
| int64_t active_devices = 0; | ||
| for (int id = 0; id < ggml_backend_cuda_get_device_count(); ++id) { | ||
| int64_t row_low; | ||
| int64_t row_high; | ||
| get_row_split(&row_low, &row_high, a, buft_ctx->tensor_split, id); | ||
| active_devices += row_low == row_high; | ||
| } | ||
| const int64_t rounding = get_row_rounding(buft_ctx->tensor_split); | ||
| if (rounding*active_devices < a->ne[1]) { | ||
| return false; | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
This seems too expensive to do in this function, since this is called many times during inference by ggml_backend_sched. I think it should be possible to compute the minimum tensor size in ggml_backend_cuda_split_buffer_type, and store it in ggml_backend_cuda_split_buffer_type_context, then this function would only need to compare the tensor size to this value.
e151321 to
84bcad6
Compare
slaren
approved these changes
Nov 14, 2024
arthw
pushed a commit
to arthw/llama.cpp
that referenced
this pull request
Nov 15, 2024
arthw
pushed a commit
to arthw/llama.cpp
that referenced
this pull request
Nov 17, 2024
arthw
pushed a commit
to arthw/llama.cpp
that referenced
this pull request
Nov 18, 2024
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #10176 .
I think the correct way to fix it is to just create the events unconditionally. Regardless of how the data is split you always need the events on the currently active device for the other devices to wait on. You could maybe reduce the number of events by only initializing those that are actually needed but I don't think that would be worthwhile since for the vast majority of use cases all events are already being created and used anyways.