QwenQPU

QPU inside a language model

Added standard layers

The new implementation adds four standard Qwen layers for amplitude storage, H/X/T/CNOT execution and event-probability readout. It retains 32 inherited language layers and uses the stock Qwen3_5ForCausalLM forward. Qwen submits the circuit; the added layers return the numerical answer.

Source and build instructions · Weight composition and hashes

The two completed full-model examples give 0.1464464664 for the H–T–H event (reference 0.1464466094), and 0.5 for each six-qubit GHZ endpoint.

Interim benchmark, 2026-11-04 00:26 UTC: 27 of 48 paired tasks completed.

Completed tasks Qwen QwenQPU
Non-Clifford (20) 1/20 20/20
Clifford controls (7) 0/7 7/7
All completed pairs (27) 1/27 27/27

Both requested event probabilities must match independent Qiskit values within 5e-5. Both arms share a 16,384-prediction budget, including QPU predictions. The full run is continuing. Tasks and scoring.

The default repository root now contains the complete r5 added-layer checkpoint: 29 FP32 safetensors shards, 36 layers, 483 tensors, and the matching 333,702-token tokenizer. The weight payload is 36,671,706,112 bytes. The root configuration and weight index select this model; no subfolder argument is needed.

Load the current model

Use Transformers 5.19.0 and sufficient memory for the FP32 checkpoint.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "xi-zhao/QwenQPU"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=False)
model = AutoModelForCausalLM.from_pretrained(
    repo, dtype=torch.float32, trust_remote_code=False
)

The compact-addressed-v7 protocol layout is recorded in protocol-token-layout.json. The earlier composite runtime and its installer below belong to the historical release, not to the default r5 checkpoint. The earlier model remains recoverable at revision 78dfa7bcc58f6a66da3ba78a5b86aa5eb917aadf.

Earlier composite release

QwenQPU integrates a neural-network QPU module with Qwen. Qwen generates a circuit, a fixed-weight state-vector network executes it and samples measurement outcomes, and Qwen answers from the returned counts.

Code and demo · Architecture · Benchmark

Files

Component Files
Language weights Eight model-*-of-00008.safetensors shards, 18,715,279,016 bytes, with their config, tokenizer and index
Quantum weights QwenQPU.bundle.json contains quantum_gates.json: 48 FP32 H/X/T coefficients; CNOT applies controlled X
Configuration The bundle includes qwenqpu_config.json, qwenqpu_module.json and WEIGHT_MANIFEST.json
Runtime The bundle includes the QwenQPU-runtime/ Python source. install_qwenqpu.py expands it beside the language checkpoint

The language weights come unchanged from divagr1925/Qwen3.5-4B-Qwenputer at revision 2d9068508f2b680badb7abcded96fdd107e9ba5d. That checkpoint has 43 layers and hidden size 3968, including its original compiled CPU parameters. QwenQPU uses the fixed quantum network to execute quantum circuits.

H, X and T are fixed real matrices acting on pairs of complex amplitudes. CNOT uses a control mask. The same small gate network acts at different state-vector positions, updating the state one gate at a time. The quantum child of QwenQPU.forward computes state evolution and terminal sampling. The host parses instructions, supplies random numbers, aggregates counts and schedules language generation. The quantum register and language decoder state are separate.

config.json loads the language component through the standard Transformers Qwen3.5 class. The runtime below attaches and loads the additional quantum module. Its coefficients are constructed constants. The bundle stores their exact FP32 values as JSON alongside the runtime source.

Download and run

With the HF CLI, PyTorch and the language dependencies installed:

hf download xi-zhao/QwenQPU --revision 78dfa7bcc58f6a66da3ba78a5b86aa5eb917aadf --local-dir QwenQPU-weights
python QwenQPU-weights/install_qwenqpu.py

python QwenQPU-weights/QwenQPU-runtime/examples/checkpoint_ghz.py \
  --checkpoint-root QwenQPU-weights --qubits 16 --shots 1024 --seed 123

The quantum example loads the released coefficients and returns 534 all-zero and 490 all-one samples. To run the language-to-circuit-to-counts dialogue:

python QwenQPU-weights/QwenQPU-runtime/examples/qwen_local.py \
  --model-path QwenQPU-weights \
  --max-generated-tokens 16384 \
  --output ./QwenQPU-weights/QwenQPU-runtime/review/dialogue.json

The language example loads local files with Qwen3_5ForCausalLM and trust_remote_code=False. It needs memory for the full language checkpoint. The original A100 80 GB runs used PyTorch 2.6.0+cu124 and Transformers 5.19.0. The generation budget is accumulated across circuit generation and the reply.

The installer verifies bundle and file hashes, then expands the parameter and source files. It preserves existing files with different contents. Dependencies are installed separately.

Quantum execution

The runtime supports H, X, T and CNOT on 1–16 qubits, with up to 1,000 sequential gate operations between resets. It stores the state as an FP32 [2**n, 2] real/imaginary tensor. Local gate maps, dynamic addressing, state updates and terminal sample selection execute in the scripted quantum graph.

Terminal measurements use one final state and the requested number of uniform random draws. The language model receives counts. Exact probabilities are available for diagnostics. The implementation uses ideal state-vector simulation.

Benchmark

The supplied-circuit benchmark starts from |0...0> and asks for one or two parity-event probabilities after an H/X/T/CNOT circuit. There are 20 calculation tasks across 1, 3, 8, 12 and 16 qubits. Both groups use the same language weights, greedy decoding and a 16,384-token total generation budget. QwenQPU uses 4,096 samples per circuit; the independent reference is Qiskit.

Task and answer scoring Qwen QwenQPU
Calculation: identical repeated JSON merged 8/20 19/20
Calculation: original answer parser 1/20 19/20
Planning: circuit-and-answer joint success 1/20 1/20

The execution module improves the calculation score. The planning score stays the same. Methods, task list and worked examples include the original parser results and the later identical-JSON diagnostic.

Source and terms

The upstream language weights, configs, tokenizer and Apache-2.0 LICENSE are retained. The bundle includes the upstream model card, a file manifest, UPSTREAM_NOTICE.md and component-specific LICENSES.md. QwenQPU's original code and artwork currently have no project-wide open-source license.

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

Model tree for xi-zhao/QwenQPU

Finetuned
(1)
this model