]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
ggml : split graph allocations according to backend max buffer size (#15815)
authorAcly <redacted>
Wed, 24 Sep 2025 14:17:49 +0000 (16:17 +0200)
committerGitHub <redacted>
Wed, 24 Sep 2025 14:17:49 +0000 (16:17 +0200)
commitf2a789e33490deb483a2694b066b37e45524bb79
tree5c08330bd8fa73f1f52d39988d1888806cf3b1a5
parent3a599719673c850647e3bb911ed6d91109bb91d2
ggml : split graph allocations according to backend max buffer size (#15815)

* ggml : make gallocr respect the backend's max buffer size

* if the graph requires more memory than can fit into a single allocation, split it into multiple backend buffers
* vulkan: report the actual max  allocation size in buffer type  interface

* fix missing newline, apple-clang warning

* track size of individual chunks in ggml_dyn_tallocr and raise max chunks.
revert to use suballocation_block_size as max chunk size for vulkan.

* track (chunk, offset) pairs instead of "global" offsets through gallocr.

* simpler, don't need loops to map between local/global offsets
* touches more code

* fix dyn_tallocr_max_size and initialization

* fix memory leak when buffers are reused due to same buffer type appearing multiple times

* make vbuffer allocation follow the same logic as backend_buffer did before

* continue to use leftover unallocated space of previous chunks after a new one has been created

* treat free blocks of each chunk as separate list
* they're still allocated together, but start/end of each chunk is tracked, and allocate/free iterate over sub-ranges
* exhaust freed blocks of all chunks before considering their last blocks with unallocated space
* start with 0 chunks/blocks and create chunks as needed
* allow the last chunk to grow beyond max size

* refactor: move adding new free block and new chunk into separate functions

* allocate chunks individually with a separate free-blocks list for each one

* needs a bit more memory/allocations/indirections, but code is simpler

* fix warnings (missing static) & debug checks
ggml/src/ggml-alloc.c
ggml/src/ggml-impl.h
tests/CMakeLists.txt
tests/test-alloc.cpp [new file with mode: 0644]