Skip to content

Commit 38fceca

Browse files
Merge pull request #579 from SKaiNET-developers/feature/native-cpu-jvm-only-doc
docs(native-cpu): document JVM-only consumption + shadow-jar caveat
2 parents 9dfb624 + ebad399 commit 38fceca

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

skainet-backends/skainet-backend-native-cpu/src/jvmMain/kotlin/sk/ainet/exec/kernel/NativeKernelProvider.kt

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,51 @@ import sk.ainet.backend.api.kernel.Q4KMemSegMatmulKernel
2424
* callers stick with [matmulQ4K]; both wrap the same C symbol so
2525
* outputs are bit-for-bit identical.
2626
*
27+
* ## Consuming this module
28+
*
29+
* The whole `skainet-backend-native-cpu` module is **JVM-only**: it
30+
* depends on `java.lang.foreign.*`, which exists on Java SE only —
31+
* not on Kotlin/Native, JS, Wasm, or Android Runtime. The module
32+
* declares only a `jvm()` Kotlin target; no klib variants are
33+
* published.
34+
*
35+
* KMP consumers MUST add the dependency to `jvmMain` only, never to
36+
* `commonMain`:
37+
*
38+
* ```kotlin
39+
* sourceSets {
40+
* val jvmMain by getting {
41+
* dependencies {
42+
* implementation("sk.ainet.core:skainet-backend-native-cpu:<version>")
43+
* }
44+
* }
45+
* }
46+
* ```
47+
*
48+
* Putting it in `commonMain.dependencies` causes Gradle to fail
49+
* resolution on every non-JVM target with a long string of "Couldn't
50+
* resolve dependency 'sk.ainet.core:skainet-backend-native-cpu' in
51+
* 'commonMain' for all target platforms" warnings. JVM-only consumers
52+
* (plain `kotlin("jvm")` modules) can use the regular `dependencies`
53+
* block.
54+
*
55+
* Auto-discovery: `KernelServiceLoader.installAll()` scans
56+
* `META-INF/services/sk.ainet.backend.api.kernel.KernelProvider` on
57+
* the classpath and registers everything it finds. With the JAR on
58+
* the classpath there is nothing else to wire — no manual
59+
* `KernelRegistry.register()` call.
60+
*
61+
* Shadow-jar consumers: `mergeServiceFiles()` on shadow plugin
62+
* 9.4.x has a known bug that silently drops one of the two co-
63+
* located service files when both `skainet-backend-cpu` and
64+
* `skainet-backend-native-cpu` are on the classpath — see the
65+
* `kllama-cli` build script in `SKaiNET-transformers` for a working
66+
* `doLast` workaround that rebuilds the union.
67+
*
2768
* Staged rollout cursor (see `native-ffm-plan` asciidoc):
2869
* - PR 2: real Q4_K matmul wired into the heap SPI.
2970
* - PR 3: MemSeg-input zero-copy sibling.
30-
* - PR 5 (this commit): native FP32 matmul wired into [matmulFp32].
71+
* - PR 5: native FP32 matmul wired into [matmulFp32].
3172
* - Later: native `matmulQ6K`, `matmulQ8_0` (need new SPI accessors).
3273
*/
3374
public object NativeKernelProvider : KernelProvider, MemSegKernelProvider {

0 commit comments

Comments
 (0)