Repository navigation
feat(sdk): run llama_cpp HTP on Hexagon SDK 5.5.x functional-safety firmware - #1499
Draft
Tadayuki Okada (TadayukiOkada) wants to merge 4 commits into
Draft
Tadayuki Okada (TadayukiOkada) wants to merge 4 commits into
Tadayuki Okada (TadayukiOkada) wants to merge 4 commits into
Conversation
Closed
10 of 11 tasks
Tadayuki Okada (TadayukiOkada)
marked this pull request as ready for review
September 30, 2026 16:53
Tadayuki Okada (TadayukiOkada)
marked this pull request as draft
October 2, 2026 13:15
DSP firmware built from Hexagon SDK 5.5.x rejects skels built against SDK 6.x headers, and functional-safety firmware also requires an SWIV CRC section. Add the cache variables to retarget the skels, and arm64-oe-linux-fusa presets that build with an OpenEmbedded gcc and sysroot for rootfs images older than the container targets. Signed-off-by: Tadayuki OKADA <TadayukiOkada@users.noreply.github.com>
The skel honored a release request only between op batches. A batch can be a whole graph, so a long prefill held both resources for its full duration; on functional-safety firmware the periodic DSP self-test then timed out and the host shut the DSP down. Signed-off-by: Tadayuki OKADA <TadayukiOkada@users.noreply.github.com>
…skel A transposed copy in a vision encoder runs about 70 ms as one op, longer than the 50 ms period of the functional-safety DSP self-test. Copy non-contiguous tensors in 128 KiB chunks and yield between them. Signed-off-by: Tadayuki OKADA <TadayukiOkada@users.noreply.github.com>
Such matmuls fell back to HVX. The SigLIP so400m FFN down projection (K = 4304) took about 100 ms per op, long enough to trip the functional-safety DSP self-test. Signed-off-by: Tadayuki OKADA <TadayukiOkada@users.noreply.github.com>
Tadayuki Okada (TadayukiOkada)
force-pushed
the
feat/llama-hexagon-sdk5-fusa
branch
from
October 2, 2026 22:17
c8702c9 to
45832d7
Compare
Tadayuki Okada (TadayukiOkada)
marked this pull request as ready for review
October 2, 2026 22:24
Tadayuki Okada (TadayukiOkada)
marked this pull request as draft
October 11, 2026 20:49
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the
llama_cppplugin's Hexagon (HTP) path usable on DSP firmware that is older than upstream ggml-hexagon assumes, including functional-safety firmware. Four commits:feat(sdk): build the HTP skels for Hexagon SDK 5.5.x firmwaresdk/patches/llama-hexagon-sdk-select.patchadds cache variables, all defaulting to upstream behavior:GGML_HEXAGON_HTP_SDK_ROOT/GGML_HEXAGON_HTP_TOOLS_ROOT: build only the skels with another SDK (the CPU-sidelibggml-hexagon.sostill needs SDK 6.x headers).GGML_HEXAGON_TOOLV: prebuilt lib dir prefix (toolv87/toolv86for SDK 5.5.x).GGML_HEXAGON_HTP_ARCHS: SDK 5.5.x has no QuRT for v79/v81.GGML_HEXAGON_SWIV_UTILITY: embed the SWIV CRC section that functional-safety firmware verifies before loading a library.qaicin the SDK 5.5.x layout without writing into the SDK.arm64-oe-linux-fusa-{debug,release}presets andsdk/cmake/arm64-oe-linux.cmake: build outside the container with an OpenEmbedded gcc and sysroot, for rootfs images older than the container targets (glibc 2.35 / libstdc++ 6.0.29).GENIEX_RUST_CC/GENIEX_RUST_AR, defaults unchanged) and passes the sysroot when one is set.notes/build.mddocuments the variables and the two on-device load failures they address.fix(sdk): release VTCM and HMX between ops in the HTP skelsdk/patches/llama-hexagon-yield-between-ops.patch: the skel checked for a VTCM/HMX release request only between op batches. A batch can be a whole graph, so a long prefill held both resources for its full duration. On functional-safety firmware the periodic DSP self-test then timed out and the host shut the DSP down. The skel now checks after every op; with no pending request the cost is one branch.fix(sdk): yield VTCM and HMX inside long copies in the HTP skelsdk/patches/llama-hexagon-yield-between-ops.patchnow also copies non-contiguous tensors in 128 KiB chunks and yields between them. A transposed copy in a vision encoder (SigLIP, 1152 x 1024 F32) runs about 70 ms as one op, longer than the 50 ms self-test period. It is folded into the existing patch because the configure-timegit apply --reverse --checkneeds patches that do not overlap.perf(sdk): run F16/F32 matmuls with K not a multiple of 32 on HMXsdk/patches/llama-hexagon-hmx-pad-k.patch: the flat 2D HMX matmul pads K to a multiple of 32 with zeros for F16/F32 weights. Such matmuls fell back to HVX; the SigLIP so400m FFN down projection (K = 4304) took about 100 ms per op, long enough to trip the self-test. On HMX it takes about 3 ms. Batched and fused paths keep requiring K aligned to 32.Test plan
Tested on an automotive board with functional-safety cDSP firmware (v73), Qwen3-0.6B Q4_0, all 29 layers on HTP0, built with
arm64-oe-linux-fusa-releaseand-DGGML_HEXAGON_TOOLV=toolv86.geniex-toolchain-{linux,android}:v0.1.0images:arm64-linux-snapdragon-{release,debug},arm64-linux-cpu-release,arm64-android-snapdragon-release,arm64-android-cpu-release. Snapdragon packages still carry all four skels (v73/v75/v79/v81), built with Hexagon Tools 19.0.07 and without an SWIV sectionarm64-windows-snapdragon-*(no Windows build host available)toolv87(Hexagon Tools 8.7.06 bundled in SDK 5.5.x): full configure, build and install pass; the skel has no unresolved imports against the firmware shell. On device: prefill of 32 to 2048 tokens and the default bench x 6 runs pass, generated text identical to thetoolv86skel-DGGML_HEXAGON_HTP_ARCHS="v73;v75"with SDK 5.5.7: full build and install pass, both skels carry the SWIV section (build only; no v75 device with such firmware was available). A v79 skel does not build with SDK 5.5.7, as documentedVision-model checks for the last two commits (all runs had #1505 applied as well):
test-backend-opson a v73 dev kit, built from the patched submodule with regression cases added locally (K = 100 / 4304 for F16 and F32 weights, 128 KiB-boundary and transposed CONT): MUL_MAT 735/735, CONT 68/68, CPY 134/134GGML_HEXAGON_DEVICES=2), 10-image prompt, 1 + 3 runs on the functional-safety board: same answer as the dev kit, no self-test failures. Longest op is the transposed copy (77 ms, yielding inside); FFN down is 3.4 ms. A VTCM + HMX client polling every 50 ms waited at most 6.8 ms (1200 samples, none over 50 ms)🤖 Generated with Claude Code