A CPU Running Inside an LLM, and Doom Inside the CPU: What is Qwenputer Really Good For?

A 32-bit RISC-V CPU compiled directly into Qwen's transformer weights: no external Python, no sandbox runtime, pure forward-pass instruction execution—and someone even played Doom on it! Here is an in-depth dive into Qwenputer's architecture (Gated DeltaNet as RAM, compiled circuit layers, decoding as execution), alongside reproducible local steps and the breakthrough implications for deterministic agent guardrails.

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:

Qwenputer’s design is deceptively elegant:

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:

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:

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:

  1. Tool dependency & Sandbox Escapes: Delegating execution to external Bash/Python environments invites latency, environment drift, and sandbox breakout exploits;
  2. 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:


3. Step-by-Step Hands-On Quickstart

Here is how you can verify and run Qwenputer on your own hardware.

Hardware Prerequisites

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:

  1. The driver writes calc-bridge.elf machine instructions directly into the DeltaNet state matrix (RAM boot);
  2. Qwen generates a <tool_call> tag for calculation;
  3. The 11 CPU layers intercept the call and execute RV32IM assembly in the forward pass;
  4. 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:

💬 Discussion

GitHub Powered