Skip to content

Back to the catalog

Show HN: A language model that lives in a boot sector
github.comrepo

Show HN: A language model that lives in a boot sector

bootgpt is a char-level language model that runs from a BIOS boot sector. A 512-byte hand-written asm MBR loads an 11.5 KB int8 model from 23 following sectors and runs it in 16-bit real mode on a 386, generating fake Linux dmesg boot logs. train.py quantises to int8 with power-of-two scales, and its integer simulation matches the asm output char for char.

TL;DR Runs a tiny int8 char-level neural net from a 512-byte boot sector in real mode, hallucinating Linux boot logs.
Document

What it claims

bootgpt is a char-level language model whose entire inference engine fits in the 510 usable bytes of a BIOS master boot record. The model has 8 characters of context and one hidden layer. It generates fake Linux dmesg output: timestamps, PCI BARs, ACPI events. The README shows the output quality directly. Lines such as NET: Registered protocol family 16 come out clean, while others degrade into strings like ryndrde c4128 6422 Vveine or truncated BOOT_IMAGE=/vmlinu -5.5.2-1-generic.

How it works

The repository has four scripts and one asm file:

  1. corpus_gen.py generates 3 MB of synthetic dmesg. Each boot session uses one kernel version and one disk. The author says this repetition, as in real boot logs, is what makes a tiny model look coherent.
  2. train.py trains char embeddings, one hidden layer and a softmax. It quantizes all weights to int8 with power-of-two scales, so the forward pass needs only imul and a single idiv. It also simulates the exact integer math, including the LCG sampler, so its output can be diffed against the boot sector.
  3. boot.asm is the whole runtime. It loads weights with int 13h and prints with int 10h. It computes a softclip activation with cdq/idiv and samples by argmax with timer-seeded noise. Any keypress reboots.
  4. record.py records the demo GIF from headless QEMU through the monitor socket, with no window.

The 512-byte sector holds only code. Strings, weights and the vocab table sit in the 23 following sectors, about 11.5 KB. The author says this split was the only way to fit inference plus BIOS plumbing into 510 bytes.

How to use it

The documented setup is macOS with Homebrew:

brew install nasm qemu
python3 -m venv .venv && .venv/bin/pip install numpy
./build.sh
./run.sh

The build produces disk.img, a normal boot image. The README says it can be written to a USB stick with dd and booted on any BIOS machine. It reads only its own sectors. Hardware needs to be 386-class or later in 16-bit real mode, and UEFI-only machines are not covered.

Limits

The model is trained for one narrow task and is not a general text generator. Its output is visibly garbled in places. The page gives no loss, perplexity or other metric. It names no licence, so licensing has to be checked in the repository before reuse. Build instructions cover only Homebrew.

For comparison, the author points to sectorllm. That project boots a real llama2 transformer with 5 layers and attention from about 1.2 KB of real-mode asm, running Karpathy's stories260K model. It is the option for a real transformer at a larger code size. The author also lists sectorlisp-nn, which runs a TensorFlow-trained network on a Lisp interpreter during boot. UEFI apps that boot llama-class models on modern hardware are mentioned too.

Technologies named here

  • Python
  • qemu
  • NumPy
  • Llama2
  • BIOS
  • boot.asm
  • bootgpt
  • corpus_gen.py
  • llama2 stories260K
  • NASM
  • record.py
  • sectorlisp-nn
  • sectorllm
  • stories260K
  • train.py
  • x86 assembly

Techniques named here

  • Quantization
  • Argmax sampling
  • int8 quantization

Concepts named here

  • Character-level language model
  • Corpus repetition

Threat actors named here

  • Andrej Karpathy
  • Oscar Toledo