From the power switch to the first question
If you want to run a language model on your own hardware, you have a choice of perfectly sensible programs that will do it. The Qwen team even recommends a few.2
Alexey Fateev, who goes by alesha-pro on GitHub, took the same model and wrote an operating system for it in x86 assembly. Turn on the machine and the thing waiting for you is Qwen. Type /halt when you're done talking and the power goes off.12
What interests me is everything between the first keystroke and that power switch. When a model lives behind an API, sending a sentence takes one function call and the interesting machinery belongs to somebody else.
Here you can read the keyboard driver and the transformer that receives your sentence. You can see how a second CPU finds out it has a job. You can even work out how many bytes of RAM this particular computer reserves for each token position in the conversation.13
The project is called llm.asm. The kernel, the part that takes charge of the machine, comes to 25,404 bytes in the version we're looking at.1
Qwen comes along in a separate 614 MiB file containing its model weights and tokenizer data. The project also reports talking to Qwen through an 80-column VGA display on a diskless virtual machine with two GiB of RAM. Its boot guide describes a 649 MiB model package for that setup. There's a serial console, too.14
Qwen fits on this machine because the builder settled on one thing it had to do well. You can follow that decision from the bootloader right through your second question.
Give the bootloader something worth carrying
Qwen3-0.6B was the smallest of six dense models the Qwen team released under the Apache 2.0 license in April 2025. They published weights that anyone could download and a configuration that spells out the shape of the network. Hardware and software people could take it from there.2
Plastic Labs, for example, took the larger Qwen3-8B and fine-tuned it for social reasoning in its Honcho memory system. Fateev went in a different direction with the little one. Keep the trained model. Change the computer underneath it.25
That distinction makes sense as soon as you look at the project in order. Phase 1 runs Qwen on Linux. The author had already written the assembly to turn text into tokens, do the matrix multiplications and pass results through the transformer. For Phase 2, those source files came along.14
What needed replacing was the work Linux had been doing for them. Before the arithmetic can begin, somebody has to put the weights where the CPU can read them.14
Fateev gave that job to the bootloader. An old specification called Multiboot lets a loader place extra files in memory alongside a kernel. It hands the kernel the start and end addresses of each one.6
The specification calls them "boot modules." It leaves the operating system to decide what the bytes mean. In this case the bytes describe a language model.6
Back on the build machine, a Python exporter takes Qwen's downloaded files and packs them into the format this kernel reads. The package uses quantized weights, which means it stores groups of weights with smaller numbers and a scale for interpreting them.4
Using a 16-bit scale in place of a 32-bit one brings the export down from about 649 MiB to 614 MiB. Python finishes its shift before the guest ever boots.4
At startup the kernel checks the identifying bytes of the module and gives its inference code the address the loader supplied. Qwen can read the weights right there.17
The machine doesn't need to mount a filesystem, open a model file and find another 614 MiB to hold a copy. In the author's diskless setup, a bootable image supplies the program and the model together.17
The kernel reads weights from the model file where the bootloader placed it. The cache holds work from this conversation for the next turn.147
That arrangement settles what you have to ship to another machine. The person booting the image gets the model you packaged, with the numerical format your arithmetic expects and the tokenizer that turns their sentences into its input.14
Change the exported model package and you're changing a piece of the boot image. That strikes me as an unusually honest way to package an appliance.
One keypress, sixteen workers
Suppose you ask Qwen to explain a CPU cache. That's one of the prompts the author used on a Xeon virtual machine. At the keyboard end, the driver has to recognize Shift and Backspace.17
Once you press Enter, the tokenizer breaks the question into the units Qwen works in. The runtime wraps those units in the model's chat format so Qwen can tell where your message ends and its reply should begin.17
Run a finger down the source tree and you go from a PS/2 keyboard to a transformer in a handful of files. I like that Backspace gets equal billing here.
A contributor named KevinGriffin-new added a reboot command and tried it on a Lenovo ThinkCentre M920. The first version got as far as printing Rebooting... and hung. The revised code tried a different reset mechanism first and put a time limit on the waits. This time the Lenovo came back to a working chat prompt. "I kept both commits so the history shows the failure," the contributor wrote in the merged pull request. You can read both attempts.10
There's an interesting scheduling problem in the middle of the reply. Qwen picks the next token using the tokens it already has. It can't generate the last word of its answer first. Within the calculation for one token, though, there are pieces of matrix multiplication and attention that different cores can work on at the same time.18
The kernel has to find those cores, wake them up and put them into a state where they can execute the same vector instructions.1
Then it hands out work and waits for the pieces it needs before advancing. These are jobs a general-purpose operating system and a numerical library would usually split between them. Here the code that wakes a processor and the code that dispatches a piece of a matrix to it belong to the same project.1
Fateev measured what those extra workers bought on an AMD EPYC 7642 host under KVM. Each run used a 34-token prompt and generated 64 tokens. Look at the last two rows together.1
| Virtual CPUs | Time to process the prompt | Answer generation |
|---|---|---|
| 1 | 1,072 ms | 23.5 tokens/s |
| 8 | 216 ms | 119.0 tokens/s |
| 16 | 212 ms | 134.9 tokens/s |
| 32 | 204 ms | 132.4 tokens/s |
Doubling the workers from sixteen to thirty-two took about eight milliseconds off reading the question. It didn't make the answer come out any faster.1
Even "how fast does it chat?" has two answers on a computer built specifically to chat. Between those two configurations, you'd pick a different core count depending on which part of the conversation you wanted to speed up.1
What does it cost to remember your question?
Now ask "Can you give me an example?" The words an example need the earlier exchange to mean anything. The model weights have stayed exactly where the loader put them. Where did the conversation go?
Each of Qwen's attention layers computes keys and values for the tokens it processes. When it sees a new token, it uses those keys to determine how much attention to give earlier positions and draws on the corresponding values.8
Keeping the old keys and values saves the work of deriving them again. That's the KV cache. The runtime can add the tokens in your follow-up to what the model already processed.78
I pulled up the allocation code to see how much space each token gets. Qwen's model configuration gives eight key/value heads in each of 28 layers. Each head has 128 numbers for a key and another 128 for a value. The kernel's shared inference code reserves four bytes per number.39
Multiply those together and you can price a place in this conversation down to the byte.39
One token slot costs 224 KiB of cache in this implementation. At the default 2,048 positions, the keys and values alone occupy 448 MiB.39
That's two sets of 128 numbers, times eight heads, times 28 layers, times four bytes. The code reserves the whole capacity in advance. Add working space for the math and you can account for the roughly 449 MiB arena in the project notes.139
A question as short as "Why?" doesn't make the program allocate another great chunk of RAM. That space was waiting for you when the machine booted.139
The author lets you see this decision play out on the console. A counter displays how much context the chat has used. At the end of a reply the runtime records Qwen's end-of-turn marker. When you type again it picks up at the current position.17
If a continuing conversation plus the new prompt and a 64-token allowance would hit the limit, the kernel announces that it's resetting the cache. You can start fresh yourself with /clear.17
That counter is a good feature. You can put your finger on the assembly instructions that decide when the machine forgets what you were talking about.
Boot it yourself
Start with the llm.asm source and boot guide. The link fixes the revision used here. The documented QEMU/KVM path calls for an x86-64 Linux host with KVM available and a CPU exposing AVX2, FMA and F16C. You'll also need NASM, GNU binutils and QEMU.1
Follow the Phase 1 guide once to download Qwen's configuration, weights and tokenizer and export the compact model file.14
From the repository root at that revision, the author's commands build the kernel, check its image and start the serial console with eight virtual CPUs. Set the CPU count to suit your host.1
make os FAST_Q8=1
make os-check
make os-run MODEL=models/qwen3-0.6b-q8_0.asmbin SMP=8Ask it something. Follow up with "Why?" Watch the context counter move. Those two turns will have taken you from a keyboard through code you can read to a bank of numbers whose size you can now calculate.1
When you've had enough, type /halt. The same computer that had to learn what Backspace does knows when to turn out the lights.1
Sources
- 1alesha-pro, Phase 2 boot guide, architecture and benchmark table.
- 2Qwen Team, Qwen3 release and model sizes.
- 3alesha-pro, the two KV-cache allocations in the shared transformer.
- 4alesha-pro, Phase 1 weight export and Linux inference guide.
- 5Plastic Labs, Introducing Neuromancer XR.
- 6GNU Project, Multiboot specification, boot information and auxiliary modules.
- 7alesha-pro, the bare-metal kernel and its conversation loop.
- 8Hugging Face, how a transformer caches the work of earlier tokens.
- 9Qwen Team, Qwen3-0.6B model configuration.
- 10KevinGriffin-new, the reboot implementation and its first run on a Lenovo ThinkCentre.