A minimalist implementation of the EGGROLL (Evolution Guided General Optimization via Low-rank Learning) algorithm in Rust.
This project demonstrates integer-only training of a language model directly on the CPU (optimized for Apple Silicon/M-series chips), completely bypassing the need for GPUs, floating-point arithmetic, or heavy ML frameworks like PyTorch or JAX.
- Pure Rust: Minimal dependencies (rayon for threading, memmap2 for memory mapping).
- Apple Silicon Optimized: Vectorized operations using ARM NEON intrinsics and parallelized via rayon.
- Integer Only: Operates entirely on
i8weights/activations withi32accumulation. No float math in the training loop. - Gradient Free: Uses Evolution Strategies (ES) with low-rank perturbations instead of backpropagation.
| Implementation | Avg Tok/s |
|---|---|
| Rust | 11752.53 |
| C | 10221.27 |
Apple M4 Pro, 48 GB RAM, macOS 15.3
Ensure you have a text dataset named input.txt in the current directory.
cargo build --release./target/release/egg-rsConfiguration constants are defined at the top of src/main.rs:
const VOCAB_SIZE: usize = 256;
const HIDDEN_DIM: usize = 128;
const N_LAYERS: usize = 2;
const SEQ_LEN: usize = 512;
const POPULATION_SIZE: usize = 32;python3 bench/bench.py ./target/release/egg-rs- C Implementation: d0rc/egg.c
- Original JAX Implementation: ESHyperscale/nano-egg
- Original Paper & Project: EGGROLL Website