Skip to content

Add skainet-backend-api module (#468)#470

Merged
michalharakal merged 2 commits intodevelopfrom
feature/468-backend-api-module
Apr 13, 2026
Merged

Add skainet-backend-api module (#468)#470
michalharakal merged 2 commits intodevelopfrom
feature/468-backend-api-module

Conversation

@michalharakal
Copy link
Copy Markdown
Contributor

Closes #468.

Summary

Introduces skainet-backends:skainet-backend-api, a new Gradle module that api-re-exports the tensor op and storage interfaces already living in skainet-lang-core (TensorOps, TensorDataFactory, TensorData, …). It owns no Kotlin implementation of its own — it's a re-export layer plus a marker object BackendApi so tooling and IDE search land on a clear anchor.

This is the first step of the P0-2 track in the NPU / IREE roadmap: concrete backends (today's CPU, future IREE / Metal / NPU) should depend on this neutral module rather than taking a transitive dependency on skainet-backend-cpu just to reach the interfaces they implement.

Scoping surfaced a useful fact: TensorOps is already correctly placed in skainet-lang-core — no source file moves were needed, so the first step is purely additive.

Changes

  • settings.gradle.kts: include skainet-backends:skainet-backend-api directly before skainet-backend-cpu.
  • skainet-backends/skainet-backend-api/build.gradle.kts: new KMP module mirroring skainet-backend-cpu's target set (jvm / android / iosArm64 / iosSimulatorArm64 / macosArm64 / linuxX64 / linuxArm64 / js / wasmJs / wasmWasi) so every current consumer will be able to resolve it on every target once migration starts.
  • skainet-backends/skainet-backend-api/src/commonMain/kotlin/sk/ainet/backend/api/BackendApi.kt: single marker object with a KDoc explaining the module's purpose.
  • skainet-backends/skainet-backend-cpu/build.gradle.kts: adds the new module as a dependency.

Out of scope

  • Migrating the ~11 existing consumers (skainet-compile-*, skainet-io-*, skainet-test-*, apps, models) from skainet-backend-cpuskainet-backend-api. That's the follow-up step and will be split into bite-sized per-consumer PRs.
  • Moving TensorOps source out of skainet-lang-core into this module. Not needed — it's already neutral where it lives.
  • Any new backend implementation (IREE, Metal, NPU).

Test plan

  • ./gradlew :skainet-backends:skainet-backend-api:compileKotlinJvm — green
  • ./gradlew :skainet-backends:skainet-backend-cpu:compileKotlinJvm — green (cpu now pulls in backend-api transitively)
  • ./gradlew :skainet-compile:skainet-compile-hlo:compileKotlinJvm — green (representative downstream consumer; confirms the transitive dependency path still resolves)
  • CI: full multiplatform build across all targets

🤖 Generated with Claude Code

michalharakal and others added 2 commits April 13, 2026 11:42
Introduces a backend-neutral Gradle module under skainet-backends
that `api`-re-exports the tensor op and storage interfaces already
living in skainet-lang-core. No Kotlin implementation of its own —
it's a re-export layer plus a marker object for tooling.

First step in the P0-2 track: concrete backends (today's CPU,
future IREE / Metal / NPU) should depend on this module rather
than taking a transitive dependency on skainet-backend-cpu just
to reach TensorOps / TensorDataFactory / TensorData. Consumer
migration is out of scope for this PR and will follow per-module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
skainet-backend-cpu now depends on the neutral backend-api module
alongside its existing direct dependency on skainet-lang-core.
Future backends (IREE, Metal, NPU) can follow the same pattern
of depending only on backend-api without needing to pull in the
CPU module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@michalharakal michalharakal merged commit b8d8356 into develop Apr 13, 2026
4 checks passed
@michalharakal michalharakal deleted the feature/468-backend-api-module branch April 13, 2026 10:26
michalharakal added a commit that referenced this pull request Apr 13, 2026
Captures the goal, phases, non-goals, and risks of implementing
a new `skainet-backend-nnapi` module that runs SKaiNET models
on an Amlogic Android dev board's NPU via Android's NNAPI HAL.

Important placement notes in the PRD itself:
- The backend lives in a NEW sibling repo, not in mainline
  SKaiNET. Mainline stays general and IREE-focused.
- The backend builds on top of the already-merged
  skainet-backend-api module (#470) and the TensorEncoding
  metadata flow (#471 / #475 / #478) — no mainline code
  changes are required to ship Phase 1-3.
- Orthogonal to SKaiNET-transformers, which owns LLM modules.

Phases:
  0. Board bring-up + NNAPI device capability dump
  1. FP32 dense matmul end-to-end
  2. int8 quantization path hitting the NPU driver
  3. Target model (MobileNetV3 int8 or TinyLlama candidate)
  4. Optional production packaging

Also documents the known deprecation risk (Android 15 marked
NNAPI deprecated in favor of LiteRT) and captures this as
accepted: ship the Amlogic use case now, plan a LiteRT
successor later.

This file is a planning artifact; it will be moved / referenced
from the new backend repo once that repo exists.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
michalharakal added a commit that referenced this pull request Apr 13, 2026
The neutral backend api module landed in #470 as the integration
seam for future backends (IREE, Metal, NPU, the NNAPI-Amlogic
sibling repo) but it was never added to the BOM's version-
alignment constraints. Java / JVM consumers that depend on the
BOM were therefore not getting a pinned version for
skainet-backend-api, so anyone referencing the module from a
Maven / Gradle project had to either spell out the version
manually or drop the BOM reliance for that coordinate.

Adding the missing `api(project(":skainet-backends:skainet-backend-api"))`
constraint groups it with skainet-backend-cpu under the
backend section. BOM still builds clean.

First of five commits polishing the Java / JVM consumption
story for the upcoming 0.19.0 release. See #400.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Create skainet-backend-api module (P0-2 step 1)

1 participant