Repository navigation
ggml-backend : skip empty inputs in the batched sched uploads (fix Metal GGML_ASSERT(buf_src) since #393) - #416
Merged
Conversation
…tal GGML_ASSERT(buf_src) since #393) The async upload path added in #393 also sends zero-size inputs (an empty view in a decode graph). Metal cannot wrap a zero-length source buffer (newBufferWithBytes returns nil), so every Metal decode aborted in ggml_metal_set_tensor_async. The blocking copy this replaced was a no-op for these inputs; skip them.
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.
What
Skip zero-size inputs in the batched host-input uploads that #393 added to
ggml_backend_sched_compute_splits.Why
Since #393 (first in release
prism-b10819), every decode on Metal aborts with:The scheduler now uploads host inputs with
ggml_backend_tensor_set_async. One input of the decode graph is an empty view (0 bytes). The Metal backend wraps the source data withnewBufferWithBytes:length:, which returns nil for a zero length, so the assert fires. The blockingggml_backend_tensor_copythat #393 replaced was a no-op for an empty tensor. CPU-only runs (-ngl 0) are not affected.How
upload_host_inputreturns early whenggml_nbytes(input) == 0, so nothing is queued for an empty input. Every non-empty input takes the same path as before.Testing
llama-bench -ngl 99 -fa 1 -p 64 -n 16aborted on the first decode at the currentprismHEAD. With this change the same runs complete.upload_host_inputshowed the failing input: a view withnbytes=0at the point of the assert.