QuantumCoder-9B

A rank 16 Qwen3.5-9B adapter for translating fully specified synthetic quantum circuits into Qiskit, PennyLane or Cirq Python. The independently executed follow-up passes 288/288 held-out circuit/framework cases and 282/288 larger stress cases. The saved-weight helper reproduces all eight fixed validation generations exactly.

A deterministic renderer already solves this structured task perfectly. This is learned circuit-to-program translation, including framework APIs and little-endian state conventions. It is not quantum algorithm discovery, general quantum programming, full unitary verification or a result on real quantum hardware.

Results

One greedy sample, 768 generated-token cap, thinking disabled. Passing requires requested-framework import, supported-Python execution, unit norm and global-phase-invariant zero-input state fidelity greater than 1βˆ’1eβˆ’6.

Split Circuit groups Framework cases Base passes Adapter passes
Validation 48 144 16 (11.11%) 144 (100%)
Held-out circuits/angles 96 288 36 (12.50%) 288 (100%)
Larger/nonlocal/deeper stress 96 288 47 (16.32%) 282 (97.92%)

Each circuit appears in all three frameworks; these are not 288 independent circuits. Circuit-group bootstrap 95% intervals for adapter-minus-base Pass@1 are [83.33,91.32] percentage points on the held-out split and [77.78,85.42] on stress. Six stress failures remain included. Per-framework results and every scored program are under v2_execution.

The executor is deliberately restricted and may reject other valid Python/API implementations. These percentages measure supported-program compliance plus state correctness, not unrestricted programming ability. The base executed 130/288 held-out programs and 114/288 stress programs; 36 and 47 respectively had correct states. The adapter executed all 288 in each split. Import presence is a compliance proxy, not a formal data-flow proof.

Data and training

The fresh curriculum has 456 circuit groups / 1,368 framework views: 216/648 training, 48/144 validation and 96/288 in each test split. Training contains all three frameworks. All 2,000 original-study circuit groups were excluded. Group IDs, rotation-angle sets and input hashes are disjoint across partitions; an independent audit finds no exact zero-input-state duplicates between training and matching-dimension holdouts at fidelity tolerance 1eβˆ’8. This does not establish full process-equivalence separation.

Training uses 2–4 qubits, adjacent CNOTs and 6–13 gates. Stress uses 5–6 qubits, nonlocal CNOTs and 16–24 gates. Gates are H/X/Z/RY/RZ/CX. All 1,368 reference programs passed the pinned three-framework executor before model scoring. Data are original synthetic circuits with exact statevectors, not experimental measurements.

Base Qwen3.5-9B, revision c202236235762e1c871ad0ccb60c8ee5ba337b9a. One fixed epoch from the base, 648 examples, rank 16/alpha 32 on q_proj/v_proj/in_proj_qkv, AdamW learning rate 2eβˆ’5, gradient accumulation 8, seed 20261101, max training sequence 2,048. No test checkpoint selection. Training code, original programs, model outputs and audits remain in this repository.

Inference

Download this repository and install requirements-inference.txt in a CUDA environment with enough memory for 9B weights (the checked configuration used an A100). From the downloaded repository:

from quantum import QuantumCoder
coder = QuantumCoder()
result = coder.generate([{
    "framework": "cirq", "qubits": 2,
    "operations": [["h", [0], 0.0], ["ry", [1], 0.31],
                   ["rz", [0], 0.67], ["cx", [0, 1], 0.0],
                   ["h", [1], 0.0], ["z", [0], 0.0]]
}])[0]
print(result["program"])

The helper returns fallible source text and never executes it. operations follows [gate,qubit_indices,angle_in_radians]; non-rotation angles are 0. The measured limits are 2–6 qubits and at most 24 gates. Prompts beyond 2,048 tokens are rejected rather than truncated. Generation matches the frozen greedy 768-token protocol in batches of eight.

Reproduce execution

Use an isolated Linux environment with Python 3.11, libseccomp2 and requirements-evaluation.txt. The parent must run as root so workers can drop to UID/GID 65534. From a full repository snapshot, run python reproduce_execution.py. It first verifies the frozen sandbox/data hashes, isolation and every selected reference, then re-scores all 1,440 base/adapted programs and checks the published counts. This public reproducer was run successfully before release. Do not substitute direct host execution for the provided runner.

Workers clear their environment, deny filesystem opens/network/process execution, apply resource/time limits and screen a bounded Python subset. This is an evaluation harness for these programs, not a general arbitrary-code sandbox service. Original full scoring source and circuit-group bootstrap remain underv2_execution; helper parity is underhelper_verification.

Original negative study

The earlier hf_pilot trained on Qiskit/PennyLane and held out Cirq. Its adapter passed 0/128 Cirq cases versus 3/128 for the base under the original strict executor. Some valid Cirq aliases were unsupported there. The failure and original evaluator remain under execution and executor_preflight. The new study uses fresh groups and explicitly trains all frameworks; it is not a zero-shot Cirq success and does not replace that negative result.

Licensing

Adapter/base-derived weights and code: Apache 2.0; base attribution retained in LICENSE/NOTICE. Original synthetic data: CC BY 4.0, attributed to itsalissonsilva. Quantum frameworks have their own upstream licenses and are not redistributed as part of the adapter.

Downloads last month
15
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for itsalissonsilva/QuantumCoder-9B

Finetuned
Qwen/Qwen3.5-9B
Adapter
(1029)
this model