Post

llm.asm: Booting a Language Model Without Linux

A look at an assembly inference experiment that boots Qwen3 directly, and the hardware and model files it still needs.

llm.asm: Booting a Language Model Without Linux

A language model normally runs as a process inside an operating system. llm.asm takes a more unusual route: one part of the project boots a small x86 kernel and runs Qwen3-0.6B without Linux underneath it. The result is an interesting way to study what inference actually needs from a machine, from loading weights to moving data across CPU cores.

The important number is not just the kernel size. The project documents a 25,404-byte kernel, but the converted model is roughly 614 MiB and the example virtual machine has 2 GiB of RAM. This is a systems experiment, not a 25 KB language model.

What boots, and what runs

The bare-metal documentation describes a Multiboot kernel written in x86-64 assembly. A bootloader supplies the kernel and the model as a module. The kernel enters 64-bit mode, sets up memory and CPU features, brings additional cores online, and connects a console over serial or VGA. It then uses shared assembly code for tokenization and transformer inference.

The model is Qwen3-0.6B, a separate text-generation model published under Apache 2.0. llm.asm itself is MIT licensed. Its exporter converts the model and tokenizer into the project’s .asmbin format; the documented compact version uses quantized weights and FP16 scales. The kernel binds that file from memory, so its small executable size does not include the weights or working memory.

The repository also has a Linux inference executable that uses the same core model code. That gives curious readers a less drastic place to start. The bootable version is the more revealing experiment: it replaces the usual OS services with purpose-built boot, memory, CPU and console code. It is not a general-purpose inference server or a drop-in replacement for an established model runner.

Try it in a VM first

The project specifies an x86-64 CPU with AVX2, FMA and F16C. Its QEMU example uses KVM, so the Linux host must also have working KVM access and expose those CPU features. A virtual machine keeps an experimental kernel away from your normal boot disk; allocate resources according to your host and review the upstream instructions before running anything.

On an Ubuntu host, the documented route needs NASM, binutils and QEMU, plus Python and the numpy and huggingface_hub packages for the one-time model export. The Linux inference guide lists the model download and export steps. From a checkout of the repository, after preparing those dependencies:

1
2
3
4
5
6
7
8
9
10
11
12
mkdir -p models
hf download Qwen/Qwen3-0.6B \
  config.json model.safetensors tokenizer.json \
  --local-dir models/qwen3-0.6b-bf16

python3 scripts/export_weights.py \
  --model-dir models/qwen3-0.6b-bf16 \
  --out models/qwen3-0.6b-q8_0.asmbin \
  --scale-dtype fp16

make os FAST_Q8=1
make os-check

These steps download the original model files and create another converted file, so allow space for both. Use a Python virtual environment for the exporter dependencies. The project’s make os-check inspects the built kernel; it does not by itself demonstrate a working chat session.

The documented serial-console launch is:

1
2
3
4
qemu-system-x86_64 -enable-kvm -cpu host -m 2G -smp 16 \
  -kernel build/asm-llm-os.elf \
  -initrd models/qwen3-0.6b-q8_0.asmbin \
  -nographic

Adjust -smp 16 to fit the host. A successful boot reaches an asm-llm> prompt in the terminal. The documented /help command lists console controls; /clear resets the conversation and /quit powers off. If KVM or CPU feature checks fail, verify virtualization support and the features exposed to the guest before trying to debug the model.

The useful constraints

This project is young: GitHub records its creation on November 25, and there are no packaged GitHub releases at the time of writing. The repository is changing quickly, so pin a reviewed commit if you want a repeatable experiment. The maintainer documents performance and parity measurements, but those results depend on the specific hardware, model format and test prompts; they are not a promise of equivalent output or speed on another machine.

The default bare-metal chat context is 2,048 tokens. The documentation says the cache resets as it approaches the limit. The Linux guide also describes a chat-template difference: earlier thinking blocks remain in its append-only cache and consume context. Check the current project documentation before relying on identical behavior across implementations.

For day-to-day local inference, a conventional runner offers a broader model and integration ecosystem. For a homelab operator or systems programmer who wants to trace the route from bootloader to token, this project makes the machinery visible. Start in a VM, keep the original model files separate, and treat the tiny kernel as the beginning of the resource accounting rather than the end.

This post is licensed under CC BY 4.0 by the author.