TL;DR: I built quantumopt, an open-source AI-powered quantum circuit compiler using a Graph Attention Network. It achieves 30–48% gate reduction on real VQE and IQP circuits. Here’s how it works, what I got wrong, and what I learned.
Why I Built This
I’m a CS student who got obsessed with quantum computing. The problem I kept running into: quantum circuits need to be compiled down to hardware-specific gate sets before running on real IBM machines — and this compilation step massively affects circuit quality.
Qiskit’s built-in transpiler is good. But it doesn’t predict whether a circuit is worth optimizing before trying. I wondered: what if a GNN could look at a circuit’s structure and predict optimization potential before the transpiler runs?
That became quantumopt.
How It Works
The pipeline has three stages:
1. Circuit → Graph
Every quantum circuit is a directed acyclic graph. Gates become nodes, dependencies become edges. I encode each node as a 21-dimensional feature vector:
- 20 dimensions: one-hot gate type encoding
- 1 dimension: qubit index
2. Graph Attention Network (GNN)
A 3-layer GAT learns patterns from labeled circuits — specifically, it learns to predict how much Qiskit’s transpiler can improve a given circuit. Trained on 10,327 circuits on a Kaggle T4 GPU in about 3 minutes. Achieves 82% accuracy within 10 percentage points on the test set.
3. Qiskit Transpilation + Claude Explanation
The circuit gets passed to Qiskit’s transpiler targeting IBM Brisbane hardware at optimization level 3. Optionally, Claude generates a hardware-specific explanation of the optimization decisions — useful for researchers who want to cite the reasoning in papers.
from quantumopt import compile
result = compile(my_vqe_circuit, hardware="ibm_brisbane")
print(result.gate_reduction) # e.g. "30%"
print(result.explanation) # Claude-generated explanation
The Benchmark Results
After training on synthetic circuits, I followed advice from a quantum algorithms researcher to benchmark on real algorithm circuit types. I generated 500 circuits each for QAOA, VQE, and IQP and benchmarked 100 of each:
| Circuit Type | Circuits Tested | Mean Gate Reduction | Mean Depth Reduction |
|---|---|---|---|
| VQE (EfficientSU2) | 100 | +30.4% | +21.5% |
| IQP | 100 | +48.5% | +41.2% |
| QAOA (MaxCut) | 100 | +5.7% | +2.3% |
VQE is the most practically useful result — consistent 30% gate reduction regardless of qubit count (4 to 16 qubits).
IQP is the strongest result — up to 79% gate reduction in the best case.
QAOA is modest — these circuits are already near-optimal before compilation, so there’s less room for improvement.
The Measurement Bug I Had to Fix
Here’s something embarrassing but important: my first benchmark results showed 98-100% of circuits getting worse. Mean gate reduction of -61% to -78%. Clearly wrong.
The bug: I was comparing abstract gate counts (before transpilation) against native gate counts (after transpilation). Abstract gates like ry and rz decompose into multiple native IBM gates (u, sx, x) — so the gate count naturally grows during compilation regardless of optimization.
The fix was to compare level-0 transpilation (naive, no optimization) against level-3 transpilation (full optimization) — both in native gate space. Apples to apples.
Lesson: always make sure your before/after measurements are in the same space.
What I’m Building Next
- Retrain the GNN on the new QAOA/VQE/IQP datasets — the current model was trained mostly on synthetic random circuits, not real algorithm patterns.
- Multi-objective quantum optimization for mRNA design — I’ve been in conversation with a quantum algorithms researcher at Moderna about applying quantum approaches to the CAI + MFE co-optimization problem for mRNA sequence design. This is a genuinely hard multi-objective problem that goes beyond what QUBO formulations can handle.
- arXiv paper — currently waiting for an endorsement to submit to cs.ET.
Try It
pip install quantumopt
from qiskit import QuantumCircuit
from quantumopt import compile
qc = QuantumCircuit(4)
qc.h(range(4))
qc.cx(0, 1)
qc.cx(1, 2)
qc.cx(2, 3)
result = compile(qc, hardware="ibm_brisbane")
print(result)
GitHub: github.com/nsyamala1/quantumopt
PyPI: pypi.org/project/quantumopt
What I’d Love Feedback On
- Have you benchmarked quantum compilers differently? What metrics matter most to you?
- Are there circuit types I should be testing that I’m missing?
- If you’re working on quantum algorithms and want to try it on your circuits, I’d genuinely love to hear what happens.
Feel free to open an issue on GitHub.
Built by Naveen Syamala CS student, full-stack developer, and apparently now a quantum compiler engineer.
Top comments (0)