README
ΒΆ
LOOM - Layered Omni-architecture Openfluke Machine
A high-performance CPU-first neural network framework written in Go, with experimental WebGPU compute shaders for GPU acceleration (in development, only select layers supported). Features WebAssembly export for browser deployment. Now with transformer inference support!
π Cross-Ecosystem Compatibility
Models trained in any platform work instantly in all others. Bit-for-bit identical results across Go, Python, C#, TypeScript, and browser WASM.
| Platform | Package | Install |
|---|---|---|
| Go | GitHub | go get github.com/openfluke/loom |
| Python | PyPI | pip install welvet |
| C#/.NET | NuGet | dotnet add package Welvet |
| TypeScript/Node | NPM | npm install @openfluke/welvet |
| Browser | WASM | import { init } from "@openfluke/welvet" |
Supported Platforms
Pre-compiled binaries for:
- Linux: x86_64, ARM64, ARMv7
- Windows: x86_64, x86, ARM64
- macOS: Apple Silicon (M1/M2/M3), Intel, Universal
- Android: ARM64, ARMv7
- iOS: ARM64 (XCFramework)
Key Strengths
- True Embeddability: Single binary. Zero external dependencies. No Python runtime needed.
- Hybrid Gradient/Geometric Engine: Neural Tweening combines geometric gap-closing with backpropagation-guided momentum for real-time adaptation.
- Structural Parallelism: Native support for Inception, ResNeXt, Siamese, and MoE architectures via
LayerParallelwith 6 combine modes. - Native Mixed-Precision: Generic tensor backend supports
int8,uint16,float32,float64natively. - Complete Training Infrastructure: 7 LR schedulers, 3 optimizers (SGD/AdamW/RMSprop), 10 softmax variants.
- Pure Go Tokenizer: HuggingFace-compatible BPE tokenizer for LLM inference.
- Step-Based Execution: Real-time inference with layer-by-layer control via
StepForwardAPI. - Network Telemetry: Runtime introspection via
GetMethodsJSON()andExtractNetworkBlueprint().
Key Limitations
- Ecosystem Maturity: No central "Model Zoo" or pip-installable convenience; relies on loading external checkpoints.
- GPU Support: WebGPU acceleration is implemented (Dense, Conv2D, MHA) but is beta/experimental and less stable than CuDNN/CUDA.
- Operator Coverage: While "Deep" support is good (MHA, LSTM), "Broad" support (e.g., 3D Conv, Deformable Attn, FFTs) is missing compared to SciPy/JAX.
- Math Backend: Relies on custom explicit forward/backward passes rather than a general-purpose symbolic autograd graph.
What's New
π Transformer Inference: SmolLM2-135M-Instruct runs entirely in browser WASM with pure Go implementation.
π€― Grid Softmax = Native MoE: Mathematically proven equivalent to PyTorch MoE with 97.1% loss reduction. See
examples/moe_proof_demo.go.
β‘ Grid Scatter Mode: Place parallel branch outputs at specific 2D/3D grid positions for multi-agent systems, hierarchical RL, and ensemble methods with explicit topology.
π§ Neural Tweening: Train and run simultaneously with 100% accuracy on shallow networks, never crashes to 0% during task changes. Benchmarks β
Framework Comparison
Global AI Landscape
| Feature Category | Feature | Loom (Go) | PyTorch (Py) | TF / TFLite | GoMLX (Go) | Spago (Go) | Core ML | TF.js | Candle (Rust) |
|---|---|---|---|---|---|---|---|---|---|
| Core | Primary Language | Go | Python | Python / C++ | Go | Go | Swift / ObjC | JS / TS | Rust |
| Runtime Dependency | None (Binary) | Heavy (Pip) | Binary (Edge) | CGo / XLA | None | OS-Native | Browser | None | |
| Auto-Differentiation | β οΈ Hybrid/Manual | β Full | β Full | β Full (XLA) | β Manual | β (Inference) | β Full | β Full | |
| Loading | Safetensors | β Native | β | β | β | β | β | β | β |
| ONNX Support | β | β (Export) | β | β οΈ | β | β (Import) | β | β οΈ | |
| Structure Inference | β Auto-Detect | β | β | β | β | β | β | β | |
| Training | Gradient Descent | β Manual Chain | β Standard | β Standard | β Standard | β Standard | β (On-device) | β Standard | β Standard |
| Neural Tweening | β Hybrid Engine | β | β | β | β | β | β | β | |
| LR Schedulers | β 7 Types | β | β | β | β οΈ Basic | β | β | β | |
| Optimizers | β 3 (SGD/AdamW/RMSprop) | β Many | β Many | β | β | β οΈ | β | β | |
| Layer Support | Dense (MLP) | β | β | β | β | β | β | β | β |
| Conv2D | β | β | β | β | β | β | β | β | |
| Conv1D | β Native | β | β | β | β | β | β | β | |
| RNN / LSTM | β Full Gate | β | β | β | β | β | β | β | |
| Transformer (MHA) | β (Explicit) | β | β | β | β (BERT) | β | β | β | |
| SwiGLU | β Native | β | β | β | β | β | β | β | |
| Parallel / MoE | β Structure | β (Manual) | β (Manual) | β | β | β | β | β | |
| Sequential Layers | β Native | β | β | β οΈ | β οΈ | β οΈ | β | β οΈ | |
| Embeddings | β | β | β | β | β | β | β | β | |
| Tokenizer | β Pure Go | β (Rust/C++) | β (C++) | β | β | β | β | β | |
| Normalization | LayerNorm | β Native | β | β | β | β | β | β | β |
| RMSNorm | β Native | β οΈ (Manual) | β οΈ (Manual) | β | β | β | β | β | |
| Residual/Skip | β Native | β | β | β | β | β | β | β | |
| Advanced | Stitch Layers | β Native | β (Manual) | β (Manual) | β | β | β | β | β |
| Dynamic Arch Gen | β Built-in | β | β | β | β | β | β | β | |
| Step-Based Forward | β Unique | β | β | β | β | β | β | β | |
| K-Means Clustering | β Parallel | β | β | β | β | β | β | β | |
| Correlation Analysis | β Pearson/Spearman | β | β | β | β | β | β | β | |
| Model Evaluation | β Deviation/Metrics | β | β | β οΈ | β οΈ | β οΈ | β οΈ | β οΈ | |
| Network Telemetry | β Blueprint API | β | β οΈ | β | β | β | β οΈ | β | |
| Runtime Introspection | β Reflection | β οΈ (Python) | β οΈ | β | β | β | β οΈ | β | |
| Platform | WASM Training | β Full | β | β | β | β | β | β (Slow) | β |
| Cross-Lang ABI | β Universal | β | β | β | β | β | β | β οΈ | |
| Ecosystem | HuggingFace Hub | β οΈ (Read/Inspect) | β Native | β Native | β | β | β | β | β |
| Pre-trained Zoo | β | β Massive | β Massive | β | β (Small) | β (Apple) | β Large | β οΈ Growing | |
| Mobile/Web | β WASM / C-ABI | β (Mobile) | β King | β | β | β King (iOS) | β King (Web) | β (WASM) |
Go Ecosystem Comparison
| Category | Feature | Loom | GoMLX | Gorgonia | Spago | Go-Deep | Gonum |
|---|---|---|---|---|---|---|---|
| Foundation | Primary implementation | Pure Go | CGo (XLA) | Pure Go + CGo | Pure Go | Pure Go | Pure Go |
| Tensor Backend | Custom (Generic) | XLA (C++) | Custom | Custom (Dense) | Custom | Dense Matrix | |
| Autograd | β οΈ Hybrid | β Full | β Symbolic | β Dynamic | β Backprop | β | |
| Model | Load Safetensors | β Native | β | β | β | β | β |
| Model Export | binary/json | XLA format | Onnx (Import) | Gob | Json | β | |
| Architecture | Dense (MLP) | β | β | β | β | β | β (Matrix Mul) |
| Conv2D | β | β | β | β | β | β | |
| Conv1D | β Native | β | β οΈ (via 2D) | β οΈ (via 2D) | β | β | |
| RNN / LSTM | β Full Gate | β | β οΈ Basic | β BiLSTM | β | β | |
| Transformer (MHA) | β Explicit | β | β οΈ Hard | β (BERT) | β | β | |
| SwiGLU | β | β | β | β | β | β | |
| Embeddings | β | β | β | β | β | β | |
| Parallel / MoE | β MoE + Gating | β (Manual) | β | β | β | β | |
| Sequential Layers | β Native + Nested | β οΈ (Manual) | β οΈ (Manual) | β οΈ (Manual) | β | β | |
| Tokenizer | β Pure Go | β (Deps) | β | β (WordPiece) | β | β | |
| Training | Gradient Descent | β Manual | β Standard | β Standard | β Standard | β Standard | β |
| Hybrid Tweening | β Unique | β | β | β | β | β | |
| LR Schedulers | β 7 Types | β | β | β οΈ Basic | β | β | |
| Optimizers | β SGD/AdamW/RMSprop | β | β | β | β οΈ SGD | β | |
| Softmax Variants | β 10 Types | β οΈ Standard | β οΈ Standard | β οΈ Standard | β οΈ Standard | β | |
| Normalization | LayerNorm | β Native | β | β οΈ Manual | β | β | β |
| RMSNorm | β Native | β | β | β | β | β | |
| Residual/Skip | β Native | β | β | β | β | β | |
| Advanced | RoPE Embeddings | β GQA Support | β | β | β | β | β |
| Network Grafting | β Unique | β | β | β | β | β | |
| Step-Based Forward | β Unique | β | β | β | β | β | |
| Dynamic Arch Gen | β Unique | β | β | β | β | β | |
| K-Means Clustering | β Parallel | β | β | β | β | β | |
| Correlation Analysis | β Pearson/Spearman | β | β | β | β | β | |
| Model Evaluation | β Full Suite | β οΈ | β οΈ | β οΈ | β | β | |
| Network Telemetry | β Blueprint | β | β οΈ | β | β | β | |
| Runtime Introspection | β Reflection | β | β οΈ | β | β | β | |
| Platform | C-ABI (Polyglot) | β Universal | β | β | β | β | β |
| WASM Training | β Full | β (XLA) | β | β | β | β | |
| Ecosystem | HuggingFace | β οΈ (Load) | β | β | β (Load) | β | β |
| Documentation | β οΈ Growing | β Good | β Good | β Good | β οΈ Minimal | β Excellent | |
| Maintenance | π₯ Active | π₯ Active | β οΈ Slow | βΈοΈ Paused | β οΈ Slow | π₯ Active |
Native Numerical Type & Precision Support
| Layer Type | Numerical Type | Loom | GoMLX | Gorgonia | Spago | PyTorch |
|---|---|---|---|---|---|---|
| All Layers | Float32 | β | β | β | β (Float64) | β |
| (Dense, Conv, | Float64 (High Prec) | β Native | β | β | β | β |
| RNN, Attn) | Float16 / BF16 | β οΈ (Storage) | β (XLA) | β | β | β |
| Int8 (Training) | β Native | β | β | β | β οΈ (QAT Wrapper) | |
| Int8 (Inference) | β | β | β | β | β (Quant) | |
| Int16, Int32, Int64 | β Native | β (XLA) | β οΈ (Tensor) | β | β (Tensor Only) | |
| Uint8, Uint16, Uint32 | β Native | β (XLA) | β οΈ (Tensor) | β | β (Uint8 Only) |
[!NOTE] Complete Type System: Unlike frameworks that treat integers primarily as storage formats for quantization, Loom's Generics allow native training and inference on exotic types like
uint16(common in medical imaging),int32, orfloat64(scientific sim) across every layer type without changes to the model code.
Summary Verdict
- Choose PyTorch if you are doing Research, need the latest SOTA models, or rely on complex dynamic architectures.
- Choose TensorFlow / TFLite if you need robust Mobile/Edge Deployment.
- Choose GoMLX if you need High-Performance Training in Go and can tolerate CGo/C++ dependencies.
- Choose Core ML if you are targeting iOS/macOS exclusively.
- Choose Loom if you need Pure Go-Native Embedding (Cloud/CLI/Server), want a single binary with zero dependencies, need to experiment with the Neural Tweening training paradigm, or need unique features like Step-Based Forward Pass for real-time inference and Dynamic Architecture Generation for automated model exploration.
Layer Types & Features
Supported Layer Types
| Layer | Type String | Description |
|---|---|---|
| Dense | dense |
Fully connected layer |
| LSTM | lstm |
Long Short-Term Memory |
| RNN | rnn |
Recurrent Neural Network |
| GRU | gru |
Gated Recurrent Unit |
| Conv2D | conv2d |
2D Convolution |
| Conv1D | conv1d |
1D Convolution |
| Multi-Head Attention | multi_head_attention |
Transformer attention |
| LayerNorm | layer_norm |
Layer normalization |
| RMSNorm | rms_norm |
RMS normalization |
| SwiGLU | swiglu |
SwiGLU activation layer |
| Softmax | softmax |
10 variants (Standard, Grid, Hierarchical, Temperature, Gumbel, Masked, Sparsemax, Entmax, Adaptive, Mixture) |
| Embedding | embedding |
Token embedding |
| Parallel | parallel |
Branching with 6 combine modes (add, concat, multiply, average, grid_scatter, filter) |
| Sequential | sequential |
Grouped sub-layers |
Activation Functions
relu, sigmoid, tanh, softmax, gelu, swish, mish, leaky_relu, elu, selu, linear
Quick Start
Installation
# Clone the repository
git clone https://github.com/openfluke/loom.git
cd loom
# Install dependencies
go mod download
Simple Example
package main
import (
"fmt"
"github.com/openfluke/loom/nn"
)
func main() {
network := nn.NewNetwork(4096, 4, 4, 5) // 80 total layers
if err := network.InitGPU(); err != nil {
panic(err)
}
defer network.ReleaseGPU()
input := make([]float32, 4096)
output, gpuTime, _ := network.ForwardGPU(input)
fmt.Printf("GPU Forward time: %v, Output size: %d\n", gpuTime, len(output))
}
Model Serialization
// Save a trained model
err := network.SaveModel("model.json", "my_model")
// Load it back - ONE LINE!
loadedNet, err := nn.LoadModel("model.json", "my_model")
// Or use strings (great for APIs/databases/WASM)
jsonString, err := network.SaveModelToString("my_model")
loadedNet, err := nn.LoadModelFromString(jsonString, "my_model")
Cross-Platform API
| Function | Go | Python | TypeScript | C# | C |
|---|---|---|---|---|---|
| Create | BuildNetworkFromJSON() |
create_network_from_json() |
createNetworkFromJSON() |
CreateLoomNetwork() |
CreateLoomNetwork() |
| Forward | ForwardCPU() |
forward_simple() |
forward() |
LoomForward() |
LoomForward() |
| Train | Train() |
train_simple() |
train() |
LoomTrain() |
LoomTrain() |
| Save | SaveModelToString() |
save_model_simple() |
saveModel() |
LoomSaveModel() |
LoomSaveModel() |
| Load | LoadModelFromString() |
load_model_simple() |
loadLoomNetwork() |
LoomLoadModel() |
LoomLoadModel() |
| Evaluate | EvaluateNetwork() |
evaluate_network_simple() |
evaluate() |
LoomEvaluateNetwork() |
LoomEvaluateNetwork() |
Language Bindings
Python
pip install welvet
import welvet
config = {"batch_size": 1, "layers": [...]}
welvet.create_network_from_json(config)
output = welvet.forward_simple([0.1, 0.2, 0.3, 0.4])
See python/README.md for complete documentation.
TypeScript / Node.js
npm install @openfluke/welvet
import { init, createNetworkFromJSON } from "@openfluke/welvet";
await init();
const network = createNetworkFromJSON(JSON.stringify(config));
const output = network.ForwardCPU(JSON.stringify([[0.1, 0.2, 0.3, 0.4]]));
See typescript/README.md for complete documentation.
C# / .NET
dotnet add package Welvet
using Welvet;
Network.CreateFromJson(config);
var output = NativeMethods.LoomForward(input, input.Length);
See csharp/README.md for complete documentation.
Project Structure
loom/
βββ nn/ # Neural network package (core)
βββ tokenizer/ # Pure Go BPE tokenizer
βββ wasm/ # WebAssembly module
βββ cabi/ # C ABI for FFI
βββ python/ # Python package (welvet)
βββ typescript/ # TypeScript/WASM package
βββ csharp/ # C#/.NET package (Welvet)
βββ fabric/ # Demo application
βββ pods/ # GPU compute pods
βββ model_conversion/ # HuggingFace model import
βββ docs/ # Documentation
βββ detector/ # GPU device detection
Documentation
- Neural Network Package - Detailed API documentation
- Neural Tweening Benchmarks - 19-test comprehensive benchmark
- Python Bindings - PyPI package docs
- TypeScript Bindings - NPM package docs
- C# Bindings - NuGet package docs
- WASM Module - Browser deployment
- C ABI - FFI reference
- Model Conversion - HuggingFace import guide
More Examples: See github.com/openfluke/tva for additional examples and experiments.
Requirements
- Go: 1.24 or higher
- GPU: WebGPU-compatible GPU (Vulkan, Metal, or D3D12) - optional
- OS: Linux, macOS, or Windows
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Apache License 2.0 - see LICENSE file for details.
Made with β€οΈ by Openfluke