Clarify 640 MiB state, 415x KL, x86 build flags, hf_ref_2000 verifier
Browse files21 unmodified lines2223242526272829307 unmodified lines38394041424344454647485 unmodified lines545556575859606121 unmodified lines## SummaryWe 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.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 1.34 GB state that stays the same size from the first token to the last.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.7 unmodified lines| File | Size | Contents || :--- | :--- | :--- || `qwen_linux_weights.bin` | 1.06 MB | The compiled CPU weights (102,431 nonzero values) || `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 and runs the HuggingFace check.## Quickstart5 unmodified linesqwen_linux_weights.bin ram_10mb.bin ram_inception_10mb.bin \--local-dir ./weightsclang++ -O3 -std=c++17 -mcpu=native -ffast-math -fno-finite-math-only qwen_linux_cpu.cpp -o qwen_linux_cpu# 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.snap21 unmodified lines2223242526272829307 unmodified lines38394041424344454647485 unmodified lines54555657585960616263646521 unmodified lines## SummaryWe 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.7 unmodified lines| 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.## Quickstart5 unmodified linesqwen_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
README.md+8-4