M-POLY-VTD AI Engine (Loom v0.75.0) — 21 Numerical Types, WebGPU, Transformer Inference, and 100% Determinism
Project description
welvet — Loom Python Bindings
Python bindings for the M-POLY-VTD neural engine — 21 numerical types, WebGPU acceleration, NEAT evolution, and 100% determinism.
welvet wraps the Loom C-ABI with zero Python dependencies. It ships precompiled native libraries for all major platforms.
Install
pip install welvet
Supported platforms: Windows (x86-64, ARM64), Linux (x86-64, ARM64, ARM, x86), macOS (x86-64, ARM64, Universal), Android (ARM64, ARM).
Quick Start
import welvet
from welvet import Network, LayerType, DType
# Build a 3-layer dense MLP in the first grid cell
net = Network({
"id": "my_net",
"depth": 1, "rows": 1, "cols": 1, "layers_per_cell": 3,
"layers": [
{"z": 0, "y": 0, "x": 0, "l": 0, "type": "dense",
"input_height": 128, "output_height": 256, "activation": "relu"},
{"z": 0, "y": 0, "x": 0, "l": 1, "type": "dense",
"input_height": 256, "output_height": 256, "activation": "relu"},
{"z": 0, "y": 0, "x": 0, "l": 2, "type": "dense",
"input_height": 256, "output_height": 10, "activation": "sigmoid"},
]
})
# Forward pass
output = net.forward([0.5] * 128)
print(output[:5])
net.free()
Core Concepts
Supported Layer Types
| Type | Description |
|---|---|
dense |
Fully connected / linear layer |
mha |
Multi-Head Attention (with RoPE, GQA/MQA, Causal Masking) |
swiglu |
SwiGLU gated MLP (LLaMA-style) |
rmsnorm |
Root Mean Square Normalization |
layernorm |
Layer Normalization |
cnn1 / cnn2 / cnn3 |
1D / 2D / 3D Convolution |
convtransposed1d / 2d / 3d |
Transposed Convolution |
rnn / lstm |
Recurrent layers |
embedding |
Token embedding lookup |
kmeans |
Differentiable K-Means clustering |
softmax |
10 softmax variants (Standard, Gumbel, Masked, Entmax, ...) |
parallel |
MoE / ensemble branching |
sequential |
Nested sequential sub-graph |
residual |
Residual / skip connection |
21 Numerical Types
float64, float32, float16, bfloat16, int64/32/16/8, uint64/32/16/8, fp8_e4m3, fp8_e5m2, int4, uint4, fp4_e2m1, int2, uint2, ternary, binary
Morph a layer's precision at runtime with no reallocation:
welvet.morph_layer(net._handle, layer_index=0, new_dtype="int8")
WebGPU Acceleration
import welvet
from welvet import Network
net = Network({...})
# Upload weights to GPU
welvet.init_wgpu(net._handle)
welvet.sync_to_gpu(net._handle)
# GPU forward pass
output = welvet.forward_wgpu(net._handle, inputs)
net.free()
Numerical Tiling (SC vs MC)
V0.75.0 introduces specialized tiling profiles to maximize throughput:
- SC (Single-Core): Optimized for Edge/WASM/Small NPUs.
- MC (Multi-Core): Optimized for high-bandwidth L1/L2 caches (Ryzen, RTX, M4).
GPU backward training is live for Dense, RMSNorm, CNN 1D/2D/3D — 17x–65x speedup over CPU on real workloads.
DNA & Network Comparison
Extract a topological fingerprint and compare networks:
from welvet import extract_dna, compare_dna
dna_a = extract_dna(net_a._handle)
dna_b = extract_dna(net_b._handle)
result = compare_dna(dna_a, dna_b)
print(f"Overlap: {result['OverallOverlap']:.4f}")
print(f"Logic shifts: {len(result.get('LogicShifts', []))}")
NEAT Evolution
Genetically evolve a population of networks:
from welvet import (
default_neat_config, neat_mutate,
new_neat_population, neat_population_size,
neat_population_get_network, neat_population_evolve,
neat_population_best, neat_population_best_fitness,
neat_population_summary, free_neat_population,
build_network, free_network,
)
# Create a seed network
seed = Network({
"id": "seed", "depth": 1, "rows": 1, "cols": 1, "layers_per_cell": 2,
"layers": [
{"z": 0, "y": 0, "x": 0, "l": 0, "type": "dense",
"input_height": 32, "output_height": 32},
{"z": 0, "y": 0, "x": 0, "l": 1, "type": "dense",
"input_height": 32, "output_height": 1},
]
})
cfg = default_neat_config(32)
pop = new_neat_population(seed, size=16, config=cfg)
for gen in range(20):
fitnesses = [my_fitness_fn(pop.get_network(i)) for i in range(pop.size())]
pop.evolve(fitnesses)
print(pop.summary(gen))
best = pop.best()
print(f"Best fitness: {pop.best_fitness():.6f}")
best.free()
pop.free()
seed.free()
DNA Splice / Genetic Crossover
Combine two parent networks into a child:
from welvet import default_splice_config, splice_dna, splice_dna_with_report
cfg = default_splice_config()
cfg["CrossoverMode"] = "blend" # "blend" | "point" | "uniform"
cfg["FitnessA"] = 0.8
cfg["FitnessB"] = 0.5
child_handle = splice_dna(parent_a._handle, parent_b._handle, cfg)
# Or get a full diagnostic report
report = splice_dna_with_report(parent_a._handle, parent_b._handle, cfg)
print(f"Layers blended: {report['blended_count']}")
child_handle = report["child_handle"]
Systolic Grid (Online Learning)
The volumetric 3D grid supports clock-cycle accurate propagation with spatial feedback loops:
state = welvet.create_systolic_state(net._handle)
welvet.set_input(state, inputs)
welvet.systolic_step(state)
output = welvet.get_output(state, layer_idx=-1)
welvet.free_systolic_state(state)
Training
from welvet import train_network
# High-level training helper
train_network(net._handle, inputs, targets, epochs=100, learning_rate=0.001)
Or use full GPU backward dispatch for maximum performance — see the benchmark scripts.
Target Propagation
An alternative to backpropagation using localized Hebbian gap-based learning:
from welvet import (
create_target_prop_state, get_default_target_prop_config,
target_prop_forward, target_prop_backward,
)
cfg = get_default_target_prop_config()
state = create_target_prop_state(net._handle, cfg)
target_prop_forward(state, inputs)
target_prop_backward(state, targets)
LLM Inference
Load a SafeTensors model and run token generation:
from welvet import load_network, load_tokenizer, tokenize, detokenize, sequential_forward
net = load_network("path/to/model.safetensors")
tok = load_tokenizer("path/to/tokenizer.json")
ids = tokenize(tok, "Hello, world!")
output = sequential_forward(net, [float(i) for i in ids])
Platform Support
| Platform | Architecture | Binary |
|---|---|---|
| Windows | x86-64 | welvet.dll |
| Windows | ARM64 | welvet.dll |
| Linux | x86-64 | welvet.so |
| Linux | ARM64 | welvet.so |
| Linux | ARM (v7) | welvet.so |
| macOS | ARM64 (M-series) | welvet.dylib |
| macOS | x86-64 | welvet.dylib |
| macOS | Universal | welvet.dylib |
| Android | ARM64 | welvet.so |
| Android | x86-64 | welvet.so |
| iOS | ARM64 (device) | welvet.dylib |
| iOS | Simulator (x86-64) | welvet.dylib |
| iOS | Simulator (ARM64) | welvet.dylib |
| iOS | XCFramework (all slices) | .xcframework |
Links
- GitHub: github.com/openfluke/loom
- Engine docs: poly/README.md
- TypeScript bindings: @openfluke/welvet
- Issues: github.com/openfluke/loom/issues
License
Apache 2.0 — see LICENSE.
Loom: Universal precision. Volumetric freedom. Bedrock performance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file welvet-0.75.0.tar.gz.
File metadata
- Download URL: welvet-0.75.0.tar.gz
- Upload date:
- Size: 100.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b5ace0f09e91eae99c59a8de13bf1a88f5f5d896a138a8744cab43cd2f6db2b
|
|
| MD5 |
c539cebc12f1d225edd8f950d5b9fa46
|
|
| BLAKE2b-256 |
7f2baaeb7fdd95348ab13fec499b65579174c6e2113bea55df0e0cba2ea5e500
|
File details
Details for the file welvet-0.75.0-py3-none-any.whl.
File metadata
- Download URL: welvet-0.75.0-py3-none-any.whl
- Upload date:
- Size: 100.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e9a8d312a803601faee63050ae772d20b68db27a2af314697edf6130a19fc20
|
|
| MD5 |
112ab6b918c661678d024423c35e080b
|
|
| BLAKE2b-256 |
490bf1ea071a0f4ebf7d9d909aabc90b04d0b2e89553695a61db855a668393fb
|