Misc. bug: Hexagon: test-backend-ops POOL_2D fails for 128-wide kernels with padding on HTP0 (v73)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in ggml/src/ggml-hexagon/ and inspect pool_pixel_boundary_vec, especially the predicate mask built with Q6_Q_vsetq_R; compare it with Q6_Q_vsetq2_R and trace how pool_row_general_vec uses this path. Run test-backend-ops -b HTP0 -o POOL_2D; done means all 144 cases pass, including the four padded 128-wide kernel cases.
Written by the indexing model from the issue text.
Description
Name and Version
version: 1.0.0-dev (build 12536, commit 7a4117eef)
built with Clang 22.1.7 for Windows arm64
This is the unmodified master build where the bug reproduces. The bug is still present on current master (8af68d48); ggml/src/ggml-hexagon/ is identical between the two commits.
Operating systems
Windows
Which llama.cpp modules do you know to be affected?
Other (Please specify in the next section)
Command line
test-backend-ops -b HTP0 -o POOL_2D
Problem description & steps to reproduce
On my machine (Snapdragon X Elite X1E78100, Hexagon v73, SDK 6.7.0.0, driver 30.0.219.1000), test-backend-ops -b HTP0 -o POOL_2D fails 4 of the 144 cases. All four use a 128-wide kernel with padding; the other 140 pass, including the unpadded 128-wide kernels. The two shapes are ne_input=[259,5,3,2], k0=128, k1=3, s0=64, s1=2, p0=64, p1=1 and ne_input=[193,2,1,1], k0=128, k1=1, s0=128, s1=1, p0=128, p1=2, and each one fails for both avg and max pooling.
Avg pooling gives NMSE 294.16 and 206.38. Max pooling returns -FLT_MAX where the CPU reference is about 0.98. The mask in pool_pixel_boundary_vec is built per 32-float chunk. A full chunk has n = 32, so the code calls Q6_Q_vsetq_R(n * sizeof(float)) with 128 bytes. vsetq only takes a 7-bit byte count, so 128 wraps to 0 and the predicate is empty; Q6_V_vmux_QVV then substitutes the identity value (-FLT_MAX for max, 0 for avg) in every lane. Every output pixel that goes through this function with 32 or more valid columns therefore loses data, not only pixels with exactly 128. With stride 64 or 128, pool_row_general_vec sends every pixel, including interior ones, through this path; pixels with exactly 128 valid columns are just the most visible case (max gives -FLT_MAX), while the rest come out partly wrong. Q6_Q_vsetq2_R handles the full range and gives the correct mask, so switching to it is the whole fix.
Before the fix, 140 of 144 cases pass. After it, 144 of 144 pass on HTP0. POOL_1D is 240/240 both before and after. I only tested this on v73.
First Bad Commit
Likely 50569eb87 (ggml-org/llama.cpp#29995, which added the pool op). I did not bisect.
Relevant log output
Logs
before (7a4117eef):
[POOL_2D] ERR = 294.158129097 > 0.000000100 POOL_2D(pool_type=avg,type_input=f32,ne_input=[259,5,3,2],k0=128,k1=3,s0=64,s1=2,p0=64,p1=1): FAIL
[POOL_2D] ERR = 206.382433124 > 0.000000100 POOL_2D(pool_type=avg,type_input=f32,ne_input=[193,2,1,1],k0=128,k1=1,s0=128,s1=1,p0=128,p1=2): FAIL
[POOL_2D] inf mismatch: HTP0=-340282346638528859811704183484516925440.000000 CPU=0.985368 POOL_2D(pool_type=max,type_input=f32,ne_input=[259,5,3,2],k0=128,k1=3,s0=64,s1=2,p0=64,p1=1): FAIL
[POOL_2D] inf mismatch: HTP0=-340282346638528859811704183484516925440.000000 CPU=0.987192 POOL_2D(pool_type=max,type_input=f32,ne_input=[193,2,1,1],k0=128,k1=1,s0=128,s1=1,p0=128,p1=2): FAIL
after (51a77c4f2 + vsetq2):
POOL_2D(pool_type=avg,type_input=f32,ne_input=[259,5,3,2],k0=128,k1=3,s0=64,s1=2,p0=64,p1=1): OK
POOL_2D(pool_type=avg,type_input=f32,ne_input=[193,2,1,1],k0=128,k1=1,s0=128,s1=1,p0=128,p1=2): OK
POOL_2D(pool_type=max,type_input=f32,ne_input=[259,5,3,2],k0=128,k1=3,s0=64,s1=2,p0=64,p1=1): OK
POOL_2D(pool_type=max,type_input=f32,ne_input=[193,2,1,1],k0=128,k1=1,s0=128,s1=1,p0=128,p1=2): OK
- Dominant language
- C++
- Stars
- 136k
- Forks
- 26.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 521
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ggml-org/llama.cpp
-
bug-unconfirmed
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Misc. bug: router mode forwards the child's Connection: close, so keep-alive clients fail with 'other side closed'Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
llama-vocab: unbounded id_to_token.resize(n_tokens) from untrusted llama.vocab_size in no_vocab path (783-byte file allocates ~43 GB)Possibly taken @xztakin claimed this 2 days ago. Openbug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Llama chat webui. bug: scrollbar disappears when the mouse hovers near the top of the code blockPossibly taken A pull request linked to this issue is open or already merged. Openbug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ggml-org/llama.cpp#32465 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Eval bug: deepseek4 file with no ratio-4 (CSA) layer crashes with integer division by zero in the llama_kv_cache constructorPossibly taken @rishitha2625 claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ggml-org/llama.cpp#32424 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ggml-org/llama.cpp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/DirectXShaderCompiler#9173 ·
Maintainers usually reply within 2 days
-
arch-based bug niri
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
noctalia-dev/noctalia#5552 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
EchoTools/nevr-runtime#2912 ·
Maintainers usually reply within 1 day