- Assembly 58.1%
- Python 39.7%
- Shell 2.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .claude/skills | ||
| .github/workflows | ||
| brain | ||
| kernel | ||
| scripts | ||
| src/token0 | ||
| tests | ||
| .gitignore | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| icon.svg | ||
| LICENSE | ||
| LICENSE-MIT | ||
| LICENSE-WTFPL | ||
| mise.toml | ||
| pyproject.toml | ||
| README.md | ||
| ROADMAP.md | ||
| TODO.md | ||
| uv.lock | ||
token0
A bare-metal x86-64 operating system, written in assembly, that boots straight into a language model. Power on, and a few milliseconds later Qwen3-0.6B is waiting for your first message: no Linux, no libc, no C, no drivers beyond a serial port, a text screen (VGA, or a framebuffer under UEFI) and a PS/2 keyboard.
Status: usable. The kernel boots into a multi-turn chat with Qwen3-0.6B or Qwen3-1.7B on every core, bit-exact with the numpy reference, from QEMU or a bootable BIOS/UEFI ISO. Real hardware is next (ROADMAP.md).
Usage
token0 convert ~/models/Qwen3-0.6B -o models/qwen3-0.6b.t0 # safetensors -> .t0
token0 run models/qwen3-0.6b.t0 # boot it under QEMU/KVM
token0 0.8.1
cpus: 4, threads 4
model: 28 layers, dim 1024, vocab 151936, context 2048, 616 MiB
ready: 215 ms after power-on, 10 ms in the kernel
chat with the model; /help lists the commands
> What is the capital of France?
The capital of France is **Paris**.
[9 tokens, 368.5 tok/s prefill, 9 typed ahead, 95.4 tok/s decode, context 30/2048]
>
To boot a real machine, take token0-<version>-qwen3-0.6b.iso (or the
1.7B one) from the releases,
or build one, then copy it to a Ventoy stick or
write it to a USB stick:
mise run iso models/qwen3-0.6b.t0 # build/token0.iso, BIOS + UEFI
sudo dd if=build/token0.iso of=/dev/sdX bs=4M status=progress
It boots under UEFI and legacy BIOS (CSM). The chat uses the screen (the firmware's framebuffer at native resolution under UEFI, VGA text under BIOS) and a PS/2 keyboard; USB keyboards work through the firmware's legacy emulation where it provides one. Loading the model from a stick takes about a minute.
Options go on the Multiboot command line (prompt=, n=, ctx=,
threads=, think...), so the same kernel serves the interactive chat and
scripted runs (brain/features/cmdline.md).
Speed
Qwen3-0.6B Q8_0 decode on a Ryzen 7 7800X3D, token0 in a KVM guest against llama.cpp on the host, same thread counts:
| Threads | token0 | llama.cpp |
|---|---|---|
| 1 | 70.9 tok/s | 50.4 tok/s |
| 2 | 97.1 tok/s | 77.5 tok/s |
| 4 | 100.7 tok/s | 95.2 tok/s |
Once the memory bus is saturated both are level; llama.cpp's batched prompt processing is much faster than token0's token-by-token prefill. Details in brain/architecture/performance.md.
How it works
- A Multiboot 1 loader (QEMU's
-kernel, GRUB) loads the flat kernel at 1 MiB and the model file as module 0. - The kernel switches to long mode with identity-mapped 2 MiB pages, turns on SSE/AVX, and wakes every core with INIT-SIPI-SIPI.
- Weights stay where the loader put them: Q8_0 matrices (int8 rows, f16 block scales) streamed through an AVX2 int8 dot product, every matmul split by rows across the cores.
- The tokenizer (byte-level BPE with a prebuilt merge hash table) and the Qwen3 chat template run in the kernel too.
More in brain/BRAIN.md.
Development
Toolchain through mise: NASM, Python and uv. QEMU
comes from the system (qemu-system-x86_64).
mise install
mise run build # build/token0.bin
mise run test # host-tool tests and QEMU boot tests
mise run check # the gate
mise run coverage # line coverage of the host tools
Licence
MIT OR WTFPL, at your option (LICENSE).