Skip to content

Feat: Migrate to unified KleidiAI build and direct internal model downloads - #137

Open
afalefesifiofo wants to merge 2 commits into
shubham0204:mainfrom
afalefesifiofo:main
Open

afalefesifiofo wants to merge 2 commits into
shubham0204:mainfrom
afalefesifiofo:main

Conversation

@afalefesifiofo

Copy link
Copy Markdown

Description

This PR significantly improves the C++ architecture and Android integration for LLM inference in SmolChat.

Changes Included:

  • Unified KleidiAI Dispatch: Removed the 8 fragmented CMake target variants in favor of a single arm64-v8a target. The runtime now uses KleidiAI micro-kernels to dynamically dispatch to the best matrix multiplication operations (SVE, DotProd, i8mm, Neon) based on the device's CPU topology.
  • Redundant Submodule Removal: Removed the unneeded llm-runner submodule and implemented a clean, standardized LLMRunner abstraction locally in C++.
  • Kotlin Integration & Dependencies: Downgraded Kotlin serialization to 2.0.0 to cleanly match the base KSP version requirements.
  • Direct Model Downloading: Replaced DownloadManager with the internal Ketch downloader. Models are now downloaded directly into the app's filesDir. This completely eliminates the need for the Android File Picker and prevents 1.5GB models from being duplicated across internal and shared storage.
  • Automated GGUF Parsing: After a successful download, the ViewModel natively parses the GGUF metadata (context size, jinja templates) and automatically registers the model to the Room Database.
  • Benchmark Improvements: Improved the bench_model JNI implementation by adding an initial cache warmup pass (producing more reliable throughput numbers) and explicitly printing the Time To First Token (TTFT) in milliseconds.

Ale added 2 commits September 16, 2026 14:48
…and standard LLMRunner

- Consolidate CMake build to a single arm64-v8a target using KleidiAI native dispatch.

- Downgrade kotlin serialization to 2.0.0 across modules to match KSP version.

- Remove redundant LLM-Runner submodule and implement LLMRunner abstraction locally.

- Simplify SmolLM.kt and LLMInference.cpp by delegating core inference loop to LLMRunner.
- Refactor DownloadModelsViewModel to use internal Ketch DownloadService.

- Models now download directly to app's internal filesDir, preventing duplicate storage.

- Automate GGUF metadata extraction and Room DB model registration upon download completion.

- Add TTFT (Time To First Token) metric and cache warmup pass to C++ bench_model.
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.

1 participant