You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part of #1136 (Phase 2 of 5). Pure commonMain in skainet-backend-api — the SPI, the portable reference kernel, and the dispatch pack. No native dependency; mirrors the existing BitNetGemvNative / TernaryKernelPacks seam.
registers the native-backed view kernel under both the capability-free and capability keys (mirroring TernaryKernelPacks.install) only when native != null — without the native LUT kernel, the existing requantize→bitnet_gemv path remains the better portable fallback, so the exact key stays unregistered and behavior is unchanged
native view kernel: unwrap heap storage, loop rows for prefill (advance offsets by r*k / r*n), apply bitNetScale to outputs, fall back to the f32 reference (not BitNetGemvKernel) for non-heap storage
Rebase the Phase-1 FFM object onto the SPI: FfmTernaryF32Gemv : TernaryF32GemvNative + an install(warn) helper in skainet-backend-native-cpu/jvmMain
Tests
TernaryF32KernelPackTest (FakeNative, modeled on TernaryKernelPacksTest): exact-key selection beats the requantize path; pack absent → int8 path still serves; multi-row loop; scale application; install(null) warns and registers nothing
TernaryF32GemvKernelTest: reference vs TernaryCodec.decodeBitNet + naive FP32 matmul on random tensors (exact equality on the codes-dot; tolerance only for summation order)
Part of #1136 (Phase 2 of 5). Pure
commonMaininskainet-backend-api— the SPI, the portable reference kernel, and the dispatch pack. No native dependency; mirrors the existingBitNetGemvNative/TernaryKernelPacksseam.Tasks
TernaryF32GemvNative.kt— array-shaped native seam:TernaryF32GemvKernel.kt— portable referenceViewKernel: FP32 activation ×BITNET_B1_58weight, decode((byte >> 2*(i%4)) & 3) − 1, fp32 accumulate, post-multiply byTernaryCodec.bitNetScale.keyFor()= the exact keymatmul(FP32 dense contiguous × FP32/BITNET_B1_58 BLOCKED_ROW_MAJOR).TernaryF32KernelPack.kt—install(native: TernaryF32GemvNative?, capabilities, warn):TernaryKernelPacks.install) only whennative != null— without the native LUT kernel, the existing requantize→bitnet_gemvpath remains the better portable fallback, so the exact key stays unregistered and behavior is unchangedr*k/r*n), applybitNetScaleto outputs, fall back to the f32 reference (notBitNetGemvKernel) for non-heap storageFfmTernaryF32Gemv : TernaryF32GemvNative+ aninstall(warn)helper inskainet-backend-native-cpu/jvmMainTests
TernaryF32KernelPackTest(FakeNative, modeled onTernaryKernelPacksTest): exact-key selection beats the requantize path; pack absent → int8 path still serves; multi-row loop; scale application;install(null)warns and registers nothingTernaryF32GemvKernelTest: reference vsTernaryCodec.decodeBitNet+ naive FP32 matmul on random tensors (exact equality on the codes-dot; tolerance only for summation order)