Skip to content

feat(kllama,kgemma): ship the Android NEON backend with the runtime facades (#285) - #286

Merged
michalharakal merged 1 commit into
developfrom
fix/android-jni-backend-wiring-285
Aug 11, 2026
Merged

michalharakal merged 1 commit into
developfrom
fix/android-jni-backend-wiring-285

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Closes #285.

Engine 0.39.0 ships sk.ainet.core:skainet-backend-jni-cpu — an AAR with NEON kernels for Q8_0 / Q4_0 / Q4_K / Q5_K / Q6_K and runtime dotprod dispatch, ServiceLoader-registered on ART. This PR makes the two Android runtime facades carry it, so an Android app that depends on runtime-kllama or runtime-kgemma gets native kernels out of the box instead of silently falling back to the scalar Kotlin matmul (measured on a Pixel 8a: ~24 tok/s vs ~3.8 tok/s decode-kernel throughput on SmolLM2-135M Q8_0, engine PR SKaiNET#945).

Changes:

  • gradle/libs.versions.toml: catalog entry skainet-backend-jniCpu (version-less; the engine BOM re-exported by :llm-bom carries the 0.39.0 constraint — verified in the published skainet-bom-0.39.0.pom).
  • llm-runtime/kllama + llm-runtime/kgemma: runtimeOnly(libs.skainet.backend.jniCpu) in androidMain. runtimeOnly because the backend has no compile-time API surface — discovery is ServiceLoader-only.
  • README: note under the supported-targets matrix — facades get NEON automatically; apps driving llm-inference/llama + transformer-core directly should add the AAR themselves; excluding the artifact opts back into pure Kotlin.
  • CHANGELOG entry under [Unreleased].

Verified locally:

  • :llm-runtime:kllama:dependencies --configuration androidRuntimeClasspath and the kgemma equivalent both resolve skainet-backend-jni-cpu -> 0.39.0 (BOM-constrained).
  • :llm-runtime:kllama:assembleAndroidMain and :llm-runtime:kgemma:assembleAndroidMain build clean.

Cost note for reviewers: consuming apps gain four small .so files (arm64-v8a + armeabi-v7a × baseline/dotprod tiers). If you'd rather keep the facades dependency-free and make this opt-in-by-docs instead, happy to flip the PR to a README-only change.

…acades (#285)

Add sk.ainet.core:skainet-backend-jni-cpu (engine 0.39.0) as a runtimeOnly
dependency of the androidMain source sets. The backend self-registers via
ServiceLoader on ART, so presence on the runtime classpath is sufficient —
Android consumers get NEON kernels (Q8_0/Q4_0/Q4_K/Q5_K/Q6_K, runtime
dotprod dispatch) instead of the scalar Kotlin fallback. Version comes from
the engine BOM re-exported by :llm-bom.

Document the behavior in the README target-matrix section and CHANGELOG.
@michalharakal
michalharakal merged commit 08474b0 into develop Aug 11, 2026
2 checks passed
@michalharakal
michalharakal deleted the fix/android-jni-backend-wiring-285 branch August 11, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android apps using the runtime facades still run scalar Kotlin — ship sk.ainet.core:skainet-backend-jni-cpu with kllama/kgemma

1 participant