A CPU Running Inside an LLM, and Doom Inside the CPU: What is Qwenputer Really Good For?
Over the past few days, the open-source LLM and systems architecture communities witnessed a mind-bending engineering feat:
Someone compiled a complete 32-bit RISC-V CPU (RV32IM + Zba) directly into the weights of an open-weight language model!
To make things even wilder, on the very day of its release, community hacker @mapestree ran the raycaster engine of Doom E1M1 (first level) on this in-weights CPU, exploring the floor plan inside an LLM.
You press W, S, A, D in a browser. The model executes 17,540 RISC-V assembly instructions in forward passes, and stream-prints the next frame of the map in ASCII text.
Most people’s immediate reaction is: “Isn’t this just regular agent tool-calling or a remote Python sandbox?”
Not at all.
There is zero external interpreter, zero container sandbox, and zero subprocess execution. Every register operation, memory address write, and arithmetic branch occurs entirely inside the neural network’s forward passes and recurrent state transitions.
Commenters joked that it is “the world’s slowest CPU simulator” and “like building a computer with redstone inside Minecraft.”
So, how does Qwenputer actually work under the hood? Since calculating an addition takes millions of floating-point multiplications, is it merely a geek parlor trick? And why are AI security researchers fascinated by its potential for deterministic agent guardrails?
Let us break down the architecture and walk through a rock-solid, reproducible local quickstart.
1. Under the Hood: How Do You Put a Computer into Neural Weights?
A classic computer needs four pillars: RAM, Registers, a Program Counter (PC), and an ALU (Arithmetic Logic Unit).
Standard Transformer self-attention fails as RAM because Softmax dilutes values across probability distributions. But Qwenputer takes advantage of an architectural gem in Qwen: Gated DeltaNet recurrent layers.
RAM from Recurrent State
In Qwen, certain layers utilize linear recurrent attention (DeltaNet) alongside full attention. Each DeltaNet head maintains a recurrent state matrix updated token-by-token via the gated delta rule:
- Gate $\alpha$ governs memory decay;
- Write strength $\beta$ dictates how strongly new inputs overwrite existing state.
Qwenputer’s design is deceptively elegant:
- It locks the gate wide open ($\alpha = 1.0$), ensuring zero memory fade;
- It locks write strength to absolute overwrite ($\beta = 1.0$);
- For every memory write, the Key vector is a strict one-hot vector selecting a single row.
The result? A specific row in the state matrix is overwritten with an exact byte value while leaving every other row completely intact. That is physically identical to a RAM write. A one-hot query reads that byte back. With lower address bits picking the head and remaining bits picking the row, Qwen’s hidden recurrent state becomes an addressable 32KB virtual RAM.
A Compiled 11-Layer CPU Frontend
Standard neural weights are trained via backpropagation and gradient descent. Qwenputer’s CPU layers have never seen a training step.
The author wrote an automated compiler that inserts 11 custom Transformer layers in front of Qwen’s original 32 layers:
- Every single weight is mathematically derived from the microarchitecture gates of an RV32IM chip as exact bfloat16 numbers;
- MLP blocks serve as exact lookup tables, performing arithmetic, bit shifts, and comparisons with zero floating-point imprecision;
- The entire CPU circuit occupies merely ~0.7M non-zero parameters.
User Prompt
↓
[ Qwenputer: 11 Compiled CPU Layers ] ← Intercepts requests, executes RV32 assembly in DeltaNet RAM
↓ Emits Trace Tokens (Machine execution log)
[ Qwen: 32 Native Backbone Layers ] ← Reads standard output tokens and continues naturally
Decoding as Execution (Clock Cycles)
In Qwenputer, token autoregression is the clock cycle of the CPU.
Each generated hidden Trace Token represents one instruction executed or register modified:
V...: register writeback;NT: branch not taken;J: jump (advances PC);ST: store to memory;HALT: program exit;BYTE: standard output (putchar).
When the CPU finishes execution and invokes putchar, Qwen’s native layers catch the printed characters and resume language generation. In tests replaying 230,000 output positions against a reference emulator, there were zero mismatches (100% mathematical accuracy).
2. If an Addition Takes Millions of Multiplications, What is It Good For?
As Reddit user @SailingToFenway wryly observed: “Doing one addition requires evaluating thousands of forward passes on a 4B parameter model—that compute could estimate the US federal budget ten times over.”
If judged purely as a compute engine, it is certainly energy-inefficient. But in the eyes of systems researchers, Qwenputer unlocks something unprecedented: Deterministic Agent Guardrails.
The Vulnerability of Conventional Agents
Today’s autonomous agents suffer from two systemic vulnerabilities:
- Tool dependency & Sandbox Escapes: Delegating execution to external Bash/Python environments invites latency, environment drift, and sandbox breakout exploits;
- Probabilistic Hallucinations & Jailbreaks: Keeping decisions strictly within the prompt leaves them vulnerable to Prompt Injection. Models cannot violate their own probabilistic sampling.
The Breakthrough: Inviolable Circuit Laws
Imagine compiling a policy engine, a cryptographic verifier, or a SQL schema validator directly into these 11 CPU layers:
- Immune to Prompt Injection: Every token must physically pass through the forward-pass circuitry. No prompt instruction can force the matrix multiplication to skip those 11 layers;
- 100% Deterministic Guarantee: Access control, authorization checks, and arithmetic bounds are mathematical hardware circuits, not fuzzy guesses;
- Zero External Dependencies: Operates seamlessly in air-gapped devices, edge microcontrollers, and offline environments.
3. Step-by-Step Hands-On Quickstart
Here is how you can verify and run Qwenputer on your own hardware.
Hardware Prerequisites
- OS: Linux (Ubuntu 22.04+ recommended) or macOS (Apple Silicon M-series)
- GPU: NVIDIA GPU with 16GB+ VRAM (RTX 3090/4080/A10/L4 recommended; runs on CPU, albeit slower)
- Package Manager:
uv(fast, isolated Python packaging)
Step 1: Clone and Setup Environment
# Clone the repository
git clone https://github.com/divagr18/qwenputer.git
cd qwenputer/experimental/riscv
# Install uv if not already present
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
# Synchronize dependencies with Hugging Face extras
uv sync --extra hf
Step 2: Download Compiled Qwenputer Weights
pip install -U huggingface_hub
hf download divagr1925/Qwen3.5-4B-Qwenputer --local-dir qwenputer-rv
Step 3: Run Deterministic Multiplication in Forward Passes
The repository bundles a precompiled RISC-V firmware (calc-bridge.elf). Run the chat driver to execute large-number multiplication with zero host Python involvement:
uv run python -m chipformer.rv.chat qwenputer-rv \
--firmware tests/data/rv/calc-bridge.elf \
--ask "Use calc: what is 123456789 * 987654321?"
What Happens Under the Hood:
- The driver writes
calc-bridge.elfmachine instructions directly into the DeltaNet state matrix (RAM boot); - Qwen generates a
<tool_call>tag for calculation; - The 11 CPU layers intercept the call and execute RV32IM assembly in the forward pass;
- The exact product is echoed token-by-token:
121932631112635269.
4. Playing Doom Inside Model Weights
Community developer @mapestree ported the Doom E1M1 floor plan and raycasting engine into an RV32 firmware binary running on Qwenputer:
git clone https://github.com/mapestree/qwenputer-doom.git
cd qwenputer-doom
uv sync
uv run python play.py --model-dir ../experimental/riscv/qwenputer-rv
Opening the browser interface, pressing W / A / D dispatches key presses as inputs. The in-weights CPU executes ~17,540 instructions and prints out the 3D raycasted frame as ASCII art!
5. Summary: A Glimpse into the Future of Computation
Qwenputer is more than a technical tour-de-force:
- It reveals that modern recurrent language models (Linear Attention / DeltaNet) are not just statistical predictors—they are mathematically universal computing fabrics;
- It suggests a future where probabilistic reasoning and deterministic verification harmoniously coexist inside the very same neural weights.