QwenPU: a vector unit, compiled into the weights of a language model.

Code on GitHub · Qwenputer · Base model: Qwen/Qwen3.5-4B · Apache-2.0

QwenPU is Qwen3.5-4B with a 32-bit RISC-V CPU and a vector unit compiled into its weights. The vector unit runs a whole neural network inside the model's forward passes: Andrej Karpathy's stories260K, the 260K-parameter Llama from llama2.c, runs as a program on it and writes its stories.

It's part of Qwenputer: the same CPU, compiled into transformer layers in front of Qwen's own, every weight set by a compiler, with Qwen3.5's Gated DeltaNet state as its memory. Qwenputer-npu gave that CPU dot-product instructions. QwenPU gives it a vector unit of its own: separate memories in DeltaNet heads, 64-lane matrix rows a token, and whole vector results streamed through the token stream.

Work in progress. QwenPU is exact, but not yet small: the checkpoint is 26.7 GB, so it needs a 40 GB or larger GPU to load whole. The story demo and the checks run the computer's layers on their own and fit a 24 GB GPU. Trimming the hidden size, and with it the checkpoint, is next.

A language model inside the language model

stories260K is a C program here (guests/stories260k/stories_vx.c). Its int4 weights sit in the vector unit's weight memory, loaded from the program, and every matrix row, residual add, softmax and attention read is a vector op. None of it is compiled into the checkpoint, so any model that fits runs the same way.

Build of stories260K Trace tokens per story token
Plain C, int8 weights 2,430,000
Qwenputer-npu: VDOT + SMAQA 225,000
QwenPU: the vector unit 53,000

QwenPU writing a story: stories260K runs on the vector unit inside Qwen3.5.

Every build writes the same story, token for token:

Once upon a time, there was a little girl named Lily. She loved to play outside in the park. One day, she saw a big, red ball. She wanted to play with it, but it was too high

The vector unit

Op Does
VMAT int8 · int4 matrix rows, 64 lanes a token, times the row scale; or the argmax
VQ quantizes a vector register into int8 activations or a K / V cache row
VEW residual add, SiLU-gated product, RoPE
VMATR attention scores over the K cache; probabilities times the V cache
VEXP exp-table softmax numerators
VRED sum or sum of squares of the activations
VGET, VPUT move values between the CPU and the unit

Its memories are DeltaNet heads: 16 vector registers of 64 words, 384 int8 activations, 4,152 row-chunks of int4 weights, and K / V caches for 32 positions. An op's record starts with config tokens carrying its operands, then streams its results, and each token is one exact step of the compiled layers. SiLU and exp are fixed-point function units, generic like the CPU's adders.

Checks

  • Every vector op runs random test programs on this checkpoint's own chip layers, teacher-forced against a reference model of the unit, along with the first 30,000 steps of the story program: zero mismatches.
  • The circuit's executor writes the whole story free-running on a GPU, checked against the reference at every one of its 3,184,920 steps: exact. It runs at about 3,300 trace tokens a second on an L4, so a story token takes about 16 seconds, against 41 for Qwenputer-npu.

Quickstart

git clone https://github.com/divagr18/QwenPU && cd QwenPU && uv sync --extra hf
uv run python guests/stories260k/storyrun.py guests/stories260k/stories_vx.elf --vx
hf download divagr1925/QwenPU --local-dir qwenpu
uv run python -m chipformer.rv.vxcheck qwenpu guests/stories260k/stories_vx.elf

storyrun writes the story on the computer's executor; vxcheck runs the vector unit on this checkpoint's layers (--chip-only loads only those on the GPU, about 13 GB).

Model details

Base Qwen/Qwen3.5-4B, Qwen's own weights unchanged
Architecture stock Qwen3_5ForCausalLM (text only); config-only changes
Computer 13 compiled layers before Qwen's 32: RV32IM + Zba + bignum unit + the vector unit
Hidden size 5120 (Qwen's 2560 plus the computer's dims)
Vocabulary Qwen's, plus 394,164 trace tokens
Size 26.7 GB in bf16, mostly zero padding
Precision exact in bf16

Citation

@software{agrawal2026qwenputer,
  author  = {Agrawal, Divyansh},
  title   = {{Qwenputer}: a computer compiled into the weights of a language model},
  year    = {2026},
  url     = {https://github.com/divagr18/qwenputer},
  license = {MIT}
}

License

Apache-2.0. This is a modified version of Qwen/Qwen3.5-4B: the config is widened and computer layers are added, but Qwen's own weights are unchanged. stories260K and llama2.c are by Andrej Karpathy (MIT).

Downloads last month
677
Safetensors
Model size
13B params
Tensor type
BF16
·
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for divagr1925/QwenPU

Merge model
this model

Collection including divagr1925/QwenPU