Skip to content

ggml-alloc : grow the chunk list on demand instead of an unbounded 16th chunk - #164

Merged
dzannotti merged 1 commit into
halo-box:masterfrom
Nathanw1014:hb/alloc-growable-chunks
Oct 9, 2026
Merged

dzannotti merged 1 commit into
halo-box:masterfrom
Nathanw1014:hb/alloc-growable-chunks

Conversation

@Nathanw1014

Copy link
Copy Markdown

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 262144 on 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

  • The chunk lists in the allocator and the vbuffer grow on demand: 16 to start, then doubling.
  • Every chunk stays within the backend max size, unless one tensor alone is larger.
  • Graphs that fit in 16 chunks are laid out exactly as before.
  • test_not_enough_chunks used to assert the old behaviour (the last chunk grows). It now also runs check_max_size.

Testing

  • test-alloc: all 17 pass. As a control, the updated test_not_enough_chunks fails on master (offset + nbytes <= max_size).
  • Full Vulkan build has no new warnings.
  • Flash-Next UD-Q5_K_XL at the reporter's settings (-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.
  • The same change has shipped in strix-halo-llamacpp v0.7.8.1. There, forcing 512 MiB chunks took the same model to 17 chunks, past the old cap, and it loaded with every chunk at most 1 GiB. The release gate showed no perf change.

🤖 Generated with Claude Code

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants