Fermion Research has put Linux inside Qwen. The team compiled a complete 32-bit RISC-V computer into the weights of an unmodified Qwen3.5-0.8B model, and ordinary token-by-token generation boots Linux 6.1.14 to a live shell. No gradient descent, custom PyTorch operations or external memory were involved.
The checkpoint still chats like Qwen3.5-0.8B. Its KL divergence from the stock model is between 0.0005 and 0.0021.
What got compiled in
The machine is an RV32IMA processor with the Zicsr extension, machine-mode traps and MRET, a CLINT timer 64 bits wide, an hvc0 console and 10.0 MB of writable RAM. Execution starts at reset vector 0x80000000. Each fetch, register write, syscall, timer interrupt and console byte comes out of the model’s own forward passes.
Two runs
In the first run, Linux booted to a ~ # prompt and accepted typed commands such as uname -a and ls /. It took 287,990,241 forward passes covering 45,000,915 RISC-V instructions, about 6.40 tokens per instruction, with zero errors. On one NVIDIA L4 it ran 13,591 seconds at 21,189 tokens per second.
The second run goes a step further. The team put a 260K-parameter Llama-2 model, quantized to 4 bits with 5 layers and compiled into a 7.7 KB binary, into an initrd. From the shell, that tiny model prints a short story and returns cleanly to the prompt. This run took 427,500,002 forward passes and 51,512,377 instructions, about 8.30 tokens per instruction, again with zero errors, in 19,743 seconds at 21,654 tokens per second.
Why Linux inside Qwen works with Qwen3.5
Softmax attention would force a CPU to hold its memory in a KV cache that keeps growing. At 427.5 million tokens, that would be petabytes. Qwen3.5 uses Gated DeltaNet linear-attention layers, each holding a fixed-size recurrent state that updates in constant time and memory whether it’s token 1 or token 427,500,002. Fermion uses those states as RAM.
Ten of those layers carry 128 value heads, 1,024 key slots and 128 value dimensions. That adds up to an fp32 state of 1.34 GB that stays fixed. A key row holds two 32-bit words, which makes 1.0 MB of Linux memory per layer and 10.0 MB across all ten.
The architecture has 46 layers. Layers 0 to 21 hold the compiled CPU and RAM, and layers 22 to 45 are the 24 stock Qwen3.5-0.8B layers. Hidden size grows to 2,304, with channels 0 to 1,023 carrying the normal chat stream and the rest carrying CPU buses. The vocabulary grows to 313,856 tokens, where 65,536 extra entries each pack a 5-bit bus command with an 11-bit payload. The CPU itself takes 13,134 SwiGLU neurons and 102,431 nonzero MLP weights, about 1.06 MB, generated by the team’s HDL compiler.
Five bfloat16 tricks
Bfloat16 has a 7-bit mantissa, which makes naive 32-bit arithmetic collapse almost at once. Five techniques held every one of 427.5 million back-to-back forward passes exact:
- An adder split into eight 4-bit nibbles, which caps every weight at 30 instead of 2^31.
- A 64-bit timer built from one Gated DeltaNet head with fixed decay, behaving like an RC oscillator that ticks once per 32 instructions.
- Differential RAM, storing a 1 as (12, 4) and a 0 as (4, 12), which gives each row an identical norm so normalization can’t drift.
- Word assembly in the native conv1d layer, which turns three 11-bit tokens into one bus word in a single pass.
- A smaller rms_norm_eps (1.25e-7 instead of 1e-6), paired with adjusted norm scales in the stock layers. That cut chat divergence 364 times, from KL 0.5533 to between 0.0005 and 0.0021.
Speed, and why it’s not a general speedup
The full 46-layer HuggingFace model in bfloat16 runs at 5.1 tokens per second and matched every one of 1,800 tokens in the instruction suite and every one of 2,000 live boot tokens. Two custom executors run the same exported weights much faster. A CUDA version reaches 21,654 tokens per second on one L4. A single-core C++ version reaches 27,061 tokens per second on one MacBook CPU core, so Linux can boot on a laptop with no GPU.
The gap comes from structure, not a faster language model. In the dense 17.75 GB checkpoint, over 99.9% of the weights compiled for the CPU are exactly zero, yet dense PyTorch multiplies all of them. The nonzero weights total 1.06 MB. On a GPU, small sequential steps over that much data spend most of their time on synchronization, at 46 microseconds per token. On Apple silicon the data fits in L2 cache at 37 microseconds per token. Skipping zeros changes nothing, so the token IDs match the dense model.
It is still slow as a computer. One forward pass equals roughly an eighth of a RISC-V clock cycle, which works out to an effective clock of 3 to 4 kHz. Booting takes roughly 170 million tokens, and the inner network adds about 257 million. Without skipping zeros, a five-hour boot would stretch into a 2.6-year dense PyTorch run.
Running Linux inside Qwen yourself
All weights stay frozen, and the registers, CSRs, timer and Linux memory live in the recurrent states. The code, including the compiler, HDL and both executors, is on GitHub under fermionresearch/qwenlinux, and the weights and RAM images are on Hugging Face. You build the C++ executor with clang++, boot Linux on a single core and snapshot the machine at the shell prompt. The snapshot reloads in under a second.
Source: Fermion Research