Repository navigation
Extract native library candidates and rank Linux arm64 CPU variants - #1459
Merged
Merged
Conversation
Library file names, patterns, asset URIs and the Android CPU-variant ranking now take the host OS, module directory and directory listing as inputs, so every platform's naming is table-tested on any host. Open and probe loops stay in LlamaCppService. The only behavior change: an unreadable Android module directory no longer throws from sorting a const empty list while ranking CPU modules. Refs #354
With a module directory on Linux arm64, the CPU module candidates try libggml-cpu-linux_armv8.6_1.so, then linux_armv8.2_2, then the baseline. ggml_backend_load rejects a variant whose score is 0, so an unsupported CPU falls through to the baseline. The order matches descending ggml_backend_score, so the startup and explicit-mode load picks the module ggml_backend_load_all_from_path picks and ggml registers one CPU backend. Refs #354, #675
…ctor/354-native-library-candidates
…ctor/354-native-library-candidates
Contributor
|
Chat app preview removed for |
12 of 13 tasks
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
llama_cpp_service.dartintolib/src/backends/llama_cpp/native_library_candidates.dart(LlamaCppLibraryCandidates, internal). Backend/ggml/wrapper/mtmd file names, patterns, asset URIs, wrapper lookup paths and the Android CPU-variant ranking now take host OS, ABI, module directory and directory listing as inputs. The open/probe loops and every guarded native call stay inLlamaCppService. One deliberate behavior change: when the Android module directory can't be read, the code used to throwUnsupportedError(it calledsorton aconst []). It now returns no names.libggml-cpu-linux_armv8.6_1.so, thenlibggml-cpu-linux_armv8.2_2.so, then the baselinelibggml-cpu.so.ggml_backend_loadreturns NULL for a variant whose score is 0, so the loop falls through to the baseline.Why this matters beyond explicit modes:
initializeBackendalways loads the CPU module through these candidates before any model load. Onmain, a Linux arm64 bundle from #127 therefore registers the baseline first, andauto(ggml_backend_load_all_from_path) then adds the variant as a second CPU backend. ggml/llama.cpp use the first CPU device, so evenautowould stay on the baseline. The new order matches descendingggml_backend_score(aarch64 score: 8.2_2 = 1+2+4 = 7, 8.6_1 = 7+16 = 23). The first module that loads is the same fileload_bestpicks, and ggml'sregister_backenddrops the repeatedreg. The result is one CPU backend whichever order auto and explicit loads run in.Production-readiness scope
cpu,vulkan,blas,auto). No current release bundle ships them yet, so nothing changes until the native pin moves.libggml-cpu.so. Variants not in the list (for example a futurelinux_armv9.*) sort after the baseline until llamadart adds their rank. That keeps an unscored or unaudited module from being tried first. No asset-URI variants are added for Linux.Completeness checklist
native-build-hooks.mdgets a Linux arm64 CPU variants section, and one Unreleased bullet in both changelogs. There is no public API.)PR type guidance
native_library_candidates_test.dart.Test Plan
dart run tool/prepare_workspace.dart(clean tree afterwards)dart format --output=none --set-exit-if-changed .dart analyzedart run tool/testing/check_platform_boundaries.dartTMPDIR="$(mktemp -d)" dart test -p vm -j 1 --exclude-tags local-only test/unit/backends/llama_cpp/ test/unit/test_structure/ test/unit/tooling/ test/unit/hook/(2703 passed, macOS). The full VM and Chrome suites run in CI.dart test -p chrome --exclude-tags local-only: CI only. No web-reachable file changed.main(see Matrix Evidence)Matrix Evidence
mainorigin/main's methods, with onlyPlatform.isXreplaced by an injected OSlinux/linuxArm64/cpureorders of the variant fixtures. The committed table tests run against the same oracle: 15/16 pass, and the one failure is the documented Android throw. Oracle is scratch-only, not committeddebugLlamadartWrapperLibraryCandidatesForTesting()main vs branchnative_library_candidates.dartggml-baseasset, backend regex escape, Android static variants, baseline rank, Apple framework names, mtmd suffix patternggml_backend_loadof an unsupported variant returns NULL. Loading the same file twice gives one CPU device. Explicit baseline plus auto on N1 gives two devices with the baseline first, which is what this PR removes. The ranked-then-auto sequence itself has not been run on Linux arm64high-risk-exact-head-independent-qa3003c25a2/8dede4429c470d3eBLOCKED on one P1 (test missing@TestOn('vm'), broke Test Web (Chrome)); fixed in3031a099d. Delta re-audit CLEAR at3003c25a2: 12,600-case differential vs main, ggml dedupe/score analysis, mutants killed. Evidencellamadart-evidence/pr-1459/r2/evidence-1459-3003c25.json;high_risk_readiness.dartexits 2.release-metadata-verificationstructured-output-adversariallitert-lm-json-schemaReview Notes
3003c25a2(independent auditor sessions). P3: service wiring mutants (abi,moduleDirectory,listFiles) survive unit tests; Linux arm64 hardware run left for Qwen3-TTS: cancellation takes ~800 ms on Linux arm64 CPU, over the tts pack's 500 ms budget #675.3003c25a2a21b08495f82fe3a420745434366d4e(main8dede4429merged in, no conflicts), CI: 32 pass, 5 skipped, 0 failing (run 40515608087)High-risk regression review
backendRuntime)3003c25a2/8dede4429os: Platform.operatingSystem,abi: _abi) has no unit test that can see it, becauseggml_backend_loadis native. The host wrapper-candidate comparison and the differential oracle cover the moved call sites.