Paper Feed

Issue 44 · Project 04 HF model AI / ML trending #38 ✓ read

divagr1925/Qwen3.5-4B-Qwenputer

text-generation · transformers

TL;DR: Qwenputer is Qwen3.5-4B with a fully functional 32-bit RISC-V CPU compiled into its weights — 11 extra transformer layers whose parameters are computed by a compiler, not learned, using the model's Gated DeltaNet recurrent state as writable RAM. The model executes real C and MicroPython programs inside its own forward pass, passes the official riscv-tests suites, and does exact big-number arithmetic at parity with an external Python interpreter, while leaving Qwen's text behavior essentially untouched. It's the most convincing existence proof yet that a transformer forward pass can host a verifiable, programmable computer.

Why this is interesting

Compiled transformers aren't new — Tracr compiled RASP programs into weights — but those constructions had no mutable memory and nothing like a real ISA. The key insight here is that Qwen3.5's Gated DeltaNet layers (its linear-attention component) maintain a running state matrix that the delta rule can overwrite one row at a time, exactly. That makes each row a memory cell. The CPU keeps its code, data, registers, and program counter in that state, and the compiled attention/MLP layers implement fetch–decode–execute. No weights are trained; everything is constructed. The result is exact in bf16, which is itself a nontrivial engineering claim.

11 compiled layers RV32IM + Zba + bignum coproc Qwen3.5-4B 32 layers, unchanged DeltaNet state = RAM code · data · registers · PC delta rule = exact row writes Hidden size 3968 2560 Qwen dims + computer dims Qwen emits a tool-call block → CPU layers run it 230k trace tokens carry execution; driver hides them from Qwen model writes the result digit by digit — no external executor
The CPU is prepended, not interleaved: Qwen's weights are untouched, and the two share a widened residual stream. The trick enabling RAM is DeltaNet's exact one-row state overwrite.

How execution actually flows

Cleverly, it piggybacks on Qwen3.5's existing tool-call training. The model writes a calc tool-call block exactly as it would for a real tool — but nothing outside the model runs it. The compiled layers read the call from context, boot/execute it against the DeltaNet RAM (firmware is loaded into state by the RvChat driver after the prompt), and the model itself decodes the answer token by token. Execution is carried by 230,324 new "trace tokens" appended to the vocabulary; the driver keeps those out of Qwen's layers during decoding so text behavior stays clean. So it's not a stock generate() loop — you need their driver — but every token still comes from the weights, and the checkpoint loads as a stock Qwen3_5ForCausalLM.

Evidence

Verification is unusually strong for a stunt project: ~230,000 output positions replayed against a reference machine model with zero mismatches, plus the riscv-tests suites. Text-behavior preservation: KL of 6e-4 vs. a 5e-4 noise floor. Arithmetic (greedy, 40 problems/set):

Exact arithmetic accuracy (%)accuracy020406080100synthetic intmul_bigdiv_bigmul_div_longeradd_or_sub_bigbase Qwen3.5-4BQwenputerhost Python tool40 problems per set, greedy decoding; from the model card

Qwenputer matches a real host interpreter within noise — the residual misses are presumably Qwen failing to write the call correctly, not CPU errors.

What to expect

  • Maturity: explicitly experimental (v0.2.0). Apache-2.0 model, MIT code on GitHub.
  • Cost: 18.8 GB in bf16 for a 4B model — mostly zero padding from the widened hidden size (the computer itself is only ~1M nonzero weights). That's a real deployment tax.
  • Speed: ~3,200 trace tokens/s on an L4 via a Triton executor. Running a CPU at transformer-forward-pass granularity is orders of magnitude slower than just calling Python. Nobody should use this for arithmetic in production; the value is the existence proof and the DeltaNet-as-exact-RAM technique.
  • Gaps: the "Gated DeltaNet as RAM" section of the card is empty in what I saw — the mechanism details live in the GitHub repo. The curator notes follow-up variants (a vector unit, a SIMT GPU) exist; check the repo before committing to this checkpoint.
  • No overclaiming detected: the card is careful — base Qwen's weights unchanged, benchmarks include the Python-tool upper bound, verification methodology stated.

Try it

git clone https://github.com/divagr18/qwenputer && cd qwenputer/experimental/riscv
uv sync --extra hf
hf download divagr1925/Qwen3.5-4B-Qwenputer --local-dir qwenputer-rv
uv run python -m chipformer.rv.chat qwenputer-rv \
  --firmware tests/data/rv/calc-bridge.elf \
  --ask "Use calc: what is 123456789 * 987654321?"

Model card: https://huggingface.co/divagr1925/Qwen3.5-4B-Qwenputer