Skip to content

hexagon: handle multi-sequence in concat_2d - #29344

Merged
max-krasnyansky merged 1 commit into
ggml-org:masterfrom
jhen0409:jhen/hexagon-npl-concat
Sep 24, 2026
Merged

max-krasnyansky merged 1 commit into
ggml-org:masterfrom
jhen0409:jhen/hexagon-npl-concat

Conversation

@jhen0409

@jhen0409 jhen0409 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Overview

Currently the op_concat in ggml-hexagon will fallback from 2d transposed to generic path when n_seqs greater than 1, especially in qwen35.cpp, which it will be slower than the fast path on PP. (See the CONCAT numbers in Additional information)

Since each plane is an independent 2D transposed concat, we should be able to iterate them instead of falling back to generic.

Additional information

Test on IQ-9075, run two models (that cover the path) with llama-batched-bench --device HTP0:0 -ngl 99 -fa on -t 6 --cpu-mask 0xfc -c 4096 -b 512 -ub 256 -npp 128 -ntg 32 -npl 1,2,4:

Model npl test master (t/s) patch (t/s) change
Qwen3.5-4B Q4_0 1 pp512 373.07 376.00 +0.8%
Qwen3.5-4B Q4_0 1 tg32 10.62 10.59 -0.3%
Qwen3.5-4B Q4_0 2 pp512 x 2 49.36 181.24 +267.2%
Qwen3.5-4B Q4_0 2 tg32 x 2 13.49 14.11 +4.6%
Qwen3.5-4B Q4_0 4 pp512 x 4 49.86 176.66 +254.3%
Qwen3.5-4B Q4_0 4 tg32 x 4 14.59 15.47 +6.1%
granite-4.0-h-micro Q4_0 1 pp512 243.14 244.61 +0.6%
granite-4.0-h-micro Q4_0 1 tg32 8.73 8.71 -0.2%
granite-4.0-h-micro Q4_0 2 pp512 x 2 155.97 226.01 +44.9%
granite-4.0-h-micro Q4_0 2 tg32 x 2 10.75 10.99 +2.2%
granite-4.0-h-micro Q4_0 4 pp512 x 4 153.17 221.45 +44.6%
granite-4.0-h-micro Q4_0 4 tg32 x 4 13.52 14.04 +3.9%
Per-call CONCAT time (GGML_HEXAGON_PROFILE=1, one run per npl)
Model npl CONCAT shape (src0 x src1 -> dst) calls master (ms) patch (ms) change
Qwen3.5-4B Q4_0 1 3:8192 x 256:8192 -> 259:8192 48 1.265 1.269 +0.3%
Qwen3.5-4B Q4_0 1 3:8192 x 1:8192 -> 4:8192 768 0.233 0.233 +0.2%
Qwen3.5-4B Q4_0 2 3:8192:2:1 x 128:8192:2:1 -> 131:8192:2:1 96 138.243 1.356 -99.0%
Qwen3.5-4B Q4_0 2 3:8192:2:1 x 1:8192:2:1 -> 4:8192:2:1 768 0.752 0.469 -37.6%
Qwen3.5-4B Q4_0 4 3:8192:4:1 x 64:8192:4:1 -> 67:8192:4:1 192 154.644 1.635 -98.9%
Qwen3.5-4B Q4_0 4 3:8192:4:1 x 1:8192:4:1 -> 4:8192:4:1 768 1.500 0.927 -38.2%
granite-4.0-h-micro Q4_0 1 3:4352 x 256:4352 -> 259:4352 72 0.646 0.649 +0.4%
granite-4.0-h-micro Q4_0 1 3:4352 x 1:4352 -> 4:4352 1152 0.130 0.130 +0.3%
granite-4.0-h-micro Q4_0 2 3:4352:2:1 x 128:4352:2:1 -> 131:4352:2:1 144 15.102 0.696 -95.4%
granite-4.0-h-micro Q4_0 2 3:4352:2:1 x 1:4352:2:1 -> 4:4352:2:1 1152 0.395 0.252 -36.3%
granite-4.0-h-micro Q4_0 4 3:4354352:4:1 288 15.049 0.811 -94.6%
granite-4.0-h-micro Q4_0 4 3:43552:4:1 1152 0.783 0.494 -36.8%

The remaining gap I found for qwen35 so far is ssm_out MUL_MAT. In #29197, it uses MATMUL_4D_REPACKED_IMPL instead of falling back to CPU. In my experiments, flatten to 2D and use HMX could be more faster.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, I use Claude Code to track the issue, and did validation and review.

@jhen0409
jhen0409 requested a review from a team as a code owner September 23, 2026 22:48
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning Hexagon labels Sep 23, 2026
@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 Sep 24, 2026
@max-krasnyansky

Copy link
Copy Markdown
Member

@lhez please review/ack

@max-krasnyansky
max-krasnyansky merged commit a02c7f5 into ggml-org:master Sep 24, 2026
19 checks passed
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 7, 2026
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