Misc. bug: Hexagon: test-backend-ops POOL_2D fails for 128-wide kernels with padding on HTP0 (v73)

Aperta Adatta ai principianti
#32,598 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

Inizia da ggml/src/ggml-hexagon/ ed esamina pool_pixel_boundary_vec, in particolare la maschera di predicato costruita con Q6_Q_vsetq_R; confrontala con Q6_Q_vsetq2_R e segui come pool_row_general_vec usa questo percorso. Esegui test-backend-ops -b HTP0 -o POOL_2D; il lavoro è completato quando tutti i 144 casi passano, inclusi i quattro casi con padding e kernel largo 128.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug-unconfirmed
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
Lingua principale
C++
Stelle
136k
Fork
25.7k
Merge medio
2g 1h
PR unite (30g)
524

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ggml-org/llama.cpp

Tutte le issue di ggml-org/llama.cpp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.