Skip to the content
PCBKitNew board
4 layers70 × 50 mmStage0 5, the printed circuit board in 3D

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

5

README

README.md

MinAI

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:

PlatformFileHow 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.exedouble-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++):

bash
make              # builds ./minai with your default C++ compiler
./minai           # trains the default config and runs a demo
./minai --help    # see all flags

Windows (and an all-platforms fallback) via CMake:

bash
cmake -B build
cmake --build build --config Release
./build/minai --help          # macOS/Linux
./build/Release/minai.exe     # Windows MSVC

No 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:

text
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 0

Read 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.cpp and including a hands-on walkthrough of every flag. Section 2 (Chs 16–22) grows the program into maxai.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

text
--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

text
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              MIT

Credit

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
QtyValueFootprintReferences
14100nFflux2kicad:C_0603_1608MetricC1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14
1240k 0.1%flux2kicad:R_0603_1608MetricR12, R13, R14, R15, R16, R17, R18, R19, R20, R21, R22, R23
910kflux2kicad:R_0603_1608MetricR1, R2, R3, R4, R5, R6, R8, R9, R11
8Test Point 1.8mmflux2kicad:Test_Point_1.8mmTP1-GND, TP2 VOUT, TP3 VLOW, TP4 VLSB, TP5 A3V3, TP6 D3V3, TP7 AGND, TP8 DGND
610uFflux2kicad:C_0603_1608MetricC15, C16, C17, C18, C19, C20
6MCP4251-103E/SLflux2kicad:SOIC-14_3.9x8.7mm_P1.27mmU1, U2, U3, U4, U5, U6
3OPA2333AIDGKTG4flux2kicad:easyeda2kicad_VSSOP-8_L3.0-W3.0-P0.65-LS4.9-BLU11, U12, U13
210k 0.1%flux2kicad:R_0603_1608MetricR7, R10
22.56M 0.1%flux2kicad:R_0603_1608MetricR24, R25
24.7kflux2kicad:R_0603_1608MetricR26, R27
113Ω 5%flux2kicad:R_0603_1608MetricR28
1302-S401flux2kicad:302-S401J1
1ADS1115IDGSRflux2kicad:Package_SO_VSSOP-10_3x3mm_P0.5mmU9
1AMS1117-3.3flux2kicad:Package_TO_SOT_SMD_SOT-223U10
1BLM18AG601SN1Dflux2kicad:Fuse_0603_1608MetricFB1
1LOGOsilkscreen:logo35x14G***
1MCP4728A0T-E/UNflux2kicad:Package_SO_MSOP-10_3x3mm_P0.5mmU8
1SN74HC138PWRflux2kicad:easyeda2kicad_TSSOP-16_L5.0-W4.4-P0.65-LS6.4-BLU7

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 mmBus sonar10, the printed circuit board in 3D

    Bus sonar10

    makerbus/bus_sonar10

    Connect 10 sonar modules to a bus.

    40 parts
  • 2 layers60 × 34 mmMiniNDP, the printed circuit board in 3D

    MiniNDP

    bkw777/NODE_DATAPAC

    Reproduction & documentation of Node Systems DATAPAC

    21 parts7
  • 4 layers100 × 100 mmLabathome pcb, the printed circuit board in 3D

    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 mmPhase interferometer, the printed circuit board in 3D

    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 mmDLTM Old, the printed circuit board in 3D

    DLTM Old

    poakzmmz/NS26F-Datalogger-HW

    NS26F Datalogger HW

    108 parts
  • 2 layers76 × 35 mmGround station, the printed circuit board in 3D

    Ground station

    Horizon-Avionics/Horizon-H1

    Building a fully open-source flight computer for amateur rocketry!

    38 parts17
  • 2 layers70 × 70 mmSensactUp4, the printed circuit board in 3D

    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 mmPi hat LoRa, the printed circuit board in 3D

    Pi hat LoRa

    Doenec/pi-hat

    collection of different shields to be stacked in raspberry pi

    80 parts1MIT