nCPU: model-native and tensor-optimized CPU research runtimes with organized workloads, tools, and docs
nCPU: model-native and tensor-optimized CPU research runtimes with organized workloads, tools, and docs
A complete computer in which every layer — arithmetic, OS, compiler, display — is either a trained neural network or runs entirely on GPU.
The model doesn't run on the computer. The model is the computer.
nCPU is one repository pursuing one thesis from five directions: a computer can be built out of learned components, and once the whole execution stack is differentiable, programs stop being things you write and become things you can search for by gradient descent. Each subsystem below stands on its own measurements; together they cover the stack from individual ALU operations to an operating system to program synthesis.
Every ALU operation — addition, subtraction, multiplication, bitwise logic, shifts, division — is a trained neural network. The neural OS (neurOS) manages memory, schedules processes, and compiles code through 11 trained models with no hand-written fallbacks. A neural display renders characters through char→glyph MLPs and a ConvNet (143K parameters). The full pipeline — source code → neural compiler → neural assembler → neural CPU → neural display — is differentiable end to end.
The neural ALU reaches 100% accuracy on 32-bit integer arithmetic, verified exhaustively over every possible input. One result inverts the conventional hardware hierarchy: multiplication is 12x faster than addition here, because addition needs an 8-pass carry chain while multiplication decomposes into parallel byte-pair table lookups.
| Instruction | Strategy | Latency |
|---|---|---|
| ADD/SUB/CMP | Kogge-Stone carry-lookahead (8 passes) | 248 µs |
| MUL | Byte-pair LUT (65,536 entries) | 21 µs |
| AND/OR/XOR | Vectorized truth table | 21 µs |
| SHL/SHR | Attention-based bit routing | 434 µs |
| DIV | Restoring division (neural subtraction) | varies |
neurOS component accuracy:
| Component | Accuracy | Component | Accuracy |
|---|---|---|---|
| MMU | 100% | Assembler codegen | 100% |
| TLB | 99.6% | Assembler tokenizer | 99.4% |
| Cache | 99.7% | Compiler optimizer | 95.2% |
| Scheduler | 99.2% | Watchdog | 100% |
| Prefetch | 97.8% | Block allocator | 98.4% |
A self-sufficient computer on a single GPU — the CPU is involved only at bootstrap. The Rust + Metal kernel executes about 200 ARM64 instructions (integer and floating-point) at roughly 1.9M instructions per second, with zero-copy shared memory and zero cycle-count variance across runs (σ = 0.0).
What runs on it:
nSynth is a Rust-based program synthesis system that discovers executable programs from input/output examples using gradient descent, enumeration, and search. Combined with a comprehensive ML/tensor engine and complete web stack, it enables synthesis of:
Coverage: 420/420 synthesis problems (Mog: 315/315, nSynth: 105/105)
Three Pillars:
cd nsynth
cargo run --release --bin nsynth_codegen --lang python --examples '{
"name":"reverse","signature":"fn reverse(arr: List) -> List",
"examples":[{"inputs":[[1,2,3]],"expected":[3,2,1]}]
}'
# → def reverse(arr): return arr[::-1]The neural ALU injected into a transformer's forward pass as a routed expert. A learned per-token gate decides whether each token flows through the original MLP or through the neural ALU. Bilinear soft truth tables provide differentiable logic, tensor ops provide differentiable arithmetic, and gating is modulated by model confidence.
Results from an 11-model sweep across the Qwen 2.5/3/3.5 families, on arithmetic tasks:
| Model | Arithmetic accuracy | Note |
|---|---|---|
| Qwen3.5-2B (instruct) | 14.5% → 71.0% (+56.5 pp) | best overall |
| Qwen3.5-2B (base) | 15.5% → 63.0% (+47.5 pp) | 100% on ADD/SUB/MUL/DIV |
| Qwen3.5-4B | +51.0 pp | largest base-model gain (tied) |
| Qwen3.5-9B | +51.0 pp | largest base-model gain (tied) |
Real-world transfer is measured, not extrapolated: on full HumanEval (Qwen3.5-4B, A100), 62.2% → 64.6% — four additional problems solved.
A predictive world model of the computer itself. Alongside exact execution, a JEPA-style network (Joint Embedding Predictive Architecture) learns to predict machine state transitions in a compressed latent space:
latent_state_t + instruction → predictor → latent_state_{t+1}It runs at two levels. A Python demo (ncpu/jepa_neural_cpu/) executes real
programs next to the predictor, turning prediction error into a live anomaly
signal. A Rust Metal implementation (kernels/rust_metal/src/jepa/, 2,858
lines) observes deterministic GPU execution and actively steers scheduling
through learned bias overrides.
Because the substrate underneath is exact, this world model has two properties most lack: unlimited free ground truth (run more programs), and the ability to mix predicted and exact execution at will — cheap latent speculation when exploring, exact execution when it matters. The long-term direction is a hierarchy of predictors at the bit, instruction, program, and task levels.
python3 -m ncpu.jepa_neural_cpu.demo # bottom-up JEPA neural computer demo
python -m ncpu.world_model.quickstart # JEPA machine world model quickstart…| Mode | What runs | Differentiable? | Speed |
|---|---|---|---|
| Neural | 13 trained .pt models |
yes — full gradient flow | ~5K IPS |
| Fast | native tensor ops | yes — standard autograd | ~5K IPS |
| Compute | Rust + Metal shader | no (discrete hardware) | ~1.9M IPS |
All three execute the same programs and produce the same results. Neural mode sends every operation through trained networks. Fast mode uses native tensors with the same ISA and the same differentiability. Compute mode trades gradient flow for speed — it is where the UNIX OS boots, the compiler self-hosts, and BusyBox runs.
…| Layer | Implementation | Result |
|---|---|---|
| ALU | 13 trained .pt models |
Exact 32-bit integer arithmetic, exhaustively verified |
| OS | neurOS — 11 neural models, no fallbacks | Learned MMU, TLB, cache, scheduler, compiler |
| GPU compute | Rust Metal kernel, ~200 ARM64 instructions | Arbitrary programs at ~1.9M IPS |
| UNIX OS | Compiled C on Metal | fork/pipe/wait, 25-command shell, 28 syscalls |
| Compiler | cc.c, ~4,200 lines, self-hosting | Compiles itself, then compiles programs — on GPU |
| ELF loader | Real Linux binaries on GPU | BusyBox and Alpine Linux v3.20 on Metal |
| Coprocessor | Neural ALU in a transformer forward pass | Tokens routed through neural arithmetic, measured gains |
| JEPA | Predictive world model of machine dynamics | Latent speculation + anomaly detection over an exact substrate |
| Program synthesis | Backprop through execution | Programs discovered from I/O examples |
| Constant-time crypto | AES-128 ECB/CBC (ncpu/crypto/) |
σ = 0.0 timing; FIPS 197 + NIST SP 800-38A vectors pass |
| Multi-GPU | Distributed cores with shared memory | fork/pipe/wait across GPUs; parallel and pipeline execution |
| SOME | Hidden controller with latent heads | Self-optimizing inference; HumanEval+ and BigCodeBench gains |
GPU execution here produces zero cycle-count variance — σ = 0.0 across 270 runs, where the same code on native Apple Silicon shows 47–73% timing variance. With no data cache there are no cache lines and no cache-miss penalty, so AES T-table attacks have nothing to measure.
Built on that property, ncpu/crypto/ provides constant-time AES-128 (ECB and
CBC) from 19 constant-time primitives, passing all FIPS 197 and NIST SP
800-38A test vectors.
A hidden controller that turns part of the neural machine into an internal coprocessor for code generation: a buffered think → write → verify → patch → commit loop, learned action/halt/descriptor/state-patch/memory heads, and task-local fast weights updated during inference. The learned memory head improved validation MSE by 83.26% over baseline.
Measured end to end: HumanEval+ for qwen3.5:4b improved 147 → 154 and for qwen3.5:9b 144 → 156; BigCodeBench-Hard for qwen3.5:9b improved 33 → 49.
SUBLEQ plus MUX, running in all three execution modes. In neural mode, SUB
goes through the Kogge-Stone carry-lookahead (~248 µs) and MUX through neural
AND/OR/NOT (~63 µs). It loads .dec images and boots eForth. The point: if
trained networks exactly execute a two-instruction one-instruction-set
computer, the construction extends to any instruction set.
cargo build --release --bin nsynth_codegen
./target/release/nsynth_codegen --lang python --examples '{
"name":"square","signature":"fn square(x: i64) -> i64",
"examples":[{"inputs":[0],"expected":0},{"inputs":[3],"expected":9}]
}'
# → def square(x: int): return (0 * x * x) + (1 * x * x) + 0…Every top-level directory has its own README.md describing its purpose.
python -m ncpu doctor
pytest tests/ -q # 2,500+ tests across the stackCoverage spans exhaustive formal verification of the ALU, neural ops, neurOS, compute mode, multi-process execution, MUXLEQ, BusyBox/Alpine, the GPU debugging toolkit, the coprocessor, Mog sy
No open issues yet, or sync has not completed.