Skip to content

feat(wasm): BF16/FP16 provider kernels, common KernelStrictness, matrix rows, sidecar features, aligned wasm-bench scenarios - #1363

Merged
michalharakal merged 1 commit into
SKaiNET-developers:developfrom
michalharakal:feature/wasm-parity-bf16-fp16-strictness-matrix
Oct 19, 2026
Merged

michalharakal merged 1 commit into
SKaiNET-developers:developfrom
michalharakal:feature/wasm-parity-bf16-fp16-strictness-matrix

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Summary

First step of bringing the wasmJs tier to feature parity with the JVM tier (compute layer). No C changes; everything here is Kotlin, the support matrix and the bench.

  • BF16 / FP16 matmul on wasm. The sidecar has exported skainet_bf16_matmul and skainet_fp16_matmul since 0.61.0, but WasmKernelProvider never bound them, so 16-bit dense weights fell to the scalar Kotlin kernels in a browser. WasmBf16MatmulKernel / WasmFp16MatmulKernel bind them; a contiguous weight is uploaded once and stays resident, a strided window is staged per call like the activation.
  • Sidecar diagnostics. WasmSimd.features() (mode, SIMD128, threads, cross-origin isolation, logical cores, resident weight bytes), and WasmSimd.install() prints the same one-line [SKaiNET] Using … banner the JVM factory prints.
  • KernelStrictness is common code. It was JVM-only (System.getProperty). Now KernelStrictness.overrideEnabled is the programmatic switch on every target (the only one on JS, Wasm and Kotlin/Native); JVM and Android still honour -Dskainet.strict.kernels. Two new fail-fast sites make strict mode mean the same thing on every tier: KernelDispatch before the decoding reference fallback, DefaultCpuOps.matmul before the generic per-element loop. The JVM subclass keeps its earlier check.
  • Kernel support matrix. Float16 row (every tier had the kernel, the matrix had no row); BF16/FP16 in the wasm column; Q6_K on the JVM corrected from panama-vector to native-ffm (NativeKernelProvider.matmulQ6K() has existed, the declared tier had not been updated — DefaultCpuOps resolves the kernel from the best available provider, so FFM was already serving it); a third table, Resident serving, for the sidecar-resident weights that stand in for mapped serving on JS/WASM. The test now also gates the declared Panama and FFM tiers against what the providers expose when they are available on the runner.
  • wasm-bench runs the engine-* scenarios of jvm-cpu-publish (same ids, shapes, generators and metrics) on each tier it measures, so JVM and wasm numbers sit in one table. engine-ternary-f32-gemv is reported as skipped on wasm until the ternary kernels join the sidecar (the decoding reference path takes hours at that shape).
  • Docs: eager-execution tables gain the wasm column and FP16 row, the stale "Native FFM Q6_K" gap is replaced by the real wasm gaps (ternary, non-matmul ops); dtype-model documents the common strict switch.

Verification

  • :skainet-backends:skainet-backend-wasm-simd:wasmJsNodeTest — parity for BF16/FP16 (contiguous and windowed) against the scalar kernels, features, strict mode on wasm, plus the existing Q8_0/Q4_0/dense tests.
  • :skainet-backends:skainet-backend-native-cpu:jvmTest --tests '*KernelSupportMatrixTest*', generateKernelMatrix (page regenerated).
  • :skainet-backends:skainet-backend-cpu:jvmTest --tests '*KernelStrictnessTest*'.
  • scripts/pr-gate.sh --quick.

Follow-ups in the same series: explicit SIMD128 bodies for the K-quants, Q5_0/Q5_1 and dense FP32/BF16/FP16 plus row threading for the dense kernels; ternary kernels in the sidecar and the direct x · Wᵀ kernel on the JVM; resident activations and fused elementwise/attention kernels; the browser IO gaps.

…ix rows, sidecar features, aligned wasm-bench scenarios

- WasmKernelProvider binds the existing skainet_bf16_matmul / skainet_fp16_matmul
  sidecar exports (resident contiguous weight, staged strided window).
- WasmSimd.features() and a one-line install banner mirroring the JVM factory.
- KernelStrictness moves to commonMain with a programmatic overrideEnabled switch;
  JVM/Android keep the system property. KernelDispatch and DefaultCpuOps.matmul
  fail fast in strict mode before their reference fallbacks.
- Kernel support matrix: Float16 row, BF16/FP16 on wasm-simd128, Q6_K on
  native-ffm, new "Resident serving" table; drift gate covers Panama and FFM
  tiers when available.
- wasm-bench runs the engine-* scenarios of jvm-cpu-publish on every tier;
  the ternary gemv is skipped where no ternary kernel is registered.
- Docs: eager-execution wasm column and FP16 row, corrected gaps; dtype-model
  strict-mode section; CHANGELOG.
@michalharakal
michalharakal merged commit c0d3d3a into SKaiNET-developers:develop Oct 19, 2026
22 checks passed
@michalharakal
michalharakal deleted the feature/wasm-parity-bf16-fp16-strictness-matrix branch October 19, 2026 10:14
michalharakal added a commit that referenced this pull request Oct 21, 2026
CHANGELOG [0.62.0] - 2026-10-21 with the parity headline over #1363, #1364,
#1368, #1369, #1426, #1427, #1428 and #1430, plus entries for the operator
coverage matrix (#1370), the BitNet decode allocation and threading fixes
(#1359, #1360, #1361, #1362), the ClassificationSupport extraction (#1429)
and the toolchain bumps (Kotlin 2.4.21, kotest 6.2.6, Gradle 9.8.1).
VERSION_NAME, CITATION, Antora version, README bom coordinate, What's New
and contributors, Android tutorial coordinates; regenerated operator and
kernel-support matrices; SKEEP-007 rollout step 3 marked shipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants