Repository navigation
ggml-alloc : grow the chunk list on demand instead of an unbounded 16th chunk - #164
Merged
Merged
Conversation
…th chunk The compute buffer is split into chunks of at most the backend's max size (1 GiB on Vulkan), but the chunk list was a fixed array of 16, and the 16th chunk was made unbounded so it could take whatever was left. A compute buffer past ~16 chunks therefore put everything remaining in one chunk that can be larger than the device allows: Flash-Next at -c 262144 on a 128 GB Strix Halo needed a 19.5 GB compute buffer and failed on a 4.4 GiB chunk, over RADV's 4 GiB buffer limit (issue 22). The chunk lists of the allocator and of the virtual buffer now grow (16, then doubling), and every chunk stays at the max size unless one tensor alone is larger. Graphs that fit in 16 chunks are laid out exactly as before. test_not_enough_chunks now also checks that every chunk stays within max_size; it fails on the old layout. Assisted-by: Claude Opus 5.5
dzannotti
approved these changes
Oct 9, 2026
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.
Summary
The compute buffer is split into chunks of at most the backend's max buffer size (1 GiB on Vulkan). The chunk list was a fixed array of 16, so the 16th chunk was made unbounded to hold whatever was left. Once a graph needs more than ~16 chunks, that last chunk can be larger than the device allows.
This came up with Flash-Next at
-c 262144on a 128 GB Strix Halo. The compute buffer was 19.5 GB, which left a 4.4 GiB 16th chunk, over RADV's 4 GiB buffer limit, so the load failed (strix-halo-llamacpp#22).Change
test_not_enough_chunksused to assert the old behaviour (the last chunk grows). It now also runscheck_max_size.Testing
test-alloc: all 17 pass. As a control, the updatedtest_not_enough_chunksfails on master (offset + nbytes <= max_size).-c 262144 -ub 2048, experts on CPU), Strix Halo 64 GB, Mesa 26.2.4. Loads fine with and without the patch, so this is a regression check, not a repro. On this box halo-box needs only ~12-14 chunks.🤖 Generated with Claude Code