deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

bootgpt runs an 11.5 KB language model from a 512-byte boot sector with no OS

A developer has packed a character-level language model into a PC's master boot record: 510 bytes of hand-written assembly run an 11.5 KB int8 network that invents a Linux boot log on bare hardware.

bootgpt runs an 11.5 KB language model from a 512-byte boot sector with no OS

What the project does

bootgpt, a project published on GitHub by the developer kerlenton and surfaced on Hacker News's front page, squeezes a character-level language model into the master boot record of a disk image. According to the project's README, the MBR consists of 510 bytes of hand-written assembly, which pull an 11.5 KB int8-quantized model from the 23 sectors behind it and execute it in 16-bit real mode on a 386-class CPU. No operating system is involved, nor is there a C runtime — the only software beneath the model is the BIOS.

What it generates is an invented Linux boot log: dmesg-style lines with timestamps, PCI address ranges and ACPI interrupt events describing hardware that is not actually present. Given just 8 characters of context and a single hidden layer, the output is roughly what you would expect — recognizable structure and kernel vocabulary interleaved with nonsense strings. The developer has also documented the build in a thread on X.

Squeezing inference into 510 bytes

The boot sector holds code and nothing else; the strings, the vocabulary table and the weights all sit in the data sectors that follow, which the README says was the only way to fit both the inference logic and the BIOS plumbing into the available space.

The runtime leans on BIOS services: interrupt 13h reads the weights from disk and interrupt 10h prints characters. The activation function is a softclip built from the cdq and idiv integer-division instructions, and sampling is argmax with noise seeded from the hardware timer. Pressing any key reboots the machine.

The quantization scheme is what makes real-mode execution feasible. Everything is stored as int8 with power-of-two scales, so the complete forward pass runs on integer multiply instructions plus one division, keeping the entire computation in integer arithmetic.

Training and bit-exact verification

The training pipeline is conventional where it can be. corpus_gen.py synthesizes 3 MB of fake dmesg text, and train.py trains character embeddings, one hidden layer and a softmax head before quantizing the result to int8. One deliberate choice: every generated boot session sticks to a single kernel version and disk identifier, because genuine boot logs are highly repetitive, and that repetition is what lets a model this small look plausible.

The verification method is the more interesting part. The training script emulates the precise integer arithmetic the assembly will perform, including the LCG-based random sampler, so the output of the simulator and the output of the real boot sector can be compared directly. Per the README, the two match exactly.

A genre with a long history

Boot sector demos are an established art form, and the README situates the project within that lineage. Oscar Toledo famously placed chess, a small operating system and a BASIC interpreter inside 512 bytes, and others have managed a C compiler. The nearest relative is sectorllm, which boots an actual llama2 transformer — five layers, attention and all — from about 1.2 KB of real-mode assembly, running Andrej Karpathy's stories260K model. Elsewhere, sectorlisp-nn executes a TensorFlow-trained network during boot on a Lisp interpreter, and UEFI applications exist that load straight into llama-class models on modern hardware.

bootgpt sits at the opposite pole from sectorllm: the entire engine lives inside the MBR itself, with weights and strings in the sectors behind it, and rather than being a general storyteller, the network is trained for exactly one job — inventing the boot log of the machine it starts on.

Running it

Building the image needs little beyond nasm, QEMU and numpy: one script assembles it and another boots it under the emulator, and a separate script records the demo from headless QEMU. The resulting disk.img is a normal bootable image, so it can be written to a USB stick and booted on any BIOS-era machine. The code reads only its own sectors.

Why it matters

The project is a useful calibration point for how small a language model can be. An 11.5 KB network with one hidden layer and 8 characters of context produces text that, at a glance, resembles a boot log — largely because the target domain is narrow and repetitive, which says something about where apparent fluency actually comes from. The integer-only quantization, with power-of-two scales chosen so a forward pass reduces to multiplies and a single division, is the same family of techniques used to shrink models for phones and edge devices, taken to an extreme. And as engineering, it shows that the bare BIOS execution path is still a usable compute environment, connecting modern machine learning to one of the oldest demo traditions on the PC.

  • #machine-learning
  • #assembly
  • #quantization
  • #retrocomputing
  • #open-source

Related posts