Skip to content

ggml-backend : skip empty inputs in the batched sched uploads (fix Metal GGML_ASSERT(buf_src) since #393) - #416

Merged
bri-prism merged 1 commit into
prismfrom
fix/sched-skip-empty-uploads
Nov 2, 2026
Merged

bri-prism merged 1 commit into
prismfrom
fix/sched-skip-empty-uploads

Conversation

@bri-prism

Copy link
Copy Markdown
Collaborator

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:

ggml/src/ggml-metal/ggml-metal-context.m:315: GGML_ASSERT(buf_src) failed

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 with newBufferWithBytes:length:, which returns nil for a zero length, so the assert fires. The blocking ggml_backend_tensor_copy that #393 replaced was a no-op for an empty tensor. CPU-only runs (-ngl 0) are not affected.

How

upload_host_input returns early when ggml_nbytes(input) == 0, so nothing is queued for an empty input. Every non-empty input takes the same path as before.

Testing

  • Apple M5 Pro, Metal: llama-bench -ngl 99 -fa 1 -p 64 -n 16 aborted on the first decode at the current prism HEAD. With this change the same runs complete.
  • A temporary print in upload_host_input showed the failing input: a view with nbytes=0 at the point of the assert.

…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.
@github-actions github-actions Bot added the ggml label Oct 29, 2026
@bri-prism
bri-prism merged commit a2008ca into prism Nov 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant