Bare-metal x86-64 assembly OS that boots straight into Qwen3-0.6B
  • Assembly 58.1%
  • Python 39.7%
  • Shell 2.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-12-01 11:20:52 +01:00
.claude/skills [feature/release-isos] docs: release ISOs and booting them from a Ventoy stick 2026-11-30 06:06:39 +01:00
.github/workflows [feature/m6-iso] test(iso): the ISO boots under SeaBIOS and OVMF and matches the reference 2026-11-29 08:44:14 +01:00
brain [fix/uefi-smp] docs: the start-up wait under UEFI, and the flaky keyboard test 2026-12-01 11:17:01 +01:00
kernel [fix/uefi-smp] fix(smp): wait for the first AP before trusting a quiet CPUID-counted start-up 2026-12-01 11:17:01 +01:00
scripts [feature/uefi-framebuffer] feat(iso): keep the firmware's GOP mode under UEFI 2026-11-30 08:12:04 +01:00
src/token0 [feature/f16-kv-cache] feat(kernel): store the KV cache as f16 2026-12-01 07:24:25 +01:00
tests [feature/prefill-while-typing] test: boot_typed stops at a kernel that never prompts 2026-12-01 07:43:17 +01:00
.gitignore [master] chore: workspace skeleton and licence 2026-11-29 07:56:31 +01:00
CHANGELOG.md [master] chore(release): 0.8.1 2026-12-01 11:20:52 +01:00
CLAUDE.md [master] docs: brain, roadmap and project docs from the design 2026-11-29 07:58:53 +01:00
icon.svg [feature/boot-icon] chore: boot-sector icon 2026-11-29 15:58:14 +01:00
LICENSE [master] chore: workspace skeleton and licence 2026-11-29 07:56:31 +01:00
LICENSE-MIT [master] chore: workspace skeleton and licence 2026-11-29 07:56:31 +01:00
LICENSE-WTFPL [master] chore: workspace skeleton and licence 2026-11-29 07:56:31 +01:00
mise.toml [feature/m6-iso] feat(iso): scripts/iso.sh builds a hybrid BIOS + UEFI GRUB ISO with a model 2026-11-29 08:43:47 +01:00
pyproject.toml [master] chore(release): 0.8.1 2026-12-01 11:20:52 +01:00
README.md [master] chore(release): 0.8.1 2026-12-01 11:20:52 +01:00
ROADMAP.md [feature/prefill-while-typing] docs: time to first token on top of batched prefill 2026-12-01 07:56:18 +01:00
TODO.md [fix/uefi-smp] docs: the start-up wait under UEFI, and the flaky keyboard test 2026-12-01 11:17:01 +01:00
uv.lock [master] chore(release): 0.8.1 2026-12-01 11:20:52 +01:00

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).