Repository navigation
hexagon: tensor repacking rework and support for tiled and flat quantized and fp weights - #30635
Merged
max-krasnyansky merged 35 commits intoOct 16, 2026
Merged
Conversation
…s GET_ROWS tests for K-Quants, will fix in the next round Add support for GET_ROWS with tiled Q5_K Add support for raw k-quant tensors
Member
Author
|
@lhez for review and ack (sorry for another huge PR but the updates are very targeted tiling/flat renames, etc). |
lhez
approved these changes
Oct 16, 2026
Member
|
It looks like |
Member
Author
Fixed. Thanks! |
Member
Author
|
Ok. Should be good to go. I double checked and the CI failures in other backends are unrelated (ie since I touched the test a bit). |
jhen0409
approved these changes
Oct 16, 2026
edwardyoon
pushed a commit
to edwardyoon/focus-llama
that referenced
this pull request
Oct 24, 2026
…ized and fp weights (ggml-org#30635) * hex-repack: Remove need_repack hack and streamline the rules -- breaks GET_ROWS tests for K-Quants, will fix in the next round Add support for GET_ROWS with tiled Q5_K Add support for raw k-quant tensors * hex-get-rows: vectorize raw k-quant ukernels * hex-binary: refactor dma-loop thread functions (no need for macros, etc) * hex-quant: move/cleanup flat and tiled dequant ukernels * hex-repack: add support for repacking/tiling F16/F32/BF16 2D weights * hex-get-rows: remove redundant cast * hex-repack: proper filtering for BF16 that were leaking through during the tests * hex-repack: streamling tiling rules (broken MM for now) * hex-repack: fix mmid after tiling updates * hex-repack: rename repacked to tiled in all flags/funcs/kernels/vars * hex-mm: fix valid_rows calc in various kernels * hex-mm: remove unused hvx_mm_nx_2d_flat * hex-mm: cleanup and optimize hvx-tiled vec_dot_f16 * hex-mm: another pass at hvx-tiled f16 matmul * hex-get-rows: optimize small src1 * hex-get-rows: one more pass at recovering get-rows perf regression * hex-repack: export GGML_HEXAGON_RT_REPACK via run.py * hex-mm-tiled: fix accuracy regression with hmx-tiled-f16 matmul * hex-mm: fold tiled_f16 checks into the general flow * hex-get-rows: remove dead checks for buffer_is_hexagon and tiling during supports_op * hex-quant: proper tail handling in new dequant ukernels * hex-get-rows: remove unused code and cleanup support checks * hex-mm: cleanup ne1 padding/tiling checks * hex-mm: cleanup fusion checks for tiled tensors * hex-repack: add a little can_repack helper to reduce duplication * hex-repack: never repack host buffers * hex-repack: factor out repack functions into separate .h and .cpp * hex-tensor: cleanup tensor ifaces for tiled/padded sizes * hex-repack: update k-quant tiling comments and cleanup #defines * hex-dcache: factor out l2/dcache dirty tracking and flushing * hex-tensor: update docs and remove #defs duplication * hex-tensor: remove unused/incorrect get_data interface * hex-get-rows: cleanup vtcm layout build * tests: disable huge MM tests * hex-dcache: add missing header
auRose94
pushed a commit
to auRose94/llama.cpp
that referenced
this pull request
Oct 28, 2026
…ized and fp weights (ggml-org#30635) * hex-repack: Remove need_repack hack and streamline the rules -- breaks GET_ROWS tests for K-Quants, will fix in the next round Add support for GET_ROWS with tiled Q5_K Add support for raw k-quant tensors * hex-get-rows: vectorize raw k-quant ukernels * hex-binary: refactor dma-loop thread functions (no need for macros, etc) * hex-quant: move/cleanup flat and tiled dequant ukernels * hex-repack: add support for repacking/tiling F16/F32/BF16 2D weights * hex-get-rows: remove redundant cast * hex-repack: proper filtering for BF16 that were leaking through during the tests * hex-repack: streamling tiling rules (broken MM for now) * hex-repack: fix mmid after tiling updates * hex-repack: rename repacked to tiled in all flags/funcs/kernels/vars * hex-mm: fix valid_rows calc in various kernels * hex-mm: remove unused hvx_mm_nx_2d_flat * hex-mm: cleanup and optimize hvx-tiled vec_dot_f16 * hex-mm: another pass at hvx-tiled f16 matmul * hex-get-rows: optimize small src1 * hex-get-rows: one more pass at recovering get-rows perf regression * hex-repack: export GGML_HEXAGON_RT_REPACK via run.py * hex-mm-tiled: fix accuracy regression with hmx-tiled-f16 matmul * hex-mm: fold tiled_f16 checks into the general flow * hex-get-rows: remove dead checks for buffer_is_hexagon and tiling during supports_op * hex-quant: proper tail handling in new dequant ukernels * hex-get-rows: remove unused code and cleanup support checks * hex-mm: cleanup ne1 padding/tiling checks * hex-mm: cleanup fusion checks for tiled tensors * hex-repack: add a little can_repack helper to reduce duplication * hex-repack: never repack host buffers * hex-repack: factor out repack functions into separate .h and .cpp * hex-tensor: cleanup tensor ifaces for tiled/padded sizes * hex-repack: update k-quant tiling comments and cleanup #defines * hex-dcache: factor out l2/dcache dirty tracking and flushing * hex-tensor: update docs and remove #defs duplication * hex-tensor: remove unused/incorrect get_data interface * hex-get-rows: cleanup vtcm layout build * tests: disable huge MM tests * hex-dcache: add missing header
1 task done
yuubinnkyoku
added a commit
to yuubinnkyoku/llama.cpp
that referenced
this pull request
Nov 25, 2026
Measured on host, no device needed. ceefd16 (ggml-org#30581 HMX FA sinks) and 27c7a76 (ggml-org#30435 softplus HVX) apply with zero conflicts. Not committed here, because the branch should not advance past what the device has validated; they are the first two for Phase 65. 797de63 (ggml-org#30122 Q1_0/Q2_0) is the next wall at 39 hunks across four files, 28 of them in matmul-ops.c where the fork's four-column dispatch and upstream's generic repack dispatch claim the same table. It needs the repack layer that b797b9c (ggml-org#30635) introduces, and that file pair does not exist in the fork. So the shape is: repack rework is the gate, and Q1_0/Q2_0 and Op Fusion both sit behind it. Phase 65's real work is one PR with ten files and 39+ hunks. Assisted-by: DeepSeek Harness
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.
Overview
This is a long overdue cleanup/rework of
ggml-hexagontensor / weight repacking functionality.It's another sizable update but it's hard to rework stuff like this via minor increments.
The PR cleans up the terminology and naming across the entire backend:
repackis now consistently used for the overall feature and configurationflatis now consistently used for ops/ukernels/data that operate on flat/row-major GGML formats (f16, q4_0, ...)tiledis now consistently used for ops/ukernels/data that operate on 32x32 tiled hexagon formatsWe now consistently enforce a very simple and clear rule:
This rule applies to
f16/f32/bf16 2dweights which are always repacked into f16 tiles.Our
MUL_MATkernels were already doing this at run-time and this feature allows us to now skip the run-time tiling.Note: That bf16 support is new and introduced in this PR.
The PR updates the ukernel collection to provide both flat and tiled favors for all key paths.
GET_ROWS,MAT_MULandMUL_MAT_IDnow have both flat and tiled fp ukernels, and tiled quantized ukernelsGET_ROWSsupport flat Q and K-quantsOther cleanups, refactoring, and improvements:
There is new env var
GGML_HEXAGON_RT_REPACKwith 3-states (0: disabled, 1: quantized only [default], 2: always, including float weights). This controlsruntime(aka lazy) repack and is intended only for testing where most of the tensor buffers are not marked asusage=weights. The default is intended tort-repackquantized weights for MUL_MAT and GET_ROWS tests to mimic the actual use-cases.Passing all
test-backend-ops -b HTP0 -o MUL_MAT.*tests (including all fusion tests) on single and dual-NPU setups.Performance
Performance-wise it's a significant boost for the models that use 2D F16/F32/BF16 weights.
As I mentioned above we're now able to skip the runtime tiling overhead for these weights.
Here is an example from profiling runs of
gemma-4-E2B_q4_0. It's aQ4_0 QATmodel but it still has F16 weights.Models that are heavy on F16/F32/BF16 weights should see major gains.
Please let me know if you see any regressions.
Requirements