Skip to main content

Calibration-aware quantum circuit compiler. Compiles circuits that survive today's hardware.

Project description

qb-compiler

PyPI Python 3.10+ CI Coverage License Downloads

Calibration-aware quantum circuit compiler. Compile circuits that are less likely to fail on today's hardware.


Why qb-compiler?

  • Uses TODAY's calibration data — not just topology. Gate errors, T1/T2 coherence, and readout fidelity change every calibration cycle. qb-compiler reads current data and uses it at every compilation stage.
  • Multi-vendor: IBM, Rigetti, IonQ, IQM from one API — compile for any backend with a single interface. Native gate decomposition, calibration parsing, and cost estimation are handled per-vendor.
  • Budget-aware: compile within your cost constraints — estimate execution cost before you run, enforce budget limits, and pick the cheapest backend that meets your fidelity target.

qb-compiler vs Qiskit Default

Feature Qiskit Default qb-compiler
Calibration-aware mapping - Yes
ML-accelerated layout - Yes (optional)
T1 asymmetry handling - Yes
Temporal correlation detection - Yes
Multi-vendor support IBM only IBM, Rigetti, IonQ, IQM
Budget constraints - Yes
Cost estimation - Yes
Pre-execution fidelity estimate - Yes
Noise-aware SWAP routing - Yes
T1/T2-aware scheduling - Yes

Quick Start

pip install qb-compiler
from qb_compiler import QBCompiler, QBCircuit

compiler = QBCompiler.from_backend("ibm_fez")
circuit = QBCircuit(3).h(0).cx(0, 1).cx(1, 2).measure_all()
result = compiler.compile(circuit)
print(f"Depth: {result.compiled_depth}, Est. fidelity: {result.estimated_fidelity:.3f}")

Or with budget enforcement:

result = compiler.compile(circuit, budget_usd=5.0)
cost = compiler.estimate_cost(result.compiled_circuit, shots=4096)
print(f"Estimated cost: ${cost.total_usd:.2f}")

The Problem

Standard transpilers treat quantum hardware as a static graph. They pick qubit mappings and routing paths based on topology alone, ignoring the fact that gate error rates, coherence times, and readout fidelities change with every calibration cycle. On IBM Heron processors, calibration data updates daily -- and qubit quality can vary by 10x across the chip.

The result: 15-40% fidelity left on the table because your compiler does not know which qubits are good today.

The Solution

qb-compiler reads today's calibration data and uses it at every stage of compilation: qubit mapping, SWAP routing, gate scheduling, and fidelity estimation. Every decision is made with current hardware noise in mind.

Calibration Data (T1, T2, gate error, readout error)
        |
        v
  +-----------------+     +------------------+     +---------------------+
  | CalibrationMapper| --> | NoiseAwareRouter | --> | NoiseAwareScheduler |
  | VF2 + noise      |     | Dijkstra lowest- |     | ALAP with T1/T2    |
  | weighted scoring  |     | error-path SWAPs |     | urgency scoring    |
  +-----------------+     +------------------+     +---------------------+
        |                                                   |
        v                                                   v
  +-------------------+                          +---------------------+
  | GateDecomposition |                          | ErrorBudgetEstimator|
  | Native basis      |                          | Pre-exec fidelity   |
  | (ECR, CZ, ...)   |                          | prediction          |
  +-------------------+                          +---------------------+

Key Features

  • ML-Accelerated Layout -- XGBoost model predicts the best physical qubits for your circuit, narrowing VF2 search from 156 qubits to ~20 candidates. Up to 5% better fidelity and 23x faster than standard VF2 on 8-qubit circuits. Install with pip install "qb-compiler[ml]".

  • CalibrationMapper -- VF2 subgraph isomorphism search scored by gate error, coherence (T1/T2), readout fidelity, T1 asymmetry, and temporal correlation. Finds the best physical qubit placement for your circuit on today's device.

  • T1 Asymmetry Awareness -- On IBM Heron, the probability of reading 0 when a qubit is in |1⟩ (P(0|1)) can be up to 24x higher than P(1|0). Standard transpilers use symmetrised readout error and miss this entirely. qb-compiler uses the raw asymmetric readout data to penalise high-asymmetry qubits for circuits that hold qubits in |1⟩.

  • Temporal Correlation Detection -- When multiple calibration snapshots are available, qb-compiler detects qubit pairs whose error rates co-vary over time. Correlated errors break QEC's independent-error assumption. The mapper penalises correlated edges during layout selection.

  • NoiseAwareRouter -- Dijkstra shortest-error-path SWAP insertion. Minimises accumulated gate error instead of SWAP count. Each SWAP decomposes to 3 CX gates, so error-optimal routing matters.

  • NoiseAwareScheduler -- ALAP scheduling with T1/T2 urgency scoring. Qubits with shorter coherence times get their gates scheduled first, reducing idle decoherence.

  • GateDecomposition -- Decomposes to native basis gate sets (IBM ECR, Rigetti CZ, IonQ MS, IQM CZ) using calibration-aware decomposition strategies.

  • ErrorBudgetEstimator -- Predicts circuit fidelity before execution using calibration data. Know if your circuit is viable before spending QPU time.

  • Qiskit Plugin -- Drop-in AnalysisPass that replaces Qiskit's layout stage. Works with generate_preset_pass_manager at any optimization level.


Benchmarks

All tables use the same baseline and fidelity estimator. Reproduce with python scripts/benchmark_readme.py.

Core Compiler (no ML dependencies)

Calibration-aware VF2 mapping vs naive greedy placement, on real IBM Fez calibration data (156 qubits, March 2026):

Circuit Qubits 2Q Gates Greedy VF2 Improvement
Bell 2 1 0.9868 0.9868 +0.0%
GHZ-5 5 4 0.8923 0.9471 +6.1%
GHZ-8 8 7 0.8372 0.8519 +1.8%
QAOA-4 4 6 0.9018 0.9608 +6.5%
QAOA-8 8 14 0.8204 0.8342 +1.7%

Greedy = edge-ranked placement. VF2 = calibration-weighted subgraph isomorphism (max_candidates=500, call_limit=50k).

With ML Acceleration (pip install "qb-compiler[ml,gnn]")

XGBoost narrows VF2 search to ~20 candidates. GNN captures device topology structure that flat features miss. Both shine on larger circuits:

Circuit Qubits Greedy VF2 ML+VF2 GNN+VF2 Best vs Greedy
Bell 2 0.9868 0.9868 0.9868 0.9868 +0.0%
GHZ-5 5 0.8923 0.9471 0.9463 0.9440 +6.1%
GHZ-8 8 0.8372 0.8519 0.8975 0.9062 +8.2%
QAOA-4 4 0.9018 0.9608 0.9552 0.9608 +6.5%
QAOA-8 8 0.8204 0.8342 0.8771 0.8880 +8.2%

ML+VF2: XGBoost, AUC=0.94, 454 KB. GNN+VF2: dual-graph GCN, 8,833 params, 42 KB. Both trained on IBM Fez calibration data.

T1 Asymmetry: What Qiskit Misses

Standard transpilers use symmetrised readout error and cannot see T1 asymmetry. qb-compiler models the raw asymmetric readout, revealing hidden fidelity loss:

Circuit Qubits Symmetric Asymmetric Overestimate
Bell 2 0.9868 0.9851 0.17%
GHZ-5 5 0.9471 0.9437 0.36%
GHZ-8 8 0.8519 0.8481 0.45%
QAOA-4 4 0.9608 0.9569 0.40%
QAOA-8 8 0.8342 0.8304 0.45%

The symmetric model overestimates fidelity because it hides T1-driven |1⟩ decay. On IBM Fez, qubit asymmetry ratios range from 0.2x to 24x. This is the error Qiskit's default transpiler makes.

Footnote: Greedy = edge-ranked qubit placement (no search). All fidelity estimates use per-qubit calibration data from IBM Fez (March 2026, 156 qubits). All tables use the same baseline and estimator. Reproduce: python scripts/benchmark_readme.py


Qiskit Integration

qb-compiler provides two integration paths with Qiskit:

Drop-in transpile function

from qb_compiler.qiskit_plugin import qb_transpile

compiled = qb_transpile(
    circuit,
    backend="ibm_fez",
    calibration_path="calibrations/ibm_fez_2026-03-12.json",
)

As a pass in an existing pipeline

from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qb_compiler.qiskit_plugin import QBCalibrationLayout

pm = generate_preset_pass_manager(optimization_level=3, backend=backend)
pm.layout.append(QBCalibrationLayout(calibration_data))
compiled = pm.run(circuit)

Supported Backends

Vendor Backends Native Basis
IBM Fez, Torino, Marrakesh (Heron) ECR, RZ, SX
Rigetti Ankaa-3 CZ, RZ, RX
IonQ Aria, Forte (via Braket) MS, GPI, GPI2
IQM Garnet, Emerald CZ, PRX

Calibration data can be loaded from local JSON files, fetched from vendor APIs, or streamed from the QubitBoost calibration hub.


Architecture

qb-compiler is structured as a configurable pass pipeline. Each pass reads calibration data and transforms the circuit IR:

Input Circuit (Qiskit QuantumCircuit or QBCircuit)
  |
  v
[1] Validation          Reject invalid circuits early
  |
  v
[2] CalibrationMapper   VF2 + noise-weighted qubit placement
  |
  v
[3] NoiseAwareRouter    Dijkstra SWAP insertion (min error, not min distance)
  |
  v
[4] GateDecomposition   Decompose to native basis gates
  |
  v
[5] NoiseAwareScheduler ALAP scheduling with T1/T2 urgency
  |
  v
[6] ErrorBudgetEstimate Pre-execution fidelity prediction
  |
  v
CompileResult { compiled_circuit, compiled_depth, estimated_fidelity, cost }

Passes are composable. You can run individual passes, reorder them, or write custom passes by extending BasePass.


CLI

# Compile a QASM file
qbc compile circuit.qasm --backend ibm_fez --strategy fidelity_optimal

# Show available backends and specs
qbc info

# Show calibration summary for a backend
qbc calibration show ibm_fez

Installation Options

# Core (IBM backends via Qiskit)
pip install qb-compiler

# With ML-accelerated layout (XGBoost)
pip install "qb-compiler[ml]"

# With GNN layout predictor (PyTorch)
pip install "qb-compiler[gnn]"

# With Rigetti support
pip install "qb-compiler[rigetti]"

# With IonQ support (via Amazon Braket)
pip install "qb-compiler[ionq]"

# With IQM support
pip install "qb-compiler[iqm]"

# Everything
pip install "qb-compiler[all]"

# Development
pip install "qb-compiler[dev]"

Contributing

Contributions are welcome. See CONTRIBUTING.md for guidelines on development setup, testing, and code style.

To run the test suite:

pip install "qb-compiler[dev]"
pytest

License

Apache License 2.0. See LICENSE for the full text.

Copyright 2026 QubitBoost.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qb_compiler-0.1.0.tar.gz (509.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qb_compiler-0.1.0-py3-none-any.whl (508.8 kB view details)

Uploaded Python 3

File details

Details for the file qb_compiler-0.1.0.tar.gz.

File metadata

  • Download URL: qb_compiler-0.1.0.tar.gz
  • Upload date:
  • Size: 509.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qb_compiler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 77f0c905b7905d280deb4aa7de0888ff5b19dfe76a64d1d405ef3380873f274d
MD5 193ce900d7eb9808a83882ada57c713a
BLAKE2b-256 db2a3ec08e65659723af6fba5c6d3c7697f52dcf1d6e0bf7f53ce461916ae356

See more details on using hashes here.

Provenance

The following attestation bundles were made for qb_compiler-0.1.0.tar.gz:

Publisher: release.yml on mwpwalshe/qb-compiler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qb_compiler-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qb_compiler-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 508.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qb_compiler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 081b2880604dc44e747ab2498f7afad6cf938a37540d62b95d2cae433560b6b9
MD5 357203a6d9dc5a7104df9a6895e9701f
BLAKE2b-256 f07c8fada6108e63f6b173b5591d5329e9eec6856c3af0beff497de624a9bafd

See more details on using hashes here.

Provenance

The following attestation bundles were made for qb_compiler-0.1.0-py3-none-any.whl:

Publisher: release.yml on mwpwalshe/qb-compiler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page