BootGPT: A Language Model Running from a Boot Sector
Overview
BootGPT is a specialized neural network designed to operate directly from a PC's boot sector. By utilizing 512 bytes of hand-written assembly, the project bypasses the need for an operating system, C runtime, or external dependencies. Upon execution, the system generates a simulated Linux boot log, complete with timestamps, PCI bus information, and ACPI events, providing a functional demonstration of low-level machine learning inference.
Architecture and Implementation
The project achieves inference by splitting the workload between the boot sector and subsequent disk sectors. The Master Boot Record (MBR) contains the core runtime, while the 11.5 KB int8 model and necessary data reside in the following sectors. The runtime operates in 16-bit real mode on 386-compatible hardware.
Key technical components include:
- Inference Engine: The assembly code uses
int 13hfor disk loading andint 10hfor screen output. The neural network's forward pass is optimized using integer math (imulandidiv), with a softclip activation function implemented directly in assembly. - Quantization: The model is trained using Python and quantized to int8 with power-of-two scales. This ensures that the Python training script and the assembly runtime produce identical output, allowing for character-by-character verification.
- Data Handling: To maintain the illusion of a functional system, the model is trained on approximately 3 MB of fake
dmesglogs. By training on repetitive log structures, the tiny model can produce output that mimics the syntax and format of a real Linux kernel boot sequence.
Comparison to Prior Art
BootGPT joins a lineage of boot sector projects that push the limits of the 512-byte MBR constraint. While previous projects have implemented chess engines, BASIC interpreters, and C compilers within this space, BootGPT focuses specifically on extreme model miniaturization.
Unlike projects such as sectorllm, which implement transformer architectures with attention mechanisms, BootGPT prioritizes a minimal footprint by utilizing a simple character-level network with one hidden layer. This design choice allows the entire inference engine to reside within the MBR, while the weights and vocabulary are stored in the subsequent sectors, effectively turning the boot process into a generative task.