feat(backends): JNI + Kotlin/Native faces of the fused lm_head kernel (#1150) - #1172
Merged
Merged
Conversation
JniTernaryLmhead and NativeKnTernaryLmhead complete the TernaryLmheadNative seam over skainet_ternary_lmhead_stage1 — the fused 4-plane BITNET_PLANES kernel now reaches all three bridges, closing #1150. The FP16 row scales live inside the weight buffer, so both shims derive the uint16_t* from the pinned weight at rowScaleByteOffset (2-byte aligned by the seam's contract). No capability split, as with the gemv: baseline NEON only. Parity on both bridges against a local reimplementation of the 4-plane fused contract over real codec-encoded buffers — both plane windows (0-3 and 4-7, the two calls the view kernel combines), BitNet hidden size, and the C kernel's internal 4-thread pool. Verified locally: macosArm64Test green (real NEON through cinterop), JNI AAR + test APK build with NDK; the qemu lane covers linuxArm64 in CI. Closes #1150 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…heck The binary-compatibility validator's jvmApiCheck wants the .api dump to name what #1171 made public — TernaryCodec's plane codec functions, BitNetPlanesTensorData, and TensorEncoding.BITNET_PLANES. This also heals the check on develop, which went red when #1171 merged without the dump. Refs #1150 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes #1150 (follows #1171, which landed the encoding, codec, pack, FFM face, and loader requantizer).
What
ternaryLmheadStage1shim (pins three arrays; derives theuint16_t*row-scale pointer from the pinned weight atrowScaleByteOffset),JniKernelsexternal,JniTernaryLmhead : TernaryLmheadNative+install(). Baseline.socarries the full NEON path — no capability split.NativeKnTernaryLmheadover the auto-exposed cinterop symbol (.defunchanged); row-scale pointer = pinned weightaddressOf(rowScaleByteOffset);inputDim == 0zeroes the output without pinning empty arrays.BITNET_PLANESbuffers — both plane windows (0–3 and 4–7, the two callsNativeTernaryPlanesViewKernelcombines), BitNet hidden size (k=2560), and the kernel's internal 4-thread pool.Verified locally
:skainet-backend-native-cpu:macosArm64Test— 3/3 green (real NEON through cinterop):skainet-backend-jni-cpu:assembleDebug+assembleDebugAndroidTest— both.sovariants + test APK build with NDKlinuxArm64Test -PcrossArm64=trueqemu lane;JniKernelParityTeston an arm64 deviceWith this, every SKaiNET-side phase of #1136 is code-complete: #1137–#1141, #1150. Remaining: the #1166 compliance gate, then a release for transformers#335.
🤖 Generated with Claude Code