File size: 4,418 Bytes
38fd8ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0690bee
38fd8ec
0690bee
38fd8ec
0690bee
38fd8ec
 
 
4bf6acd
38fd8ec
4bf6acd
38fd8ec
0690bee
38fd8ec
0690bee
38fd8ec
0690bee
 
 
 
 
 
 
38fd8ec
4bf6acd
0690bee
 
38fd8ec
4bf6acd
38fd8ec
0690bee
38fd8ec
 
 
 
 
 
 
 
 
4bf6acd
0690bee
38fd8ec
4bf6acd
 
 
0690bee
38fd8ec
 
0690bee
38fd8ec
 
 
 
 
0690bee
 
 
 
38fd8ec
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
license: apache-2.0
base_model: Qwen/Qwen3.5-0.8B
tags:
  - qwen3.5
  - gated-deltanet
  - risc-v
  - linux
  - neural-computer
  - fermion-research
language:
  - en
---

# QwenLinux-0.8B

QwenLinux boots unmodified mainline Linux 6.1.14 inside the weights of Qwen3.5-0.8B. This repository holds the compiled computer weights and the two RAM images it boots from.

Released by [Fermion Research](https://fermionresearch.com). Read the full write-up on [our blog](https://fermionresearch.com/research/qwenlinux).

![Linux running a story model inside Qwen3.5](assets/qwenlinux_card1_inception.png)

## Summary

We compiled a 32-bit RISC-V computer into a standard HuggingFace `Qwen3_5ForCausalLM` merged with `Qwen/Qwen3.5-0.8B`. It has the RV32IMA instruction set with Zicsr, machine-mode traps, a 64-bit CLINT timer, a console and 10.0 MB of RAM. The model is 46 layers deep: L0 to L21 hold the computer and its RAM, and L22 to L45 are all 24 original Qwen3.5-0.8B layers. The hidden size is 2,304 and `rms_norm_eps` is 1.25e-7. The widened checkpoint has 8.87B parameters (17.75 GB in bfloat16), and more than 90% of them are exactly zero.

Every weight was set by our compiler with no training. The CPU is 13,134 neurons and 102,431 nonzero weights, 1.06 MB in total. Its 10.0 MB of RAM lives in the recurrent states of the Gated DeltaNet layers L1 to L10, a 640 MiB fp32 state that stays the same size from the first token to the last. Every unused write gate sits at a bias of -32 or below, so the stored memory never drifts, however long the run.

The full 46-layer model in bfloat16 got 3,800 of 3,800 test tokens right. The CUDA executor (21,654 tokens per second on an L4) and the C++ executor (27,061 tokens per second on one MacBook CPU core) both match it on 2,000 of 2,000 tokens.

One run of 287,990,241 forward passes booted Linux to a shell and ran `uname -a` and `ls /`. A second run of 427,500,002 forward passes booted Linux and ran a 4-bit, 5-layer Llama-2 model with 260K parameters inside it. Both finished with no errors.

The same checkpoint still chats as `Qwen/Qwen3.5-0.8B`, with a KL divergence between 0.0005 and 0.0021 from the stock model.

![Checked against HuggingFace PyTorch](assets/qwenlinux_card3_verification.png)

## Files

| File | Size | Contents |
| :--- | :--- | :--- |
| `qwen_linux_weights.bin` | 1.06 MB | The compiled CPU weights (102,431 nonzero values, write gates at 64 and -32) |
| `ram_10mb.bin` | 10.0 MB | Linux 6.1.14 kernel image and device tree (`DTB_PA = 0x809ff940`) |
| `ram_inception_10mb.bin` | 10.0 MB | Linux 6.1.14 with an initrd holding the 7.7 KB story-model program (`DTB_PA = 0x809fe000`) |

The compiler in the [GitHub repo](https://github.com/fermionresearch/qwenlinux) rebuilds the full 17.75 GB bfloat16 `Qwen3_5ForCausalLM` checkpoint locally: `python3 rv32ima_compiler.py --mode build_full --ram_bin weights/ram_10mb.bin --dtb_pa 809ff940 --save_dir ./qwenlinux_hf`. The repo also ships `hf_ref_2000.bin`, a 2,000-token reference trace that `qwen_linux_cpu --verify-ref` checks against.

## Quickstart

```bash
git clone https://github.com/fermionresearch/qwenlinux
cd qwenlinux

hf download FermionResearch/QwenLinux-0.8B \
  qwen_linux_weights.bin ram_10mb.bin ram_inception_10mb.bin \
  --local-dir ./weights

# Apple Silicon (on Linux x86_64 use -march=native instead of -mcpu=native)
clang++ -O3 -std=c++17 -mcpu=native -ffast-math -fno-finite-math-only qwen_linux_cpu.cpp -o qwen_linux_cpu

# check 2,000 tokens against the HuggingFace PyTorch reference
./qwen_linux_cpu weights/qwen_linux_weights.bin weights/ram_10mb.bin 809ff940 10000 "" 2000 --verify-ref hf_ref_2000.bin

# boot Linux 6.1.14 on one CPU core
./qwen_linux_cpu weights/qwen_linux_weights.bin weights/ram_10mb.bin 809ff940 50000000 "uname -a\nls /" 0 --save-prompt linux_prompt.snap

# boot Linux and run the story model
./qwen_linux_cpu weights/qwen_linux_weights.bin weights/ram_inception_10mb.bin 809fe000 60000000 "l" 0
```

## Links

- Blog: https://fermionresearch.com/research/qwenlinux
- Code and compiler: https://github.com/fermionresearch/qwenlinux
- Site: https://fermionresearch.com
- Careers: https://fermionresearch.com/careers/

## License

Apache 2.0 for the compiled weights. The RAM images contain third-party software under its own licences, including the Linux kernel and BusyBox (GPL-2.0); see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).