Skip to content

hexagon: eliminate scalar VTCM loads via HVX splat helpers#22993

Merged
max-krasnyansky merged 5 commits into
ggml-org:masterfrom
qualcomm:tr/hvx-splat-vtcm
May 13, 2026
Merged

hexagon: eliminate scalar VTCM loads via HVX splat helpers#22993
max-krasnyansky merged 5 commits into
ggml-org:masterfrom
qualcomm:tr/hvx-splat-vtcm

Conversation

@trivikram-reddy1
Copy link
Copy Markdown
Contributor

@trivikram-reddy1 trivikram-reddy1 commented May 12, 2026

Overview

Scalar loads from VTCM are expensive on Hexagon. This PR removes scalar VTCM loads in matmul and flash attention, replacing them with HVX vector loads + splat (vdelta) operations.

Additional information

  • Add hvx_vec_repl helpers and use those for splat-from-vtcm usecase
  • Weight dequantization is significantly faster on the matmul path — the per-group scale stage was a measurable bottleneck before.
  • Flash attention slope handling is no longer gated on a scalar VTCM read.

Results from Snapdragon 8elite Gen 5

unsloth/Qwen3-4B-GGUF/Qwen3-4B-Q4_0.gguf (44% improvement in prefill TPS or TTFT)
Before:
prompt eval time = 2909.89 ms / 946 tokens ( 3.08 ms per token, 325.10 tokens per second)
eval time = 3179.95 ms / 63 runs ( 50.48 ms per token, 19.81 tokens per second)

After:
prompt eval time = 2020.47 ms / 946 tokens ( 2.14 ms per token, 468.21 tokens per second)
eval time = 3213.10 ms / 63 runs ( 51.00 ms per token, 19.61 tokens per second)

Requirements

@trivikram-reddy1 trivikram-reddy1 requested a review from a team as a code owner May 12, 2026 23:44
@github-actions github-actions Bot added script Script related ggml changes relating to the ggml tensor library for machine learning Hexagon labels May 12, 2026
@trivikram-reddy1
Copy link
Copy Markdown
Contributor Author

@max-krasnyansky @lhez. could you please review this PR.

@max-krasnyansky max-krasnyansky merged commit 856c3ad into ggml-org:master May 13, 2026
47 of 50 checks passed
xxmustafacooTR pushed a commit to xxPlayground/llama-cpp-turboquant that referenced this pull request May 13, 2026
…22993)

* hexagon: add hvx_vec_repl helpers and use those for splat-from-vtcm usecase

* hmx-mm: optimize per-group scale handling

* hmx-fa: optimize slope load from vtcm

* hmx-fa: use aligned access where possible in hmx-utils

* hexagon: add hvx_vec_repl_2x_f16 helper and consolidate repl helpers

---------

Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
@trivikram-reddy1 trivikram-reddy1 deleted the tr/hvx-splat-vtcm branch May 14, 2026 15:40
rsenthilkumar6 pushed a commit to rsenthilkumar6/llama.cpp that referenced this pull request May 19, 2026
…22993)

* hexagon: add hvx_vec_repl helpers and use those for splat-from-vtcm usecase

* hmx-mm: optimize per-group scale handling

* hmx-fa: optimize slope load from vtcm

* hmx-fa: use aligned access where possible in hmx-utils

* hexagon: add hvx_vec_repl_2x_f16 helper and consolidate repl helpers

---------

Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
ArberSephirotheca pushed a commit to ArberSephirotheca/llama.cpp that referenced this pull request May 19, 2026
…22993)

* hexagon: add hvx_vec_repl helpers and use those for splat-from-vtcm usecase

* hmx-mm: optimize per-group scale handling

* hmx-fa: optimize slope load from vtcm

* hmx-fa: use aligned access where possible in hmx-utils

* hexagon: add hvx_vec_repl_2x_f16 helper and consolidate repl helpers

---------

Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
njsyw1997 added a commit to aizip/llama.cpp that referenced this pull request May 20, 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 script Script related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants