Rechenwerk is an eager, debuggable Nim deep learning framework on OpenXLA/PJRT.
It gives you a PyTorch-like tensor API, typed compiled training steps, functional layers and optimizers, and one shared StableHLO/VJP path for eager execution and compiler-backed transforms.
- One compiler path: eager ops and raw
jittraces emit the same StableHLO. - One autodiff path: VJP rules are shared by eager tape and
grad/vjp. - Plain Nim objects: layers, optimizers, configs, and pytrees are value types.
- Explicit runtime behavior: no macro
jit, no hidden host transfers, no implicit cross-device copies. - Runtime backends: CPU, CUDA 12/13, ROCm, Metal, and TPU are resolved through PJRT plugins and a pinned manifest.
From a published package:
requires "rew >= 0.2.0"From a source checkout:
bau test
bau fetch cpuDevelopment commands are declared in bau.toml and require Bau 0.4.0 or newer
on PATH.
Installed packages also provide the standalone plugin downloader:
rew_fetch cpuimport rew
setDefaultDevice(cpu(0))
installEagerBackend()
let x = fromHost([1.0'f32, 2.0, 3.0, 4.0], [2, 2])
let y = relu(x + x)
echo y.toHost(float32)Run it after fetching a CPU plugin:
nim c -r quickstart.nim- Tensor ops: arithmetic, reductions, shape ops, linalg, convolution, pooling, gather/scatter, sort, random, and normalization.
- Autograd:
grad,vjp,valueAndGrad, and eager tape-stylebackward. - Transforms: user-level
grad,vjp,cond,whileLoop,fori, andvmap; rawjit, lowering, and HLO inspection live underimport rew/xla. - Neural nets: functional layers under
rew.nn, explicit PRNG keys, and pytree flatten/unflatten for training state. - Training:
Runtimefor user-owned loops andTrainerfor framework-owned loops with callbacks. - Data: lazy datasets, transforms, batching, image loading, and graph data helpers.
- Binaries:
bau fetch <target>,rew_fetch <target>,bau task doctor, and manifest-driven plugin caches.
nim c -r examples/list_devices.nim
nim c -r examples/mnist_mlp.nim
nim c -r examples/mnist_cnn.nim
nim c -r examples/mnist_trainer.nimMNIST examples use synthetic data when REW_MNIST_DIR is not set. Set
REW_TARGET=cpu, REW_TARGET=cuda12, or another supported target to override
auto-detection.
bau lint
bau testFast # dev-profile tests for fast iteration
bau test
bau asanThe full bau test command still runs debug, release, and danger. The test
runner defaults to parallel child test builds; set REW_TEST_JOBS=1 to debug
serially or raise it on larger machines.
Architecture notes live in docs/architecture.md, the user guide is in docs/user-guide.md, and PJRT plugin details are in docs/binaries.md.
The public API is tiered: import rew for high-level user code,
import rew/xla for raw compiler/lowering work, and import rew/dev for
extension internals.
MIT. See LICENSE.