topos
An autodiff compiler stack in Rust. Record a graph, inspect it, differentiate it, compile it, emit it. The spec is an immutable value and the state is yours. The network never moves; a training step is a pure data transform of caller-owned parameters.
The interpreter is the executable spec; everything faster must match it, bit for bit by default. The stack stays small enough to read. Every result is provable.
A typical compiler rewrites the program until it can run. Topos
does not. The tape is written once; everything after it is a named
way of reading the same spec. Fusion is an offer, not a rewrite.
Emission writes the plan as text for an industrial backend — a
sibling of describe, not a second compiler.
The design is in docs/vision.md. Constraints
it assumes live in docs/principles/.
Record and train
use ;
let = record;
let mut parameters = network.parameters;
let samples = ;
for step in 0..100
assert!;
The graph is recorded once. Every step feeds a sample and steps the parameters. Training never touches the network.
Inspect, compile, emit
use ;
let = record;
println!;
let plan = network.entry.lower;
println!;
Two rustdoc maps, nothing moves:
topos::model
to train,
topos::compiler
to inspect and emit.
As a dependency
Write networks, losses, optimizers, and element types against the public surface. A hand-rolled layer behaves identically to a facade; a custom optimizer has the same standing as Adam. The opcode set, fusions, and backends stay in the crate — the core is closed on purpose.
Opt-in backends (accelerate, simd, metal, cuda) are
documented in docs/acceleration.md.
Vocabulary: docs/terminology.md.
Notebooks: docs/notebooks.md. API:
docs.rs/topos.
Examples
examples/ runs from a scalar chain to a transformer:
gradient_descent— one spec, many statesmakemore/— Karpathy's classroom, through facades, compiled plans, and StableHLOmnist/andcifar10/gpt2/— 124M, recorded from the public op surfacellama/
The name
A topos is a place — here, one where the whole compiler stack stays in view.
License
Licensed under either of MIT or Apache-2.0, at your option.