fix(dispatch): ternary kernel packs join the self-healing SPI (#1240) - #1241
Merged
Merged
Conversation
The 0.52.0 self-healing dispatch discovered the Q-series row-major packs but not the ternary ones: a consumer loading BITNET_B1_58 / BITNET_PLANES weights silently fell to the int8-requantize or decoding-reference path (~120x slower per the #1141 bench) unless it called the two installs explicitly — exactly the failure mode ensureInstalled() exists to eliminate, and why SKaiNET-transformers' CLI still carries explicit NativeTernaryF32GemvKernel.install() lines. - FfmTernaryKernelPackFactory (jvm jar) and JniTernaryKernelPackFactory (Android AAR), listed in the ViewKernelPack service files: install the exact FP32xB1.58 LUT gemv and the fused BITNET_PLANES lm_head; both degrade to a no-op lookup when the bundled native library is missing. - Kotlin/Native note: no ServiceLoader there — NativeKnTernaryF32Gemv / NativeKnTernaryLmhead stay explicit, now said in ViewKernelPack.other.kt and the ternary tutorial's install table (automatic vs explicit). - KernelDispatchSelfHealTest: cold dispatch must resolve matmul(FP32 x BITNET_B1_58) to the LUT kernel with zero explicit installs (skips cleanly where the native library is absent). Closes #1240. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKeDSK4JF295y53Uvez954
|
📖 Documentation Preview The documentation has been built successfully for this PR. Generated Files:
Artifacts:
This comment will be updated automatically when the PR is updated. |
This was referenced Sep 1, 2026
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.
Closes #1240. Part of the ternary track #1136.
What
The 0.52.0 self-healing dispatch (
KernelDispatch.ensureInstalled()over theViewKernelPackServiceLoader SPI) discovered the Q-series row-major packs but not the ternary ones — a consumer loadingBITNET_B1_58/BITNET_PLANESweights silently got the int8-requantize or decoding-reference path (~120× slower per the #1141 bench: 51.8 vs 0.43 GOPS) unless it calledNativeTernaryF32GemvKernel.install()/NativeTernaryLmheadKernel.install()explicitly. That is exactly the failure mode the self-healing release exists to eliminate, and why SKaiNET-transformers' CLI still carries explicit install lines (skainet-cli/Main.kt:249-250there — droppable once this ships in a consumed BOM, tracked in SKaiNET-transformers#360).FfmTernaryKernelPackFactory(jvm jar) andJniTernaryKernelPackFactory(Android AAR), listed in the twoMETA-INF/services/sk.ainet.backend.api.kernel.ViewKernelPackfiles. They install the exact FP32×BITNET_B1_58LUT gemv and the fusedBITNET_PLANESlm_head; both delegate to the packs'install(native?), which registers nothing when the bundled native library is missing — same contract as the row-major factories.ServiceLoader:NativeKnTernaryF32Gemv/NativeKnTernaryLmheadstay explicit — now stated inViewKernelPack.other.ktand in the ternary tutorial's install table (automatic vs explicit per target).Verification
KernelDispatchSelfHealTest.cold_dispatch_discovers_the_ternary_packs: a cold dispatcher —clearForTesting()thenensureInstalled(), no bootstrap of any kind — must registerternary_f32_gemv/ffm+ternary_planes_matmul/ffmand resolvematmul(FP32 × BITNET_B1_58)viaTernaryF32GemvKernel.keyFor(). Skips cleanly where the native library is absent. Observed on macosArm64:Full
skainet-backend-native-cpujvmTest suite and the AndroidcompileReleaseKotlinare green.🤖 Generated with Claude Code
https://claude.ai/code/session_01YKeDSK4JF295y53Uvez954