Qwenputer: How a RISC-V Computer Runs Inside a Language Model
Large language models can describe an algorithm yet still get a long multiplication wrong. One common remedy is to let the model call a calculator or a Python process. Qwenputer, an experiment by Divyansh Agrawal, takes a stranger route: the calculation runs through additional, fixed weights inside a modified Qwen3.5-4B checkpoint. Those weights implement a 32-bit RISC-V computer. The model’s recurrent attention state holds its memory.
This is a real instruction machine in the limited sense that matters here: it has registers, a program counter, addressable memory, an instruction set, and programs compiled for that instruction set. It is also an unusually expensive way to do arithmetic. The value of the experiment is showing that a transformer forward pass can include deterministic computation and persistent state alongside ordinary language generation.
Turning recurrent state into addressable memory
Qwen3.5 uses Gated DeltaNet in many of its layers. Each head maintains a fixed-size matrix that changes as tokens arrive. Usually, its gates and update strengths are learned so the model can keep or forget information useful for prediction. Qwenputer assigns some of those heads a different job.
Set the retention gate to one and the previous matrix survives each step. Set the write strength to one and a selected value replaces the old value. Encode an address as a one-hot key, with exactly one active position, and the update selects one row. A matching one-hot query reads that row. Within the project’s controlled numeric representation, these operations make the state matrix behave like RAM rather than a fuzzy recollection of prior text.
The memory stays a fixed size as a conversation grows. That differs from the attention key-value cache, which grows with the tokens retained. It does not mean unlimited storage: the number of usable cells is set by the allocated heads and state dimensions. The earlier fast-weights work established a connection between delta-rule attention and associative memory; Qwenputer pushes that idea toward exact, indexed operations.
A circuit becomes model weights
The CPU is specified as a circuit of small operations: fetch a value, decode an instruction, perform arithmetic, write a register, and choose the next instruction address. A compiler maps those operations to attention, feed-forward, and DeltaNet components. It computes the added weights directly. There is no training stage that teaches the CPU to imitate an instruction interpreter.
The resulting model places 11 compiled layers before Qwen3.5-4B’s original 32 layers. The added core implements RV32IM: the base 32-bit integer instructions plus multiplication and division. It also supports the Zba address-generation extension and a small big-integer unit. Its code, data, registers, and program counter live in the recurrent state. The original Qwen weights remain unchanged, while the model’s width and vocabulary expand to fit the computer and its execution trace.
Execution advances as the model decodes tokens. An ADDR token identifies a state row, VAL carries data, and STEP commits an instruction step. These are internal trace positions, rather than a visible explanation written by the language model. The implementation notes describe how the circuit owns those positions and how a reference machine checks them.
This design has a direct cost: a CPU instruction requires several generated positions. A conventional processor executes a long run of instructions in a fraction of the time it takes a language model to decode their traces. Qwenputer is a proof of computation inside weights, not a replacement for a hardware CPU.
The model hands work to its internal computer
The interface deliberately looks familiar to Qwen. It emits a calc call in the tool-call format it already knows, but no outside calculator receives it. The compiled layers capture the call text, run calculator firmware on their RISC-V core, and generate a tool-response-shaped result. Qwen then continues from that result as if a normal tool had replied.
There is still a host driver. RvChat loads firmware into the recurrent state after the prompt and prevents private CPU trace tokens from entering Qwen’s language layers. That distinction matters: the arithmetic does not use an external calculator process, yet the published interactive experience depends on a driver to initialize and route the model’s states. Loading the checkpoint and calling a plain text-generation pipeline is not the same as booting the computer.
The calculator firmware can evaluate integer addition, subtraction, multiplication, floor division, remainder, powers, and greatest common divisors; it also supports decimal operations and exact rational division. The project documents limits, including an 80-token input capture window and finite big-number registers. The same core can run C and MicroPython programs, although its calc interface is the demonstrated path for the arithmetic tests.
What the tests establish
The author reports that the core passes the official RISC-V instruction tests, agrees with QEMU on tested programs, and ran 18 million instructions without a reported error in a free-running test. About 230,000 computer-owned output positions were replayed against a reference implementation with zero mismatches. These checks test the compiled machine, rather than merely asking whether the final answer sounds right.
For end-to-end arithmetic, the picture is more nuanced. In the published 40-problem sets, Qwenputer solved 39 of 40 large multiplication problems, compared with 22 for base Qwen and 40 when base Qwen used a host Python tool. It solved 39 of 40 large division problems, versus 29 for base Qwen and 38 with the Python tool. On a longer mixed multiplication/division set, it solved 40 of 40, versus 36 and 39 respectively. Small sets and particular prompts limit how far those percentages generalize, but they demonstrate that the model can use the internal result effectively.
The distinction between correct computation and correct model behavior is important. The CPU can calculate an exact result while Qwen may still choose a wrong expression, skip the internal call, or misstate the answer afterward. The author’s replay checks support the circuit’s correctness at observed owned positions; the task scores measure the whole system.
The modification appears to preserve ordinary text behavior in the author’s checks. The measured divergence between base and modified next-token distributions was about 6.1e-4 KL, close to the 5.1e-4 difference between two inference kernels running the base model. That is evidence from a limited prompt suite, not a guarantee that every response is identical.
A filesystem in the same state
Agrawal also explored storage built from the same controlled recurrent memory. In the experimental filesystem branch, compiled layers implement internal put, append, get, list, and delete operations. File names hash into a 1,024-slot directory; collisions probe another slot. Text lives in chained rows elsewhere in the DeltaNet state, with eight tokens per row. The reported capacity is up to 512 files and roughly 53,000 tokens of content.
Saving the recurrent state at the end of a chat and restoring it in another lets those files survive across conversations. In the author’s tests, the filesystem version recalled changed facts between chats 90% of the time, compared with 30% when old chats were pasted back as context. Another comparison put its memory performance at 83.3% versus 78.9% for host-run Python memory tools. This is a separate experimental model, so those results should not be assumed for the main calculator checkpoint.
The practical boundary
The published checkpoint is about 18.8 GB in bf16, around twice the base model’s size, although much of the extra space is zero padding. The project says it can run on a single 24 GB GPU. A Triton executor reaches roughly 3,200 internal trace tokens per second on an L4; a calculation can still take seconds because every instruction consumes decoded positions and the language model must generate its own text around the call.
These trade-offs explain why an ordinary external tool remains the sensible engineering choice for most applications. Qwenputer demonstrates a different architectural possibility: a pretrained language model can share a checkpoint with directly compiled, deterministic machinery, use its recurrent state as working memory, and exchange results with that machinery through its familiar text interface. The source code, model card, and technical notes make the experiment inspectable and show where its current boundaries are.