Commit 94256114c for llama.cpp
commit 94256114c229674ef96e76eb2dea596e65b43818
Author: Ruben Ortlam <rortlam@redhat.com>
Date: Wed Sep 23 07:35:24 2026 +0200
ggml-meta: resolve multi buffer views (#29266)
* ggml-meta: resolve multi buffer views
* add TODO to revisit if graph allocator gets refactored
diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cpp
index 3ec40fb1a..7c1c0b864 100644
--- a/ggml/src/ggml-backend-meta.cpp
+++ b/ggml/src/ggml-backend-meta.cpp
@@ -1200,11 +1200,6 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_m
ggml_context * simple_ctx = stc.ctxs[j].get();
ggml_backend_buffer_t simple_buf = buf_ctx->bufs[j].get();
- if ((simple_buf != nullptr) && ggml_backend_buffer_is_multi_buffer(simple_buf)) {
- // see https://github.com/ggml-org/llama.cpp/issues/22197
- GGML_ABORT("multi buffers are not supported by the meta backend");
- }
-
if (split_dim >= 0 && split_dim < GGML_MAX_DIMS) {
// TODO: the following assert fails for llama-parallel even though the results are correct:
// GGML_ASSERT(ggml_is_contiguously_allocated(tensor));
@@ -1252,16 +1247,27 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_m
}
}
}
+ // TODO: revisit once the graph allocator has been refactored, see https://github.com/ggml-org/llama.cpp/pull/25051#issuecomment-4842873396
+ ggml_backend_buffer_t init_buf = simple_buf;
if (t_ij->view_src != nullptr) {
t_ij->data = (char *) t_ij->view_src->data + t_ij->view_offs;
+ // views inherit the source slice's concrete sub-buffer (issue 22197)
+ if (tensor->view_src != nullptr && ggml_backend_buffer_is_meta(tensor->view_src->buffer)
+ && t_ij->view_src->buffer != nullptr) {
+ t_ij->buffer = t_ij->view_src->buffer;
+ init_buf = t_ij->view_src->buffer;
+ }
} else if (simple_buf != nullptr) {
+ if (ggml_backend_buffer_is_multi_buffer(simple_buf)) {
+ GGML_ABORT("multi buffers are not supported by the meta backend");
+ }
t_ij->data = (char *) ggml_backend_buffer_get_base(simple_buf)
+ size_t(tensor->data) - size_t(ggml_backend_buffer_get_base(tensor->buffer));
}
- if (simple_buf) {
+ if (init_buf) {
// the backend that owns the buffer will set .extra
- ggml_backend_buffer_init_tensor(simple_buf, t_ij);
+ ggml_backend_buffer_init_tensor(init_buf, t_ij);
} else {
t_ij->extra = tensor->extra;
}