Skip to content

hexagon: enable alloc_buffer_n - #30126

Merged
max-krasnyansky merged 6 commits into
masterfrom
maxk/hexagon-alloc-buffer-n
Oct 8, 2026
Merged

max-krasnyansky merged 6 commits into
masterfrom
maxk/hexagon-alloc-buffer-n

Conversation

@max-krasnyansky

Copy link
Copy Markdown
Member

Overview

This PR update ggml-hexagon to use the new alloc_buffer_n backend API which allows us to better control static buffer allocations. Perhaps, static is not quite the right term, it's basically all the weights, kv tensors, etc. The rest (aka dynamic) of the stuff is still allocated via general allocator.

The PR also extends GGML_HEXAGON_MBUF setting to support three values dynamic[,static,total].
Dynamic defaults to 512M, static is 1GB as before and total is 0 (entire RAM) same as before as well.

Lower dynamic default resolve the issue on quad-NPU setup where ALLREDUCE has to mmap 4 buffers from all ranks.
Previous 1GB default was problematic in that scenario because it exceeded ~3.5GB limit.

The new static allocator also ensure that the KV tensors are placed into the same buffer so that opbatches that processes those layers don't need to mmap multiple large buffers.

The PR also adds a little helper to the snapdragon/run.py script that simplifies pass tensor override for mapping lm-head to the CPU.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes, AntiG, mostly for code view and log analysis.

@max-krasnyansky
max-krasnyansky requested a review from a team as a code owner October 7, 2026 23:33
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning Hexagon labels Oct 7, 2026
@max-krasnyansky

Copy link
Copy Markdown
Member Author

@lhez for review/ack

@max-krasnyansky max-krasnyansky added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 7, 2026
Comment thread scripts/snapdragon/run.py Resolved
Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>
@max-krasnyansky

Copy link
Copy Markdown
Member Author

@lhez sorry, I applied suggestion and need reapproval

@max-krasnyansky
max-krasnyansky merged commit 9c2e0e4 into master Oct 8, 2026
22 of 23 checks passed
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 8, 2026
* hex-bufs: add support for alloc_buffer_n

* hex-bufs: add support for splitting large tensors into separate buffers

* hex-bufs: update GGML_HEXAGON_MBUF to accept three values dyn,static,total

* hex-bufs: bump dyn. default to 512MB since 128MB causes perf regressions with big MOEs

* hex-run: add --no-embd-offload option to simplify command lines on devices that need it

* Update scripts/snapdragon/run.py

Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>

---------

Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>
(cherry picked from commit 9c2e0e4)
@BrewTestBot BrewTestBot mentioned this pull request Oct 15, 2026
1 task done
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
* hex-bufs: add support for alloc_buffer_n

* hex-bufs: add support for splitting large tensors into separate buffers

* hex-bufs: update GGML_HEXAGON_MBUF to accept three values dyn,static,total

* hex-bufs: bump dyn. default to 512MB since 128MB causes perf regressions with big MOEs

* hex-run: add --no-embd-offload option to simplify command lines on devices that need it

* Update scripts/snapdragon/run.py

Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>

---------

Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
* hex-bufs: add support for alloc_buffer_n

* hex-bufs: add support for splitting large tensors into separate buffers

* hex-bufs: update GGML_HEXAGON_MBUF to accept three values dyn,static,total

* hex-bufs: bump dyn. default to 512MB since 128MB causes perf regressions with big MOEs

* hex-run: add --no-embd-offload option to simplify command lines on devices that need it

* Update scripts/snapdragon/run.py

Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>

---------

Co-authored-by: Jhen-Jie Hong <iainst0409@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning Hexagon merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants