Skip to content

feat(decode): shared DecodeSession core + the Android activity leg (SKaiNET#1244) - #395

Merged
michalharakal merged 2 commits into
developfrom
feat/1244-decode-core
Sep 2, 2026
Merged

michalharakal merged 2 commits into
developfrom
feat/1244-decode-core

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Implements SKaiNET#1244 — the Android half of skainet-decode (the JVM leg shipped in #369/#370).

llm-apps:skainet-decode-core (new KMP library, jvm + android): the decode flow extracted from Main.kt into a common DecodeSession — sink/ctx construction (RecordingTraceSink, KernelDispatch.defaultSink, delegating context, ensureInstalled()), BOS logic, the traced prefill/decodeStep/sample loop, GenerationMetrics.from(events, peakBytesPerSecond). MemoryProbe.sample().emitTo(sink) runs inside every decode span, so the page-fault/RSS rows light up on Android AND Linux JVM. Optional extraSink composes AndroidTraceSink for Perfetto. The JVM CLI becomes a thin caller — output verified byte-identical with a real SmolLM2-135M Q8_0 run.

llm-apps:skainet-decode-android (the repo's first com.android.application, AGP 9 built-in Kotlin): single classic-Views activity — path pre-filled to the app's external-files dir (adb-push workflow, README'd; no SAF since content:// can't mmap by path, no assets), pre-flight AndroidGguf.deviceMemory/fits(weightsMapped = true) verdict that refuses before allocating, whole load+decode on one dedicated thread (RecordingTraceSink is not thread-safe), decode via MappedRandomAccessSource so the major-fault rate is meaningful, report → screen + logcat SkDecode + decode-report.md. largeHeap=true with the SKEEP-002 config-split note; runtimeOnly jni-cpu AAR, no nativeCpu/FFM; packaging keeps META-INF/services/** so the 0.52.0 self-healing SPI survives — verified in the APK: both .so variants plus the ViewKernelPack/KernelProvider service entries.

Also: androidApplication catalog alias, settings/root wiring, architecture.adoc module tree, module README with the SKEEP-002 acceptance numbers ("≤ 40 MB managed heap for SmolLM2-135M Q8_0"; "~600 MB Q4_K on a 256 MB heap", measured largeHeap-off).

Verified: :llm-apps:skainet-decode:run (JVM regression gate) and :llm-apps:skainet-decode-android:assembleDebug + APK inspection. Remaining for the device lane (no device attached here): install on a physical arm64 device, capture the report pair, record the numbers.

michalharakal and others added 2 commits September 2, 2026 11:21
… (SKaiNET#1244)

The skainet-decode flow — GGUF peek, tokenizer, family-dispatched weight
load, OptimizedLLMRuntime, and the traced prefill/decode/sample loop that
feeds GenerationMetrics — moves verbatim into a new KMP module (jvm +
android) so the Android activity leg reports the same numbers from the
same loop. The JVM CLI becomes a thin caller owning only arg parsing, the
JvmRandomAccessSource, and stdout; its output is unchanged.

One addition over the JVM-only flow: MemoryProbe.sample().emitTo(sink)
inside every decode span, which lights the page-fault/RSS rows on any
platform with a /proc answer (Android, Linux) and stays "—" elsewhere.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…(SKaiNET#1244)

First com.android.application in the repo: llm-apps:skainet-decode-android,
a thin caller of skainet-decode-core's DecodeSession. Pre-flight
AndroidGguf.fits verdict before a byte of payload is read, mapped weights
via MappedRandomAccessSource (major-fault rate becomes meaningful),
AndroidTraceSink composed for Perfetto, the whole session on one worker
thread (RecordingTraceSink is single-threaded), report mirrored to logcat
tag SkDecode and decode-report.md in the app's external-files dir for
adb pull. largeHeap=true as shipped; the SKEEP-002 256-MB-heap measurement
flips it off (documented in the README with the kernel-fallback caveat).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michalharakal
michalharakal merged commit 3513559 into develop Sep 2, 2026
4 checks passed
@michalharakal
michalharakal deleted the feat/1244-decode-core branch September 2, 2026 10:13
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