feat(sdk): add baseline armv8.0-a linux build variant - #1340
Open
David Qian (Davidqian123) wants to merge 4 commits into
Open
feat(sdk): add baseline armv8.0-a linux build variant#1340David Qian (Davidqian123) wants to merge 4 commits into
David Qian (Davidqian123) wants to merge 4 commits into
Conversation
Baseline ARMv8.0 boards (NPU-less Dragonwing IoT SoCs such as unoq) trap on the LSE atomics the armv8.2 Snapdragon toolchain inlines into every mutex, so add a CPU-only armv8.0-a preset that uses -moutline-atomics instead. Derive the runtime HWCAP guard from the __ARM_FEATURE_* macros -march defines so it tracks the toolchain file instead of a hardcoded mask. Refs #1217 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: David Qian <yichqian@qti.qualcomm.com>
Refs #1217 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: David Qian <yichqian@qti.qualcomm.com>
install.sh reads /proc/cpuinfo and falls back to the -baseline asset when LSE atomics are absent; --baseline forces it. Point the CPU-unsupported hint at it. Refs #1217 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: David Qian <yichqian@qti.qualcomm.com>
Refs #1217 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: David Qian <yichqian@qti.qualcomm.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Problem
geniexcannot run on baseline ARMv8.0 boards — NPU-less Dragonwing IoT SoCs such as the Arduino UNO Q. #1180 made the failure graceful (a clear "missing CPU features" error instead of a rawSIGILL), but the board still can't do inference at all:That remaining half is what #1217 stayed open for.
Root cause (recap of #1217)
The aarch64-Linux toolchain compiles everything with
-march=armv8.2-a+fp16+dotprod(sdk/cmake/arm64-linux-gnu.cmake:8).armv8.2-aimpliesFEAT_LSE, so GCC inlines LSE atomics with no runtime fallback — everystd::mutexand thread-safe static-local guard lowers toLDADDAL/CAS. UNO Q is ARMv8.0 and implements none of it, so the first atomic in the process traps. Credit to @mengshen_QCOM for decoding the faulting bytes.Which of the two options
We need to pick solution between a baseline
armv8.0-abuild variant and option 1 (-moutline-atomics+ runtime-dispatched ggml kernels). Option 1 is the larger change, not the smaller one:GGML_CPU_ALL_VARIANTSeven ships anarmv8.0_1variant (ggml/src/CMakeLists.txt:408) — but it requiresGGML_BACKEND_DL=ON, which we setOFF(sdk/plugins/llama_cpp/CMakeLists.txt:5). Turning it on makes ggml-cpu / hexagon / opencldlopen'd backends, changing packaging and backend discovery for the shipping Snapdragon artifact.LDADDALthat trapped comes from the global-marchapplied to the SDK's own C++ and to ggml-base — not from ggml-cpu kernels. So option 1 = this PR's flag change plus a risky refactor of the NPU path.So this PR takes the baseline variant.
GGML_CPU_ALL_VARIANTSstays on the table as a later unification, onceGGML_BACKEND_DLis de-risked on Snapdragon — at which point the two Linux artifacts could collapse back into one.Fix
sdk/cmake/arm64-linux-gnu-baseline.cmake—-march=armv8-a+crc -moutline-atomics. Atomics route through libgcc's runtime-dispatched helper: LSE whenHWCAP_ATOMICSis present, LL/SC otherwise. Dropping+fp16/+dotprodmeans ggml falls back to its fp32 quant kernels — slower, but it runs.+crcis kept; it's the one guarded extension these cores do implement.arm64-linux-baseline-{debug,release}presets — CPU-only (GENIEX_PLUGIN_QAIRT,GGML_HEXAGON,GGML_OPENCLall off). An ARMv8.0 Dragonwing board has no NPU and no Adreno to target, so the plugins would be dead weight.sdk/src/ml.cpp— the HWCAP guard mask is now derived from the__ARM_FEATURE_*macros-marchdefines, instead of a hand-maintained list with a "keep in sync with-march" comment. For the Snapdragon build the mask is unchanged; for the baseline build it collapses tocrc32and the board passes.sdk-linux-arm64-baselineandcli-linux-arm64-baselineartifacts; releases additionally shipgeniex-cli-linux-arm64-baseline-<tag>.tar.gz,geniex-sdk-linux-arm64-baseline-<tag>.zip, and a baselinegeniex-bencharchive.install.sh— picks the baseline asset when/proc/cpuinfohas noatomics,--baselineforces it, and the fastrpc symlink step is skipped there (no HTP plugin to resolve for). The CPU-unsupported CLI hint now points at it instead of only saying "use a newer device".notes/build.md.Testing
Verified on
WADTestBoard01— the same UNO Q from #1217 (Features: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid; noatomics, noasimddp, nofphp). Artifacts are this PR'spr-checkrun 31768117636, not a local build.The trapping instruction is now runtime-dispatched.
ldaddalis still present inlibgeniex.so, but only inside libgcc's outline helpers, behind a branch on__aarch64_have_lse_atomics:Attributing every LSE-class instruction in the artifact to its enclosing function: 100/100 sit inside
__aarch64_*helpers, none inlined into our code.dotprod/i8mminstruction count is 0 acrosslibgeniex.so,libggml-cpu.so, andlibllama.so.geniex-benchruns, no SIGILL —--plugin llama_cpp --device cpu, Qwen3-0.6B Q4_0,-c 512 -p 64 -n 32 -t 4:ttft=4093.3ms prefill=15.6tps decode=8.1tps,exit=0.--accuracy --prompt-file(the timing mode's random-id prefill produces meaningless text by design): "France is located in Europe, and its capital is Paris."geniex versionandgeniex listalso work.linux-arm64(Snapdragon) artifact from the same CI run on this same board. It must still refuse, and it does — cleanly, no SIGILL:lint(cpp-format / go-lint / rust-format / ruff),test-rust, all fourbuild-sdkjobs, and both Linuxbuild-clijobs green.Throughput on UNO Q (Qwen3-0.6B Q4_0, 4 threads): ~15.5 tok/s prefill, ~8.1–8.6 tok/s decode. Well below what an armv8.2 build achieves, which is the expected cost of losing
dotprod/fp16, but usable on a 4-core / 1.7 GB board.Follow-ups
publish-s3runs fromqcom-ai-hub/geniex@chore/publish-s3, sogeniex-cli-linux-arm64-baseline.tar.gz(the mutable "latest stable" key) needs the same mapping added there. Until theninstall.shon an ARMv8.0 board needs--version vX.Y.Z. @hongzhic_QCOM could you take that side?pr-check. Both are CPU-only and ccached, so they should stay under the Snapdragon job's wall time — say the word if you'd rather gate them to release builds only.