

Stage0 5
A single-file C++ transformer built to be read — every mechanism of a modern LLM in ~780 lines, with a textbook companion.
- Size
- 70 × 50 mm
- Copper layers
- 4
- Thickness
- 1.37 mm
- Parts
- 72
- Nets
- 75
- Pads
- 294
- Tracks, vias
- 989, 119
- Pours
- 1
- Routed
- Yes
- KiCad
- KiCad 10.0 (file 20260206)
- Created
- 16 Apr 2026
- Updated
- 6 May 2026
Overview
Stage0 5 is an open-source printed circuit board by essen48183, from the essen48183/MinAI repository on GitHub, published under the MIT licence. It is a 4-layer board of 70 × 50 mm with 72 parts on 75 nets, routed with 989 tracks and 119 vias.
It is built around the ADS1115IDGSR, MCP4251-103E/SL and AMS1117-3.3, with the 302-S401 and BLM18AG601SN1D among its other parts. Its parts include 28 resistors, 20 capacitors, 13 ICs and 1 connector.
Main components
5ADS1115IDGSR
VSSOP-10-40℃~+125℃ 16 1LSB 2 2.048V 2V~5.5V 500nA 860Hz 8Hz、16Hz、32Hz、64Hz、128Hz、250Hz、475Hz、860Hz Built-in Built-in I2C Sigma-Delta Support Yes VSSOP-10 Analog to Digital Converters (ADC) ROHSTexas InstrumentsAnalog To Digital Converters (ADC)MCP4251-103E/SL
SOIC-14-40℃~+125℃ 1.8V~5.5V 10kΩ 1LSB 1MHz 2 2.5uA 257 50ppm/℃ 75Ω Linear Power-on reset RAM SPI ±20% SOIC-14 Digital Potentiometers ROHSMicrochip TechnologyDigital PotentiometersAMS1117-3.3
SOT-223-40℃~+125℃ 0.003%Vout 1 1.1V@(800mA) 15V 1A 3.3V 5mA 72dB@(120Hz) Fixed Over Current Protection、Short Circuit Protection、Thermal shutdown Positive SOT-223 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSAdvanced Monolithic SystemsVoltage Regulators - Linear, Low Drop Out (LDO) Regulators302-S401
插件插件 Wire To Board Connector ROHSOn-Shore TechWire To Board ConnectorBLM18AG601SN1D
0603-55℃~+125℃ 1 380mΩ 500mA 600Ω@100MHz ±25% 0603 Ferrite Beads ROHSMurataFerrite Beads
README
README.mdMinAI
A single-file C++ transformer, built to be read. Every mechanism of a modern LLM — attention, softmax, backprop, residual connections, causal masking — in ~780 lines of heavily commented code. Learns to reverse a list of 8 digits (and sort, shift, or mod-sum), demonstrating in miniature every idea that powers GPT-4.
Descends from Damien Boureille's ATTN-11 (PDP-11 MACRO-11 assembly) via Dave Plummer's 2.11BSD port. Portable C++17 — builds on macOS, Linux, and Windows.
Why this exists
It's easy to lose the plot on what a large language model does when every explanation starts at "96 transformer blocks". This program is the plot — the irreducible version that still contains every mechanism. If you can read ~780 lines of commented C++, you understand the skeleton of every frontier model. The only difference between this and GPT-4 is quantity: more layers, more heads, more width, more data. Not one new idea.
Quick start — two paths
If you just want to run it (no compiler, no programming required)
Prebuilt binaries for common platforms live in bin/. Grab the one for your platform and run it from a terminal:
| Platform | File | How to run |
|---|---|---|
| macOS (Apple Silicon or Intel) | bin/macos-universal/minai | ./minai from a terminal |
| Linux (x86_64) | bin/linux-x86_64/minai | ./minai from a terminal |
| Windows (x86_64) | bin/windows-x86_64/minai.exe | double-click or run from cmd/PowerShell |
See bin/README.md for details (including the macOS Gatekeeper first-run workaround). After it runs, ./minai --help shows every flag.
If you want to read and modify the source
macOS / Linux (any C++17 compiler — clang++ or g++):
make # builds ./minai with your default C++ compiler
./minai # trains the default config and runs a demo
./minai --help # see all flagsWindows (and an all-platforms fallback) via CMake:
cmake -B build
cmake --build build --config Release
./build/minai --help # macOS/Linux
./build/Release/minai.exe # Windows MSVCNo external dependencies — everything needed is in the standard library. Colored sparkline output uses Unicode block characters; works in macOS Terminal, Linux terminals, and Windows Terminal (the default on Windows 11).
Abridged output:
MinAI — fixed example, task=reverse, seq_len=8, batch=1, blocks=1, ffn=on, causal=off
Parameters: 2240 Training steps: 800
step loss correct/8
----- ------ ----------
1 2.2802 0/8
...
800 0.0078 8/8
Loss curve (800 steps, 60 columns, higher bars = higher loss):
2.280 |▇▇▇▇▆▆▆▅▅▄▄▃▃▂▂▁▁ | 0.008
step 1 step 800
input : 0 1 2 3 4 5 6 7
output : 7 6 5 4 3 2 1 0Read the docs
Two companion documents live next to the source. Read the one that matches you:
-
TRAINER.md / TRAINER.pdf — the terse operator's manual. Flag reference, task zoo, worked examples. If you already know what a transformer is and just want to drive this one, start here.
-
ARITHMETICOFINTELLIGENCE.md / ARITHMETICOFINTELLIGENCE.pdf — The Arithmetic of Intelligence, a three-section textbook that builds every concept from scratch: what a model is, what attention does, why GPUs are suddenly the bottleneck of the AI industry. Section 1 (Chs 1–15) is the simple introduction, grounded in
minai.cppand including a hands-on walkthrough of every flag. Section 2 (Chs 16–22) grows the program intomaxai.cpp, a toy GPT that accepts prompts, tokenizes with BPE, samples with temperature/top-k/top-p, and runs under a KV cache. Section 3 (Chs 23–28) is a career/field essay on where AI is going and why software engineering is not ending. Written for a reader who has taken some math but has never seen why any of it mattered; a curious adult with high-school algebra can follow it end to end.
Read either document with minai.cpp open alongside. The comments in the source are in the same tone and will not contradict the prose.
Flags at a glance
--blocks=N stack N transformer layers (1..96, default 1 — 96 matches GPT-3 depth)
--ffn=0|1 include the feed-forward sub-layer (default on)
--causal=0|1 causal attention mask (default off)
--layernorm=0|1 Pre-LN normalization before each sub-layer; makes deep stacks trainable
--random=0|1 train on random sequences + measure held-out accuracy (default off)
--seq_len=N sequence length 1..32 (attention is O(N^2) in this)
--batch=B examples averaged per step 1..128 (default 1)
--task=NAME reverse | sort | shift | mod_sum (default reverse)
--steps=N training iterations (default 800)
--extra_demos=0|1 run three bonus demos after training (hierarchical weight quantization,
speculative decoding, KV cache tiering). Each is a real LLM inference
technique, shown in miniature. Adds a few seconds.Try ./minai --random=1 --blocks=2 --batch=16 --layernorm=1 --steps=3000 for a taste of how a real LLM trains in miniature — the model has to generalize, not memorize, and with LN + batch the grokking moment should land well before 3000 steps.
Repo layout
minai.cpp the program — 19 numbered parts, every line commented
Makefile one-line clang++ build
TRAINER.md .pdf operator's manual
ARITHMETICOFINTELLIGENCE.md .pdf .docx the book — textbook, toy-GPT growth, career essay
maxai.cpp the Section-2 companion program (grows from minai.cpp)
README.md this file
CLAUDE.md instructions for the AI assistant that maintains this project
md2pdf.sh regenerates PDFs from the .md sources
LICENSE MITCredit
Damien Boureille wrote the ATTN-11 original in PDP-11 MACRO-11 assembly. Dave Plummer ported it to 2.11BSD as. This repo is the C++/Apple-Silicon rewrite with extensive annotation, a textbook companion, and runtime flags for blocks / FFN / causal / random / seq_len / batch / task. The core idea — "tiny transformer, every mechanism present, no magic" — is entirely theirs.
Parts
72| Qty | Value | Footprint | References |
|---|---|---|---|
| 14 | 100nF | flux2kicad:C_0603_1608Metric | C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14 |
| 12 | 40k 0.1% | flux2kicad:R_0603_1608Metric | R12, R13, R14, R15, R16, R17, R18, R19, R20, R21, R22, R23 |
| 9 | 10k | flux2kicad:R_0603_1608Metric | R1, R2, R3, R4, R5, R6, R8, R9, R11 |
| 8 | Test Point 1.8mm | flux2kicad:Test_Point_1.8mm | TP1-GND, TP2 VOUT, TP3 VLOW, TP4 VLSB, TP5 A3V3, TP6 D3V3, TP7 AGND, TP8 DGND |
| 6 | 10uF | flux2kicad:C_0603_1608Metric | C15, C16, C17, C18, C19, C20 |
| 6 | MCP4251-103E/SL | flux2kicad:SOIC-14_3.9x8.7mm_P1.27mm | U1, U2, U3, U4, U5, U6 |
| 3 | OPA2333AIDGKTG4 | flux2kicad:easyeda2kicad_VSSOP-8_L3.0-W3.0-P0.65-LS4.9-BL | U11, U12, U13 |
| 2 | 10k 0.1% | flux2kicad:R_0603_1608Metric | R7, R10 |
| 2 | 2.56M 0.1% | flux2kicad:R_0603_1608Metric | R24, R25 |
| 2 | 4.7k | flux2kicad:R_0603_1608Metric | R26, R27 |
| 1 | 13Ω 5% | flux2kicad:R_0603_1608Metric | R28 |
| 1 | 302-S401 | flux2kicad:302-S401 | J1 |
| 1 | ADS1115IDGSR | flux2kicad:Package_SO_VSSOP-10_3x3mm_P0.5mm | U9 |
| 1 | AMS1117-3.3 | flux2kicad:Package_TO_SOT_SMD_SOT-223 | U10 |
| 1 | BLM18AG601SN1D | flux2kicad:Fuse_0603_1608Metric | FB1 |
| 1 | LOGO | silkscreen:logo35x14 | G*** |
| 1 | MCP4728A0T-E/UN | flux2kicad:Package_SO_MSOP-10_3x3mm_P0.5mm | U8 |
| 1 | SN74HC138PWR | flux2kicad:easyeda2kicad_TSSOP-16_L5.0-W4.4-P0.65-LS6.4-BL | U7 |
Questions
How big is the Stage0 5 PCB?
It measures 70 × 50 mm and has 4 copper layers, 1.37 mm thick.
What parts does the Stage0 5 use?
72 parts, built around the ADS1115IDGSR, MCP4251-103E/SL, AMS1117-3.3 and 302-S401. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
Where can I download the Stage0 5 KiCad files?
From the essen48183/MinAI repository on GitHub, at the commit this page was made from: the board is analog-sidequest/stage0_5-hardware/Stage0_5.kicad_pcb and its schematic analog-sidequest/stage0_5-hardware/Stage0_5.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the Stage0 5 design in my own project?
Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).
Similar boards
- 2 layers100 × 50 mm

- 2 layers60 × 34 mm

- 4 layers100 × 100 mm

Labathome pcb
klaus-liebler/labathome
Der kleine Bruder von lab@home. Ermöglicht das Experimentieren mit PT1...PTn-Gliedern, die intern als RC-Kombination (entkoppelt über Operationsverstärker) ausgeführt sind.
292 parts5MIT - 4 layers54.3 × 76.1 mm

Phase interferometer
mpkendall/phase-interferometer
A 2(or more)-element phase interferometric direction finder for 433 MHz using a passive phased array
78 parts3 - 2 layers77 × 80 mm

- 2 layers76 × 35 mm

Ground station
Horizon-Avionics/Horizon-H1
Building a fully open-source flight computer for amateur rocketry!
38 parts17 - 2 layers70 × 70 mm

SensactUp4
klaus-liebler/sensact
Es gibt vier Namespaces für Nachrichten "REQUEST" und "RESPONSE", "EVENT" und "ACKNOWLEDGE". Dies wird mit den beiden LSB des Versions-Namespace-Bytes erklärt (Somit bleiben 64 Versionierungsmöglichkeiten) Alle vier…
147 parts4Apache-2.0 - 2 layers65 × 56 mm
