A lightweight CPU emulator framework based on QEMU that runs machine code for multiple architectures through a clean, architecture-neutral API.
kerlenton/bootgpt
A tiny char-level language model that runs inside a 512-byte x86 boot sector and dreams up fake Linux boot logs in real mode.
- Stars
- 99
- Forks
- 4
- Open issues
- 0
- Last commit
- 7 days ago
What is it?
bootgpt is a neural network that runs at boot time, before any operating system loads. The 512-byte MBR contains hand-written x86 assembly that reads an 11.5 KB int8-quantized model from the following 23 disk sectors and performs inference in 16-bit real mode on a 386-class CPU, with no OS or C runtime involved.
The model is a small character-level network with char embeddings, one hidden layer and a softmax, trained on about 3 MB of synthetic dmesg-style logs generated by a Python script. Training uses power-of-two quantization scales so the assembly can do the forward pass with integer multiply and divide. A Python script simulates the same integer arithmetic, and its output matches the boot sector's output character for character.
The project is mainly a demoscene and sizecoding experiment. It is meant to be run under QEMU, with a script that records a demo GIF from headless QEMU, and the disk image can also be written to a USB stick for a BIOS machine.
Key features
- 01Boot sector code fits in 512 bytes and loads model weights from the following disk sectors.
- 02Inference runs in 16-bit real mode using integer-only arithmetic.
- 03Python training script quantizes the model to int8 and simulates the assembly's math for comparison.
- 04Generates synthetic kernel-style boot logs as training data.
- 05Runs under QEMU, and the disk image can be written to a USB stick.
Use cases
- Studying how neural network inference can be written in raw x86 assembly.
- Learning sizecoding and boot sector programming techniques.
- Experimenting with int8 quantization and fixed-point inference on very constrained hardware.
Quick start
- 1
Install nasm and qemu with Homebrew
brew install nasm qemu - 2
Create a Python virtual environment and install numpy
python3 -m venv .venv && .venv/bin/pip install numpy - 3
Build the boot image
./build.sh - 4
Run the image in QEMU
./run.sh
Things to know
- The README's install commands are for macOS (Homebrew), so other platforms need their own setup.
- The model is a tiny novelty that generates fake boot logs, not a general-purpose language model.
- Booting real hardware requires a BIOS machine and writing disk.img to a USB stick, which the README only mentions briefly.
Topics
FAQ
- What is bootgpt?
- A tiny char-level language model that runs inside a 512-byte x86 boot sector and dreams up fake Linux boot logs in real mode. bootgpt is a neural network that runs at boot time, before any operating system loads. The 512-byte MBR contains hand-written x86 assembly that reads an 11.5 KB int8-quantized model from the following 23 disk sectors and performs inference in 16-bit real mode on a 386-class CPU, with no OS or C runtime involved.
- Is bootgpt free to use? What license does it have?
- bootgpt is open source under the MIT license. Check the license terms before using it in commercial products.
- Is bootgpt still maintained?
- Actively maintained. The last commit to bootgpt was on Oct 31, 2026.
- What can I use bootgpt for?
- Studying how neural network inference can be written in raw x86 assembly. Learning sizecoding and boot sector programming techniques. Experimenting with int8 quantization and fixed-point inference on very constrained hardware.
- How do I install bootgpt?
- Install nasm and qemu with Homebrew: brew install nasm qemu Create a Python virtual environment and install numpy: python3 -m venv .venv && .venv/bin/pip install numpy Build the boot image: ./build.sh Run the image in QEMU: ./run.sh
- Where can I get bootgpt?
- The source code and installation instructions are on GitHub: https://github.com/kerlenton/bootgpt
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Python library for fine-tuning, evaluating and running open-source LLMs such as LLaMA, GPT-J and GPT-OSS on your own data, locally or in a private cloud.
Open-source machine learning tool that uses active learning to prioritize records when screening large text datasets for systematic reviews.
Keras 3 is a deep learning framework that runs on JAX, TensorFlow, PyTorch, or OpenVINO for inference.
A deep learning library built on PyTorch that offers high-level components for quick training and low-level pieces for custom research.
A cross-platform accelerator for running ML models exported to ONNX format, with training support for PyTorch scripts.