---
title: QwenPU
canonical_url: "https://www.modelscope.ai/models/Spartan1925/QwenPU"
md_url: "https://www.modelscope.ai/models/Spartan1925/QwenPU.md"
repository: Spartan1925/QwenPU
last_updated: 2026-10-31
license: apache-2.0
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - qwen3_5_text
architectures:
  - Qwen3_5ForCausalLM
base_model:
  - Qwen/Qwen3.5-4B
base_model_relation: merge
parameters: 13.4B
tensor_type:
  - BF16
  - F32
library_name:
  - safetensors
  - pytorch
frameworks:
  - pytorch
downloads: 6
stars: 0
tags:
  - qwen3.5
  - risc-v
  - rv32im
  - vector-unit
  - npu
  - compiled-weights
  - gated-deltanet
  - qwenputer
---

# QwenPU

> QwenPU - An open-source model by Spartan1925 on ModelScope. 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…

Spartan1925/QwenPU is a 13.4B-parameter text-generation model on ModelScope. licensed under apache-2.0. derived from Qwen/Qwen3.5-4B.

- **Repository**: Spartan1925/QwenPU
- **License**: apache-2.0
- **Tasks**: text-generation
- **Parameters**: 13.4B
- **Base model**: Qwen/Qwen3.5-4B
- **Tags**: qwen3.5, risc-v, rv32im, vector-unit, npu, compiled-weights, gated-deltanet, qwenputer
- **Downloads**: 6
- **Stars**: 0
- **Last updated**: 2026-10-31

Source: https://www.modelscope.ai/models/Spartan1925/QwenPU

---

<p align="center">
  <img src="qwenpu-banner.svg" alt="QwenPU: a vector unit, compiled into the weights of a language model." width="100%">
</p>

[Code on GitHub](https://github.com/divagr18/QwenPU) · [Qwenputer](https://www.modelscope.ai/models/Spartan1925/Qwen3.5-4B-Qwenputer) · [Base model: Qwen/Qwen3.5-4B](https://huggingface.co/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](https://huggingface.co/karpathy/tinyllamas/tree/main/stories260K), the
260K-parameter Llama from [llama2.c](https://github.com/karpathy/llama2.c), runs as a program on
it and writes its stories.**

It's part of [Qwenputer](https://github.com/divagr18/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](https://www.modelscope.ai/models/Spartan1925/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** |

<p align="center"><img src="qwenpu-demo.gif" alt="QwenPU writing a story: stories260K runs on the vector unit inside Qwen3.5." width="100%"></p>

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

```bash
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
modelscope download Spartan1925/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

```bibtex
@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](https://huggingface.co/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).
