Skip to content

hexagon: fix CPY fence bug - #28033

Merged
max-krasnyansky merged 1 commit into
ggml-org:masterfrom
yshsharke:hexagon-cpy-fence-fix
Aug 30, 2026
Merged

hexagon: fix CPY fence bug#28033
max-krasnyansky merged 1 commit into
ggml-org:masterfrom
yshsharke:hexagon-cpy-fence-fix

Conversation

@yshsharke

Copy link
Copy Markdown
Contributor

Overview

On Hexagon backend, for normal CPY, op_cpy() treats any non-null src[1] as a synchronization fence and stores the fence sequence into the first four bytes of src[1]. This corrupts the ordinary CPY destination.

This PR adds a condition to limit the atomic fence store to only the explicit fence tensor with HTP_TENSOR_FENCE flag.

Additional information

Test on Hexagon v81 with test-backend-ops shows that the normal CPY case is fixed. The test command is:

test-backend-ops test -b HTP0 -o CPY

Passed Failed
Before 0 134
After 134 0
Failed Test Case Example

test-backend-ops test -b HTP0 -o 'CPY(type_src=f32,type_dst=f32,ne_src=[256,4,3,1],permute_src=[0,0,0,0],permute_dst=[0,0,0,0],_src_transpose=1)' -j 1

ggml_opencl: selected platform: 'QUALCOMM Snapdragon(TM)'

ggml_opencl: device: 'QUALCOMM Adreno(TM) 840 (OpenCL 3.0 Adreno(TM) 840)'
ggml_opencl: default device: 'QUALCOMM Adreno(TM) 840 (OpenCL 3.0 Adreno(TM) 840)'
ggml-hex: Loading driver libcdsprpc.so
ggml-hex: FASTRPC_GET_DOMAINS[0]: type 1 id 1000 name 'nsp1000' status 1 instance-id 0
ggml-hex: using CDSP domain: instance-id 0 id 1000 name 'nsp1000'
ggml-hex: Hexagon backend (experimental) : allocating new registry : ndev 1
ggml-hex: Hexagon Arch version v81
ggml-hex: HTP0 allocating new session
ggml-hex: HTP0 hwinfo: threads 8, hvx 8, hmx 1, vtcm 8 MB
ggml-hex: HTP0 new session : session-id 0 domain-id 100000 uri file:///libggml-htp-v81.so?htp_iface_skel_handle_invoke&_modver=1.0&_dom=nsp1000&_session=0 handle 0xb4000070205c1a40
ggml-hex: HTP0 op batching: n-bufs 16 n-tensors 8192 n-ops 1024 vmem 3355443200
Testing 3 devices

Backend 1/3: GPUOpenCL
  Skipping
Backend 2/3: HTP0
  Device description: Hexagon
  Device memory: 0 MB (0 MB free)

[CPY] ERR = 0.000563718 > 0.000000000   CPY(type_src=f32,type_dst=f32,ne_src=[256,4,3,1],permute_src=[0,0,0,0],permute_dst=[0,0,0,0],_src_transpose=1): FAIL
  0/1 tests passed

Failing tests:
  CPY(type_src=f32,type_dst=f32,ne_src=[256,4,3,1],permute_src=[0,0,0,0],permute_dst=[0,0,0,0],_src_transpose=1)
  Backend HTP0: FAIL
Backend 3/3: CPU
  Skipping
2/3 backends passed
FAIL

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, this bug was found and analyzed by AI. I have run the tests, and I am responsible for all submitted changes.

@yshsharke
yshsharke requested a review from a team as a code owner August 30, 2026 15:56
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning Hexagon labels Aug 30, 2026
@max-krasnyansky

Copy link
Copy Markdown
Member

Oh. I missed this one in the tests. Looks like the test makes src[1] == dst. Normally that's not the case.

@max-krasnyansky

Copy link
Copy Markdown
Member

@lhez for second ack

@max-krasnyansky
max-krasnyansky merged commit 9723942 into ggml-org:master Aug 30, 2026
24 of 28 checks passed
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request Sep 5, 2026
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants