A 30B AI in 10 KB, no OS, on a 1987 laptop

10KILOMIND is a chat window for a large language model, and the whole program is 9,972 bytes. There is no Linux and no operating system under it: the Raspberry Pi’s firmware loads those 9,972 bytes, they unpack themselves, and then they run Qwen3-30B-A3B, a model with 30 billion weights, straight from the SD card. It answers at 2.7 tokens per second (about two words a second) inside the case of a Toshiba T1200, a laptop from 1987, and on the right of the screen a map lights up with every expert the model uses.
It’s a demo in the old demoscene sense, with a tiny file, a big effect and every byte fought for. Ask it for a haiku about a computer that is only 10 kilobytes, and it writes:
Tiny brain, so small,
10 KB, no room to roam.
Silent, fast, and bright.
The code, the docs and ready-made card files are on GitHub.

The short version
- The program: 9,972 bytes of AArch64 assembly on the SD card. It holds the whole engine, the tokenizer, the USB keyboard and SD card drivers, the screen and the font.
- The model: a mixture-of-experts model that uses only 3 of its 30 billion weights per token, cut to the 80 most used of 128 experts per layer so it fits into 8 GB, at 2-3 bits per weight.
- The speed: 2.7 tokens per second. The prompt appears 13 seconds after the program starts, your question is processed while you type it, and the rest of the model streams in meanwhile.
- The weak spot: removing 48 experts per layer costs 13 % in quality.
The demo at four times the real speed: 10KILOMIND on the Toshiba T1200 on YouTube.
A few names you’ll meet:
| Name | What it is |
|---|---|
| Bare metal | a program that runs on the hardware directly, with no operating system |
| Token | a piece of a word; a model reads and writes one token at a time |
| Mixture of experts (MoE) | a model whose layers have many small “experts”; each token goes through only a few of them (here 8) |
| Perplexity | how surprised a model is by real text; lower is better |
| GGUF, llama.cpp | the usual file format for local models and the engine most people run them with |
| Packer | a compressor whose output unpacks itself when it starts |
| Demoscene | the people who make 4 KB and 64 KB programs that play whole films of graphics and music |
The machine and the rules
The Toshiba T1200 keeps its original case and its keyboard, which sounds wonderful (here it is). A Teensy 4.1 reads the keyboard through its 22-pin ribbon cable and speaks USB (following this guide), a Waveshare 10.4-inch panel with 1600 x 720 pixels sits where the old screen was, and the brain is a Raspberry Pi 4 with 8 GB.
For a language model that brain is weak. Its Cortex-A72 cores have no dot-product instructions, which fast AI engines on ARM use for almost everything, its memory moves about 3.5 GB/s, far less than a Pi 5, and the SD card is the only disk.
So I set rules like a demo competition:
| Rule | Why |
|---|---|
| One SD card image, flash it and power on | no installer, no second disk |
| No operating system, AArch64 assembly | nothing between the program and the hardware |
| Only the file on the card counts | RAM is free, so the program may use megabytes to save bytes |
| Speed counts as much as size | a small program that answers slowly is no fun |
| English only, the font inside the program | fewer tokens, no font files |
| It has to look cool | it’s a demo |
The smallest thing that runs an LLM
The usual way to run this model on a Pi is Raspberry Pi OS and llama.cpp. That gives you every model, sampling settings and a network, and it costs gigabytes of operating system that has to boot before anything happens. The closest relative of 10KILOMIND is llm.asm, a set of x86-64 assembly programs that run Qwen3-0.6B at 8 bits: as a Linux program it’s 14,712 bytes, as its own bootable bare-metal OS 24,252 bytes, and on a big server CPU it beats llama.cpp on the same model.
| Raspberry Pi OS + llama.cpp | llm.asm | 10KILOMIND | |
|---|---|---|---|
| Runs on | Linux | x86-64 with AVX2, as a static program or its own OS | a Raspberry Pi 4 (or 5), no OS |
| Model | any GGUF | Qwen3-0.6B, 8 bits | Qwen3-30B-A3B, 2-3 bits, 80 experts |
| Program size | gigabytes with the OS | 14,712 / 24,252 bytes | 9,972 bytes |
| Start | OS boot, then loading | its own OS boots in 74-94 ms | prompt after 13 s, rest in the background |
10KILOMIND doesn’t use code from either, but it leans on both. It reads llama.cpp’s GGUF quantization formats bit for bit and quantizes its activations the way llama.cpp does, so its answers can be checked against llama.cpp token by token. What I’d love to know is the race on the same board, the same 80-expert model under Raspberry Pi OS and llama.cpp. The estimate is 1.5-2.5 tokens per second there, because Linux uses small memory pages and llama.cpp’s routines are more general, but nobody has measured it yet.
How one token is made

A language model only ever answers one question: given everything so far, what’s the next token? The tokenizer, also in assembly, cuts the text into pieces with Qwen’s split rule and merges letters into tokens with a hash table of merge pairs. The token’s row of the embedding table becomes the starting vector, and that vector goes through 48 layers. In each layer, attention looks back at every earlier token through the key/value cache, and then the router scores the layer’s experts and routes the token to the best 8, each a small network of three matrices. At the end the output layer gives a score to each of the 92,579 tokens, the best one is printed, and it goes back in as the next input.
There’s no sampling and no temperature: 10KILOMIND always takes the most likely token. Everything the engine needs to know about the model is in the model file (sizes, token strings, merge table, rotation table, the chat template), so the same 10 KB would run any Qwen3-style model, and a dense model is simply a model with one expert.
The expert map
The coolest part of the screen is the map on the right. It has a column for each of the 48 layers and a row for each expert, and every time the router picks an expert, its cell lights up: pink when the expert was already in RAM, orange when it first had to be read from the SD card. Then the cell fades through blue to dark in about a second, 15 steps of 83 ms. A grey marker above the map sweeps from left to right once per token, so you see the model think layer by layer, and nothing is reset between tokens, so an expert the model keeps using leaves a bright streak.

The map also shows what’s in memory. The experts are numbered by how often they’re used, so the most used sit in the top rows, and a resting cell is dark while its expert is still on the card and lighter once it’s in RAM. Right after start-up only the top rows are light, the first question lights up orange wherever it needs an expert from the card, and over the next minutes you can watch the whole map turn light as the background loading completes. Before all that, while the shared part of the model is read, the map works as a progress bar: it fills column by column, blue at the top to pink at the bottom, with the percentage in big letters where the tokens per second will be.

The drawing never slows the model down. The engine calls the map once for each expert it runs, the fading happens between layers and while the program waits for a key, and only cells whose colour really changed are drawn. With 80 experts the rows are 5 pixels high and fill the same 512-pixel panel as 128 would. The whole map costs 555 bytes on the card, and it’s my favourite part of the screen.
Typing in real time
A chat feels slow mostly in the pause after Enter, while the model prefills your whole question. In 10KILOMIND prefill runs while you type. Every pre-tokenizer piece except the last is stable under appending (typing more can only change the last word, number or run of punctuation), so those pieces go through the model between keystrokes, with the keyboard polled between layers so typing stays smooth. Backspace keeps the pieces that are still valid and rolls the context position back.
After Enter only the last piece and the chat-template tokens are left. The experts your question needs are routed while you type, so any that were still on the card are already read by then. The first chat starts even earlier: the system prompt’s KV state ships precomputed in the model file, so the Pi copies it into the cache and never runs the system prompt.
Speed: it’s all about memory
For every token the model has to read every weight that token uses. On a small board the memory bus is the limit, rarely the CPU, so the speed trick is to read fewer bytes per token and to read each of them only once.

The biggest trick is the model itself. Qwen3-30B-A3B routes each token to 8 of 128 experts per layer, so it has the knowledge of a 30B model and streams only about 3 billion weights per token, which makes it faster on this board than an ordinary 4B model and much smarter. The Q2_K/Q3_K weights stay bit-exact GGUF and are never dequantized into memory: each row is read once and multiplied on the fly, about 1.1 GB per token.
Then come the small tricks:
- The Cortex-A72 has no SDOT, so the kernels accumulate four 2/3-bit products in 16-bit lanes before widening.
- Sub-block codes are interleaved, so one register gives four partial sums and the scales go on with one vector multiply: about 55 instructions per 256 weights in the 2-bit kernel.
- The rows of every matrix are split over the four cores. Query heads that share a KV head are processed together, so the cache is read once per token where a naive loop reads it eight times.
- The KV cache is int8 with per-head scales, a quarter of the traffic, with no measurable perplexity loss (6.70 against 6.75).
- “English only” drops every token that isn’t plain ASCII: 92,579 of 151,936 stay, so the output layer reads 81 MiB per token where it read 134.
- Memory is mapped in 1 GB pages, so streaming gigabytes of weights causes almost no page-table misses, and the 2- and 3-bit kernels prefetch ten cache lines ahead.
The model also had to fit into 8 GB, and the full 9.6 GB file doesn’t. So I pruned it by routing statistics: on almost 14,000 tokens of English chat I counted which experts the router picks, and kept the 80 most used per layer.

A quarter of the experts can go for free, and 80 of 128 fits 8 GB for +13 % perplexity. A smaller ordinary model would fit easily, but it would read more bytes per token and be slower.
It’s memory-bound, and the proof came when the CPU clock went from 1,500 to 1,800 MHz and the speed didn’t change a thing.

The engine streams about 1.1 GB per token at roughly 83 % of the measured DRAM bandwidth, so the only way up is fewer bytes. Six experts per token instead of eight would be 13 % faster for 5 % worse perplexity, and I kept eight.
Size: the demoscene part
The program is about 18 KB before any packing, so most of the size work happens in the packer. Demosceners use context-mixing packers for 4 KB intros, and they have one great idea: the unpacker may use lots of memory. Here RAM is free, so the unpacker uses 9.5 MB of tables.
It works bit by bit, and several small models each guess the next bit: one looks at the bytes just before it, one at where the byte sits inside its 4-byte instruction, one follows the longest earlier match, and so on. A tiny mixer learns which model to trust, and a range coder stores only the surprise. The packer tries all 255 combinations of models and keeps the best. gzip makes 12,812 bytes of the same program, and this packer makes 10,607 including its own unpacker.

The best tricks were about what this packer likes:
| Trick | Bytes saved on the card |
|---|---|
| Store every instruction with its opcode byte first, so the models see the opcode before the operands, and give calls absolute targets, so the same call looks the same everywhere | 450, for one extra instruction in the unpacker |
| Cut the program into units and search their order, with the real packer as the judge | about 160 |
| Put small routines into the empty space before the exception vector | 212 of padding |
| Fill only one exception vector slot and lay the table over the program’s own start | about 2 KB of table |
| Keep all model knowledge in the model file | almost no tables in the program besides the font |
| Unpack the embedding table with the weight kernel itself, run on an input with a single 1 | no unpacking code at all |
The surprise was that the usual size-coding habits work against this packer. Shared subroutines with common exit code made the packed file 20 bytes bigger, because repeated identical code costs almost nothing once the models have seen it, while every jump to shared code is new information. So the routines got their own exit code back, 330 bytes bigger in memory and 20 smaller on the card. A bytecode interpreter for the drivers is unlikely to help for the same reason, and no published measurement shows it beating strongly packed native code.
The ideas that didn’t pay teach as much. Three ideas from demoscene research promised 190-570 bytes together, and they gave 60. Separate models for code, text and font saved 68 bytes of data and cost 108 bytes of unpacker. An 8 x 8 font was supposed to save 250-300 bytes and saved 55 to 59, because the 8 x 16 glyphs already pack to a third and the small ones barely pack at all.
The last 1,400 bytes, from 11,380 down to 9,972, came from removing everything my board doesn’t need.
How it works now

The firmware loads only the small file, which unpacks itself and then reads the model straight from a fixed block on the card, with no file system code. Everything is polled, with no interrupts, and one level of page table maps the whole memory twice, once cached for the weights and once uncached for the screen and the USB and SD controllers.
Looking back
Good
- A mixture-of-experts model on a memory-starved board: the speed of a small model with the answers of a big one.
- Reading the question while it’s typed, which makes the answer start almost at once after Enter.
- The expert map, which turns an invisible process into something you can watch.
- Context mixing with a big unpacker. Once RAM was free, the packer did more than all the code golf together.
- Measuring every cut on real text first, which showed the 8-bit cache and a quarter of the experts to be free.
Not so good
- 80 experts of 128 is a real loss (13 %), and the board can’t hold more.
- 2.7 tokens per second is close to the limit, so there’s no big speed jump left on this board.
- No sampling: always taking the most likely token makes answers repeatable but sometimes dull.
- Most byte estimates were too optimistic, from the vocabulary to the font, and the demoscene numbers didn’t transfer to ARM code.
Versions
| Thing | Version |
|---|---|
| Computer | Raspberry Pi 4 Model B, 8 GB, 1,800 MHz (arm_boost=1), in a Toshiba T1200 case |
| Screen and keyboard | Waveshare 10.4HP-CAPQLED, 1600 x 720 over HDMI; the T1200 keyboard on a Teensy 4.1 |
| Program | 10KILOMIND, 9,972 bytes packed (1,016 of them the unpacker), AArch64 assembly; a Pi 5 build of 10,607 bytes runs in the emulator |
| Model | Qwen3-30B-A3B-Instruct-2507, ByteShape GGUF at 2.70 bits per weight, 80 of 128 experts per layer, 92,579 tokens, context 2,048 |
| Font | Spleen 8 x 16 |
| Testing | QEMU (virt with Cortex-A76 and A72, raspi4b), a NumPy reference |
| Tried and dropped | gzip, an LZ packer, separate packer models, shared exit code, the 8 x 8 font, six experts per token, overclocking |
Comments
Comments are GitHub Discussions; you need a GitHub account to write one.