A developer has built a small language model that wakes up before any operating system does. The whole inference engine fits inside the 512-byte master boot record of a PC. Instead of answering questions, the model dreams up the kind of log a Linux machine prints as it starts: timestamps, PCI entries, ACPI events for hardware that never existed.
The project, called bootgpt, was posted to Hacker News under the Show HN label. The author also laid out the build in a thread on X.
How does bootgpt run a language model inside a boot sector?
The boot sector is hand-written assembly with no operating system and no C runtime underneath it. When the machine starts, the code loads an 11.5 KB int8 model from the next 23 sectors and runs it in 16-bit real mode on a 386. The model is a tiny character-level network with eight characters of context and one hidden layer. The output is rough. One sample run produced lines such as [ 1.883084] NET: Registered protocol family 16 alongside garbled fragments like usbbore: reg and ACPI: PCI Interrupt Link [LNKA: v/s.xos212.
What do you need to try bootgpt on a PC?
Anyone who wants to try it needs nasm, QEMU and Python 3 with NumPy. The build and run scripts start the model in an emulator. The disk image is also a standard boot image, so it can be written to a USB stick with dd and booted on any BIOS machine. The author says the program only reads its own sectors. Pressing any key reboots the machine.
The project is split into several pieces. A script called corpus_gen.py generates about 3 MB of fake kernel message logs. Each training session uses one kernel version and one disk layout, because real boot logs repeat themselves, and the author says that repetition is what makes a tiny model look sane. A training script, train.py, builds the network from character embeddings, one hidden layer and a softmax output, then quantizes everything to int8 using power-of-two scales. That choice lets the boot sector run the full forward pass with imul instructions and a single idiv.
The Python script also simulates the exact integer math the assembly will perform, including the random number generator used for sampling. The author says the Python output and the boot sector output match character for character, which makes the two easy to compare.
The assembly file, boot.asm, handles the rest of the runtime. It uses BIOS interrupt 13h to load the weights from disk, interrupt 10h to print text, and a softclip activation built from cdq and idiv. Sampling picks the highest-scoring character and adds noise seeded by the system timer, so the output changes from boot to boot. A separate script, record.py, captures the demo GIF from a headless QEMU session through the monitor socket.
Fitting everything into 510 bytes required a compromise. The boot sector holds only code. Strings, weights and the vocabulary table live in the data sectors that follow. The author describes that split as the only way to fit inference and BIOS plumbing into the space available.
How does bootgpt compare with other boot-sector AI projects?
Boot sector programming has a long history among hobbyists. Oscar Toledo has packed chess, a complete operating system and a BASIC interpreter into a single boot sector, and others have fit a C compiler into 512 bytes. The project also has close relatives in machine learning. The sectorllm project boots a real Llama 2 transformer, with five layers and attention, from about 1.2 KB of real-mode assembly, running Karpathy's stories260K model. Another project, sectorlisp-nn, runs a TensorFlow-trained network during boot on a Lisp interpreter. UEFI applications also boot directly into models of the Llama class on modern hardware.
Bootgpt takes a different route. Its entire engine lives in the master boot record itself, and it is not a general storyteller. It is a small character-level network trained for one task: imagining the boot log of the machine it is running on.
Dieser Artikel wurde mit Unterstützung von KI verfasst.
News Factory APP - agentische News für besseres SEO & AEO.
