qcompile — AI-Driven Hardware-Aware Qubit Placement for Qiskit
qcompile is an AI-driven hardware-aware layout optimizer for Qiskit that combines Graph Attention Networks (GATv2), live IBM Quantum calibration data, and heuristic search to generate high-quality initial qubit mappings.
Instead of replacing Qiskit's transpiler, qcompile improves the initial logical-to-physical qubit placement before routing begins, allowing the standard Qiskit compilation pipeline to produce circuits with fewer routing operations, lower depth, and higher execution fidelity on superconducting quantum processors.
Project Links
Why qcompile?
Modern quantum compilers often spend a significant portion of compilation repairing poor initial layouts by inserting SWAP operations. Every additional two-qubit gate introduces noise, increases execution time, and reduces the probability of successful circuit execution.
qcompile improves this first stage by learning hardware-aware placement strategies from thousands of optimized Qiskit compilations, enabling smarter initial layouts before routing even begins.
Unlike traditional layout heuristics, qcompile combines machine learning with live hardware information to produce layouts tailored to the current state of the target quantum processor.
How qcompile Fits Into Qiskit
Quantum Circuit
│
▼
qcompile
│
Optimized Initial Layout
│
▼
Qiskit Transpiler (O3)
│
▼
Optimized Physical Circuit
qcompile integrates seamlessly with the existing Qiskit transpiler and requires no modifications to the downstream compilation pipeline.
Features
- ✅ Live IBM Quantum calibration-aware optimization
- ✅ Automatic high-fidelity hardware slice selection
- ✅ Graph Attention Network (GATv2) based layout prediction
- ✅ Expert imitation learning from optimized Qiskit layouts
- ✅ Frequency-aware Neural Beam Search
- ✅ Reliability-aware shortest-path heuristic search
- ✅ Local search refinement using simulated annealing
- ✅ Physics-based multi-objective optimization
- ✅ Automatic zero-SWAP fast-path optimization
- ✅ Detailed research-grade telemetry and compiler statistics
- ✅ Fully compatible with the standard Qiskit PassManager
Core Optimization Goals
A poor initial layout forces the transpiler to insert excessive SWAP gates, increasing hardware errors and circuit execution time.
qcompile optimizes the initial mapping according to three primary objectives:
- Reduced Two-Qubit Gates – minimizes physical two-qubit operations and SWAP overhead.
- Lower Circuit Depth – produces shallower circuits that better tolerate decoherence.
- Higher Estimated Success Probability (ESP) – maximizes execution fidelity by selecting reliable qubits and couplers.
- Seamless Integration – works directly with the standard Qiskit compilation workflow.
Compiler Architecture
Quantum Circuit
│
▼
Hardware Analysis & Calibration Extraction
│
▼
High-Fidelity Hardware Slice Selection
│
▼
Expert Layout Harvesting (Qiskit O3)
│
▼
Elite Layout Selection & Ranking
│
▼
Graph Attention Network (GATv2)
│
▼
Frequency-Aware Neural Beam Search
│
▼
Local Search Layout Refinement
│
▼
Optimized Initial Layout
│
▼
Standard Qiskit Transpiler
│
▼
Optimized Physical Circuit
How It Works
1. Hardware Analysis
The compiler connects to a live IBM Quantum backend and extracts:
- Coupling map
- Readout errors
- Two-qubit gate errors
- Current calibration data
It then automatically selects a high-quality hardware region for optimization.
2. Expert Layout Harvesting
Thousands of randomized Qiskit compilations are generated using different transpiler configurations.
The resulting layouts are
- Deduplicated
- Evaluated
- Ranked using a physics-based hierarchy
Priority order:
- Minimum two-qubit gate count
- Maximum Estimated Success Probability (ESP)
- Minimum circuit depth
Only the highest-quality layouts are retained.
3. Graph Attention Network Training
The elite layouts are converted into graph datasets and used to train a Graph Attention Network (GATv2).
Instead of learning from random layouts, the network performs expert imitation learning, learning placement strategies directly from optimized Qiskit solutions.
4. Frequency-Aware Neural Beam Search
During inference, the trained GNN predicts promising physical qubit assignments.
A frequency-aware beam search explores multiple candidate layouts simultaneously while using hardware reliability and shortest-path heuristics to guide the search toward high-quality mappings.
5. Local Search Refinement
The highest-ranked layouts undergo simulated annealing based local search.
Each candidate is refined according to the same optimization hierarchy:
- Fewer two-qubit gates
- Higher Estimated Success Probability (ESP)
- Lower circuit depth
6. Final Qiskit Compilation
The optimized layout is passed directly into the standard Qiskit preset pass manager.
Because qcompile only improves the initial layout, all of Qiskit's existing routing and optimization passes remain unchanged.
Fast-Path Optimization
If Qiskit's optimization level 3 already produces a zero-SWAP solution, qcompile automatically bypasses the AI optimization pipeline and immediately returns the native layout.
This avoids unnecessary computation while preserving optimal compiler performance.
Performance Results
Benchmarks were performed on 30-qubit high-fidelity regions extracted from IBM's ibm_fez quantum processor.
Benchmark Configuration
- Backend:
ibm_fez - Optimization Level: 3
- Hardware Slice Size: 30 qubits
- Seed: 42
- All benchmarks were performed using identical transpiler settings, hardware slice size, and random seed for a fair comparison.
Metrics:
- Physical two-qubit gates
- Circuit depth
- Estimated Success Probability (ESP)
| Circuit Type | Logical Qubits | 2-Qubit Gates | Circuit Depth | Estimated Success Probability (ESP) |
|---|---|---|---|---|
| QFT | 15 | 510 → 276 ⬇️ | 433 → 93 ⬇️ | 0.24 → 0.43 ⬆️ |
| QCNN (Binary Tree) | 16 | 42 → 42 | 21 → 22 | 0.62 → 0.76 ⬆️ |
| QML VQC (Ring) | 16 | 108 → 84 ⬇️ | 69 → 64 ⬇️ | 0.50 → 0.62 ⬆️ |
| ML Kernel | 10 | 189 → 183 ⬇️ | 86 → 106 | 0.51 → 0.53 ⬆️ |
| QAOA Max-Cut | 20 | 135 → 123 ⬇️ | 34 → 32 ⬇️ | 0.44 → 0.46 ⬆️ |
| Random Circuit | 15 | 1191 → 1152 ⬇️ | 298 → 252 ⬇️ | 0.01 → 0.02 ⬆️ |
| Linear Chain | 20 | 46 → 25 ⬇️ | 32 → 25 ⬇️ | 0.63 → 0.63 |
Left value = Standard Qiskit | Right value = qcompile
Installation
Install from PyPI
pip install qcompile
Requirements
- Python 3.10+
Or install the latest development version directly from GitHub:
git clone https://github.com/shaguntembhurne/qcompile.git
cd qcompile
pip install -e .
Quick Start
from qiskit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qcompile import get_ai_layout
# Create your quantum circuit
qc = QuantumCircuit(16)
# Generate an optimized layout
ai_layout, cmap_sliced, active_nodes = get_ai_layout(
qc,
backend_name="ibm_fez",
max_physical_qubits=30,
train_samples=2500,
)
# Compile using the optimized layout
pm = generate_preset_pass_manager(
optimization_level=3,
coupling_map=cmap_sliced,
initial_layout=ai_layout,
seed_transpiler=42,
)
transpiled_qc = pm.run(qc)
Research Highlights
Unlike traditional layout optimization techniques, qcompile combines multiple AI and heuristic optimization methods into a unified compiler framework.
Core techniques include:
- Live hardware-aware optimization
- Dynamic hardware slicing
- Expert imitation learning
- Graph Attention Networks (GATv2)
- Frequency-aware Neural Beam Search
- Reliability-aware shortest-path heuristics
- Simulated annealing local refinement
- Multi-objective optimization based on:
- Two-qubit gate count
- Estimated Success Probability (ESP)
- Circuit depth
Experimental
qcompile is an active research project. APIs and implementation details may evolve as new optimization techniques and hardware backends are incorporated.
Getting Help
If you encounter a bug or have a feature request, please open an issue on GitHub.
GitHub Issues: https://github.com/shaguntembhurne/qcompile/issues
Citation
If you use qcompile in academic research, please consider citing the forthcoming publication and starring the GitHub repository.
A formal BibTeX citation will be added after the associated research paper is published.
License
This project is released under the MIT License.
About
qcompile is an AI-assisted compiler extension for Qiskit that combines graph neural networks, live hardware calibration data, and heuristic optimization to improve initial qubit placement on superconducting quantum processors while remaining fully compatible with Qiskit's existing transpilation pipeline.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qcompile-0.1.25.tar.gz.
File metadata
- Download URL: qcompile-0.1.25.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5dc6bfe972f000861e00732a744f29936e3d4510f3a3b9d9c6286e3cff45c95
|
|
| MD5 |
cb0a8ace1254d43290fe1e0f8d3bd410
|
|
| BLAKE2b-256 |
95f07909265a6fbf251f5eb8b56900213195313bb1c028bbbad9f5ce990080a0
|
File details
Details for the file qcompile-0.1.25-py3-none-any.whl.
File metadata
- Download URL: qcompile-0.1.25-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2b2c4703c692ff2e10823ab30310115990bd112bcf432a3604a83e1db6ce618
|
|
| MD5 |
27a44e47cca6952d5b645ece96d99e8f
|
|
| BLAKE2b-256 |
7a4511ea04c57d55f671bd28a32e0f0ae243796b2ff060595229f220372f1864
|