Overview
Relevant source files
- CHANGELOG.md
- FAQ.md
- README.md
- build.gradle.kts
- gradle.properties
- gradle/libs.versions.toml
- settings.gradle.kts
- skainet-backends/skainet-backend-api/build.gradle.kts
- skainet-backends/skainet-backend-api/gradle.properties
- skainet-backends/skainet-backend-api/src/commonMain/kotlin/sk/ainet/backend/api/BackendApi.kt
- skainet-backends/skainet-backend-cpu/build.gradle.kts
- skainet-bom/build.gradle.kts
- skainet-compile/skainet-compile-core/build.gradle.kts
- skainet-data/skainet-data-api/build.gradle.kts
- skainet-data/skainet-data-simple/build.gradle.kts
- skainet-lang/skainet-lang-core/build.gradle.kts
- skainet-lang/skainet-lang-dag/build.gradle.kts
- skainet-lang/skainet-lang-ksp-annotations/build.gradle.kts
- skainet-lang/skainet-lang-ksp-processor/build.gradle.kts
- skainet-lang/skainet-lang-ksp-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
- skainet-lang/skainet-lang-models/build.gradle.kts
- skainet-lang/skainet-lang-models/src/commonTest/kotlin/sk/ainet/lang/nn/SineApproxReproductionTest.kt
This document provides a high-level introduction to SKaiNET, its architecture, capabilities, and organization. It serves as the entry point for understanding the framework's design and navigating to specific subsystems.
For detailed information about specific subsystems, see:
- Project module structure: Project Structure
- Quick start and usage examples: Getting Started
- Cross-platform deployment: Platform Support
- Core framework components: Core Framework
- LLM inference infrastructure: LLM Inference
What is SKaiNET?
SKaiNET is a Kotlin Multiplatform tensor and neural network engine designed for edge AI and on-device inference. It enables developers to build, train, and deploy neural networks from a single codebase across JVM, Android, iOS, macOS, Linux, JavaScript, and WebAssembly targets. The framework emphasizes type safety, developer ergonomics, and production deployment without requiring Python or cloud infrastructure. README.md8-10 README.md92-95
As of version 0.20.0, the ecosystem is highly modular. While this repository contains the core engine and compiler infrastructure, specialized high-level LLM and transformer implementations have been extracted to standalone repositories (SKaiNET-LLM and SKaiNET-transformers). README.md68-76 CHANGELOG.md5-13
Sources: README.md8-10 README.md68-76 README.md92-95 CHANGELOG.md5-13
Core Design Principles
SKaiNET is built around several key design principles:
- Kotlin-First: Native Kotlin DSLs for neural network definition (
nn { }), training, and data processing, leveraging Kotlin's type system. README.md30-36 README.md108-115 - Multiplatform by Default: Single codebase sharing logic across JVM, Native, JS, and WASM (including
WasmWasi). README.md92-95 skainet-lang/skainet-lang-core/build.gradle.kts48-50 - Production-Ready: Direct path from development to deployment via StableHLO MLIR export or Arduino C99 codegen. README.md127-137
- On-Device Optimized: High-performance CPU backend with SIMD vectorization (Kotlin Vector API),
MemorySegmenttensors, and advanced quantization formats like Q4_K and Q6_K. README.md98-102 CHANGELOG.md9-13 - Modular Architecture: Pluggable components for execution contexts, backends, and I/O formats, organized into a multi-module Gradle structure. settings.gradle.kts23-80
Sources: README.md30-36 README.md92-137 CHANGELOG.md9-13 settings.gradle.kts23-80 skainet-lang/skainet-lang-core/build.gradle.kts48-50
Key Capabilities
Neural Network Development
LLM Infrastructure
The core engine provides specialized primitives for large-scale inference, even as high-level apps move to external repos:
| Feature | Description | Module |
|---|---|---|
| TurboQuant | Runtime KV-cache compression (~8x memory reduction at 4-bit) | skainet-backend-cpu |
| Q6_K Native Matmul | High-precision quantized matmul using SIMD kernels | skainet-backend-cpu |
| SDPA | Scaled Dot-Product Attention recorded and lowered to StableHLO | skainet-compile-hlo |
| Tokenizers | Byte-Level BPE (Qwen/GPT-2) and SentencePiece (LLaMA) | skainet-io-core |
Data and I/O
| Format | Description | Module |
|---|---|---|
| GGUF | Unified format for weights and metadata with streaming mmap support | skainet-io-gguf |
| SafeTensors | Zero-copy, file-backed loading for HuggingFace standards | skainet-io-safetensors |
| ONNX | Model import and detection tools | skainet-io-onnx |
| Image I/O | Multi-platform bitmap handling (JPEG, PNG) | skainet-io-image |
Sources: README.md98-148 CHANGELOG.md9-56 settings.gradle.kts23-80
Module Organization
SKaiNET is organized into multiple Gradle modules following a layered architecture. The settings.gradle.kts file defines the current structure, including the skainet-pipeline and specialized I/O modules. settings.gradle.kts23-80
Architectural Mapping
The following diagram maps high-level system components to their primary code entities.
Sources: settings.gradle.kts23-80 CHANGELOG.md9-17 README.md98-102 README.md133-137
Platform Support Matrix
SKaiNET leverages Kotlin Multiplatform to support a wide array of targets. Version 0.20.0 continues to expand SIMD support and platform-specific optimizations. README.md92-95 CHANGELOG.md10-13
| Platform | Targets | Optimizations |
|---|---|---|
| JVM | Java 21+ | Vector API (SIMD), MemorySegment tensors |
| Android | minSdk 24 | androidMultiplatformLibrary support |
| Native | macOS, iOS, Linux | POSIX optimizations, Native SIMD |
| Web | JS, WASM (Browser) | Multiplatform target support |
| Edge | WASM (WASI), Arduino | C99 export with static memory allocation |
JVM-Specific Performance Features
The JVM backend (skainet-backend-cpu) is highly optimized for modern Java using the Vector API and Foreign Function & Memory API. CHANGELOG.md9-13 skainet-backends/skainet-backend-cpu/build.gradle.kts114-120
JVM Runtime Requirements:
- JDK 21+: Required for
MemorySegmentand bytecode compatibility. build.gradle.kts22-24 - JVM Flags:
--add-modules jdk.incubator.vectorand--enable-previeware required for SIMD and advanced memory optimizations. skainet-backends/skainet-backend-cpu/build.gradle.kts114-120
Sources: README.md92-95 CHANGELOG.md9-13 build.gradle.kts22-24 skainet-backends/skainet-backend-cpu/build.gradle.kts114-120
Technology Stack
The framework is built on a modern Kotlin/Java stack:
- Kotlin 2.3.21: Core language and KMP infrastructure. gradle/libs.versions.toml8
- Java 21+: Targeted for advanced memory management and vectorization. build.gradle.kts22
- KSP (Kotlin Symbol Processing): Used for generating tracing wrappers and operator documentation. build.gradle.kts82-102
- StableHLO / MLIR: The intermediate representation for hardware-agnostic compilation. README.md133-137
- Dokka: Aggregated API documentation across all library modules. build.gradle.kts119-124
Sources: gradle/libs.versions.toml1-28 build.gradle.kts1-172
Next Steps
To continue exploring SKaiNET:
Sources: README.md80-87
