feat(kernel): Panama Vector FP32 matmul provider (M5)#557
Merged
michalharakal merged 1 commit intodevelopfrom Apr 28, 2026
Merged
feat(kernel): Panama Vector FP32 matmul provider (M5)#557michalharakal merged 1 commit intodevelopfrom
michalharakal merged 1 commit intodevelopfrom
Conversation
Implements `PanamaVectorMatmulKernel` (jdk.incubator.vector, FloatVector + fma + reduceLanes) and `PanamaVectorKernelProvider` against the kernel SPI from PR #554. Picks up automatically over `ScalarKernelProvider` once registered, and respects the existing `-Dskainet.cpu.vector.enabled=false` kill switch. Closes the M5 "Panama-first" half of the JVM perf milestone plan. Routing `DefaultCpuOpsJvm.matmul` through the SPI and adding a ServiceLoader-based auto-registration are deferred to follow-ups so this PR stays focused on the kernel itself. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 28, 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.
Summary
PanamaVectorMatmulKernel(jdk.incubator.vector —FloatVector+fma+reduceLanes) implementing theFp32MatmulKernelSPI from feat(kernel): add KernelProvider SPI for matmul dispatch (Scalar baseline) #554.PanamaVectorKernelProvider(name = \"panama-vector\",priority = 50). Sits aboveScalarKernelProvider(0) and below a future native provider (100).isAvailable()requires JDK 21+, thejdk.incubator.vectormodule on the path, and respects the existingskainet.cpu.vector.enabledkill switch (-DorSKAINET_CPU_VECTOR_ENABLED).Why this shape
B^Tinto a contiguous(n, k)buffer so the inner reduction streams sequentially overkfor both operands. One pack + one FMA accumulator per output cell, scalar tail for the lanes that don't fill a vector.ScalarMatmulKernelis not guaranteed (FMA + reordered accumulation), but parity within1e-5 * ktolerance is asserted across contiguous, strided sub-blocks, non-alignedk(tail loop), and randomized larger sizes. This matches the per-milestone golden-output regression bar in the roadmap.Out of scope (follow-ups)
DefaultCpuOpsJvm.matmulthrough the kernel SPI. Today it still callsJvmVectorKernels.matmulFloat/matmulFloatBlockeddirectly; until that routing change lands, the existingMatmulBenchwon't exercise this provider end-to-end.:skainet-backends:benchmarks:jvm-cpu-jmhis the natural home.ServiceLoaderauto-discovery inKernelRegistry. The SPI doc explicitly defers this until a second concrete JVM provider exists — that condition is now met, so this is a clean small follow-up PR.JvmVectorKernels.matmulFloatBlocked). Useful if the simple FMA path doesn't clear the ≥4× target on 512² thatdocs/.../perf/jvm-cpu.adocmentions.Test plan
./gradlew :skainet-backends:skainet-backend-cpu:jvmTest --tests \"sk.ainet.exec.kernel.*\"— 13 new tests pass (8 kernel parity + 5 provider/registry); existingKernelRegistryTestandScalarMatmulKernelTeststill pass.ScalarMatmulKernelfor: 2×3×4 contiguous, 8×16×32 random, 31×17×23 random, non-alignedk=23(tail loop), strided A sub-block.m=0/n=0is no-op,k=0zeros the output block, negative dims throwIllegalArgumentException.isAvailable()on test JDK, registry picks Panama over Scalar when both registered, kill-switch via-Dskainet.cpu.vector.enabled=falsedisables it.🤖 Generated with Claude Code