Skip to content

Validate kllama Apple native-kernel fix (PR #315) on real iOS/macOS hardware #316

Description

@michalharakal

Context

PR #315 fixed llm-runtime/kllama's PlatformNativeKernels.ios.kt/.macos.kt,
which were stale no-op stubs — both cited SKaiNET#959 as "not shipped yet" when
it had in fact shipped, meaning kllama's registerPlatformBackends() facade
was silently leaving packed-quant matmul on the scalar floor on iOS and macOS,
despite the engine's native-cinterop NEON/Accelerate kernels being built and
available.

The fix itself (calling installNativeKernels(), mirroring linuxMain's
actual) was written and reviewed, but could not be compiled or run in the
session that produced it — that environment was Linux only, and Kotlin/Native
requires a macOS host to compile Apple targets at all. Verification there was
limited to code review and cross-target compilation (jvm/linuxX64/android/js).

What needs a Mac

  • ./gradlew :llm-runtime:kllama:compileKotlinIosArm64 :llm-runtime:kllama:compileKotlinIosSimulatorArm64 :llm-runtime:kllama:compileKotlinMacosArm64 — confirm the fix actually compiles (the installNativeKernels() import/call was written against the API but never type-checked on an Apple target). Update: it did not compile as originally written — implementation(libs.skainet.backend.nativeCpu) was still scoped to linuxMain only, not nativeMain, so macosMain/iosMain never got the dependency. Fixed in PR fix(kllama): stop leaving packed-quant matmul scalar-only on iOS/macOS #315 commit 9bb3707; all three Apple targets now compile.
  • At runtime, confirm KernelRegistry.bestAvailable()?.name (or equivalent) reports native-cinterop on iOS/macOS after registerPlatformBackends() runs, not scalar. Confirmed via KernelRegistry.availableNames() on both macosArm64Test and iosSimulatorArm64Test: reports [native-cinterop].
  • A real before/after comparison: packed-quant matmul throughput with the old no-op stub vs. the fix, on an actual Apple Silicon device/simulator — the engine's own NEON/cinterop work (#958/#959) reported real numbers on Android-equivalent hardware; this fix has none yet for Apple.
  • Run kllama's existing test suite on iosSimulatorArm64Test/macosArm64Test (both currently skip on CI/Linux — kotlin.native.ignoreDisabledTargets). Both green, including the cross-target SmolLm2InferenceSpike (commonTest).

Related

Good fit for whoever on the team has a Mac + Xcode handy — no deep kernel-SPI knowledge needed, mostly "build it, run it, check the numbers." Remaining: real-device throughput numbers (needs physical hardware time, not just simulator/compile verification).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions