From 0f46bf065e0d7731ed967aacdb70d6b4d064fcac Mon Sep 17 00:00:00 2001 From: MirariImmensitatemAstrorum Date: Sun, 20 Sep 2026 10:32:56 -0500 Subject: [PATCH] ggml-alloc: avoid splitting on zero-size view tensors When buffer splitting is driven only by the accumulated buffer size, a view tensor with zero allocation size can trigger a split. That resets the running size at the view and can leave trailing view tensors outside the final allocated range. Require the current tensor to have a nonzero allocation size before it can start a new backend buffer chunk. Ported semantically from historical private-fork commit 00d54526e24e3aba4c76474e3147cbf9c7cc034c. --- ggml/src/ggml-alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-alloc.c b/ggml/src/ggml-alloc.c index a71838eafc69..61e0def9788e 100644 --- a/ggml/src/ggml-alloc.c +++ b/ggml/src/ggml-alloc.c @@ -1184,7 +1184,7 @@ static ggml_backend_buffer_t ggml_backend_alloc_ctx_tensors_from_buft_impl( this_size = GGML_PAD(ggml_backend_buft_get_alloc_size(buft, t), alignment); } - if (cur_buf_size > 0 && (cur_buf_size + this_size) > max_size) { + if (cur_buf_size > 0 && this_size > 0 && (cur_buf_size + this_size) > max_size) { // allocate tensors in the current buffer if (!no_alloc && !alloc_tensor_range(ctx, first, t, buft, cur_buf_size, &buffers, &n_buffers)) { return NULL;