Skip to main content

Enhanced Quantum Backend Selector

Tests PyPI Python License Code style: ruff

Intelligent quantum backend selection for Qiskit circuits using transpilation-based error analysis.

Usage

pip install enhanced-quantum-backend-selector
from enhanced_quantum_backend_selector import BackendSelector
from qiskit_ibm_runtime import SamplerV2

selector = BackendSelector(backends)        # any list of Qiskit BackendV2
best = selector.select_backend(circuit)     # transpile, score and pick the best

print(best.backend.name)                    # e.g. "ibm_kingston"
sampler = SamplerV2(mode=best.backend)      # run on it as usual

ranking = selector.rank_backends(circuit)   # every backend, best first

See the Quick Start for a complete example with IBM Quantum backends.

Overview

Quantum computing users typically rely on simplistic backend selection methods like least_busy(), which only considers queue depth. This library provides intelligent backend selection by transpiling your circuit to each backend and calculating the actual expected error rates:

  • Transpilation-Based: Circuits are transpiled to each backend's native gate set
  • Real Error Calculation: Combines the actual gate and readout error rates of the specific qubits the transpiler chose, plus decoherence while they sit idle, into an estimated success probability
  • Multiple Runs: Averages over multiple transpilation runs for stability (default: 3, configurable)
  • Direct Quality Metric: Score = estimated success probability, between 0 and 1 (higher is better)
  • Compatibility Checks: Backends with too few qubits, that are offline, or that fail to transpile are flagged and ranked last

How It Works

flowchart TD
    IN["Your circuit + list of BackendV2"] --> BS["BackendSelector<br/>select_backend() / rank_backends()"]
    BS -->|"each backend in parallel"| CHK{"Enough qubits<br/>and operational?"}
    CHK -->|no| INC["CircuitScore<br/>compatible=False, score=0"]
    CHK -->|yes| TR["transpile() x N runs<br/>optimization_level=2, seed + run"]
    TR -->|fails| INC
    TR --> CS["CircuitScorer.score_circuit()<br/>success probability =<br/>product of (1 - gate error) x (1 - readout error)<br/>x (1 - idle error from T1/T2)<br/>on the qubits the transpiler chose"]
    CS --> AVG["Average the N runs into one CircuitScore<br/>score, log_success_probability, reasons"]
    AVG --> RANK["Rank by log_success_probability"]
    INC --> RANK
    RANK --> OUT["BackendRecommendation<br/>backend, score_data, rank"]

    classDef io fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
    classDef selector fill:#ede9fe,stroke:#7c3aed,color:#4c1d95
    classDef scorer fill:#dcfce7,stroke:#16a34a,color:#14532d
    classDef check fill:#fef3c7,stroke:#d97706,color:#78350f
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
    class IN,OUT io
    class BS,TR,AVG,RANK selector
    class CS scorer
    class CHK check
    class INC bad

BackendSelector is the entry point. For each backend it transpiles your circuit and hands the result to CircuitScorer, which looks up the calibrated error of every gate and readout on the qubits that were actually used, plus the decoherence each qubit suffers while it waits for others. Each backend ends up with a CircuitScore, and the ranked list is returned as BackendRecommendation objects.

Installation

pip install enhanced-quantum-backend-selector

Or with Poetry:

poetry add enhanced-quantum-backend-selector

Quick Start

from enhanced_quantum_backend_selector import BackendSelector
from qiskit import QuantumCircuit
from qiskit_ibm_runtime import QiskitRuntimeService

# Get available backends
service = QiskitRuntimeService()
backends = service.backends()

# Create your circuit
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.measure_all()

# Select the best backend
selector = BackendSelector(backends)
best = selector.select_backend(qc)

print(f"Recommended: {best.backend.name}")
print(f"Score: {best.score_data.score:.3f}")  # Success probability, 0 to 1
print(f"Expected error: {1 - best.score_data.score:.2%}")  # As percentage
print(f"Reasons: {', '.join(best.score_data.reasons)}")

Features

  • ✅ Transpilation-Based Scoring: Calculates actual error rates for your specific circuit
  • ✅ Fractional Gates Support: Pass standard and fractional-gate versions of a backend to compare them for chemistry circuits
  • ✅ Reproducible Rankings: Pass seed= to get the same ranking every run
  • ✅ Provider Agnostic: Works with any Qiskit BackendV2 provider (IBM, Aer, etc.)
  • ✅ Multiple Run Averaging: Configurable transpilation runs (default: 3) for stable scoring
  • ✅ Parallel Processing: Scores multiple backends concurrently (up to 10 workers)
  • ✅ Comprehensive Type Hints: Full mypy strict mode compliance
  • ✅ Extensive Documentation: Detailed docstrings with examples

Rank All Backends

# Get full ranking
rankings = selector.rank_backends(qc, top_n=5)

for rec in rankings:
    error_pct = (1 - rec.score_data.score) * 100
    print(f"#{rec.rank}. {rec.backend.name}: {rec.score_data.score:.4f} ({error_pct:.2f}% error)")

Limitations

Scores are estimates from reported calibration data. They assume independent errors, and leave out crosstalk, dynamical decoupling, and queue time. See Limitations for the full list and expected run times.

Development

See CONTRIBUTING.md for development setup and guidelines.

# Clone repository
git clone https://github.com/sevetseh28/enhanced_quantum_backend_selector.git
cd enhanced-quantum-backend-selector/enhanced-quantum-backend-selector

# Install with development dependencies
poetry install --with dev,docs

# Run tests
poetry run pytest

# Run type checking
poetry run mypy src/

# Format code
poetry run ruff format .

Benchmarking

The library includes a comprehensive benchmarking suite with real-world quantum circuits to evaluate backend selector performance using mock backends that simulate real IBM Quantum processors (Heron R1, Heron R2, Heron R3, and Nighthawk):

# Run full benchmark suite
poetry run python benchmarks/run_benchmarks.py

# Run benchmark tests
poetry run pytest tests/test_benchmarks.py -v

Benchmark Circuits:

  • GHZ: Multi-qubit entanglement testing
  • Bernstein-Vazirani: Parallel operations and phase kickback
  • Mirror_5k: Device benchmarking (circuit inversion)
  • LUCJ Ansatz: Quantum chemistry applications
  • QAOA: Combinatorial optimization

Mock Backends (based on real IBM processors):

  • IBM Heron R1: 133 qubits, heavy-hex topology, 1,800 gate capacity
  • IBM Heron R2: 156 qubits, heavy-hex topology, 5,000 gate capacity
  • IBM Heron R3: 156 qubits, heavy-hex topology, improved error rates
  • IBM Nighthawk: 120 qubits, square lattice, superior connectivity

See Benchmarking Guide for detailed methodology, metrics, and references.

Documentation

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Citation

If you use this library in your research, please cite:

@software{enhanced_quantum_backend_selector,
  title = {Enhanced Quantum Backend Selector},
  author = {Esteves, Hernan},
  year = {2025},
  url = {https://github.com/sevetseh28/enhanced_quantum_backend_selector}
}

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

Acknowledgements

Developed as part of the Qiskit Advocate Mentorship Program (QAMP) 2025, mentored by Junye Huang (@HuangJunye).

Metadata

Release files for enhanced-quantum-backend-selector 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enhanced-quantum-backend-selector 1.0.0
File Size Uploaded Provenance Actions
enhanced_quantum_backend_selector-1.0.0.tar.gz 20.9 kB With provenance Details for enhanced_quantum_backend_selector-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for enhanced-quantum-backend-selector 1.0.0
File Interpreter ABI Platform Actions
enhanced_quantum_backend_selector-1.0.0-py3-none-any.whl Python 3 none any Details for enhanced_quantum_backend_selector-1.0.0-py3-none-any.whl

Total release size: 40.4 kB

Release files / enhanced_quantum_backend_selector-1.0.0.tar.gz

Download URL enhanced_quantum_backend_selector-1.0.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7717cde09db731ad18b67606d742d5f4b77d1a753a50a69ec4497a852cec6ddc
BLAKE2b-256 checksum
How to use checksums
f36eea497083fa08c98c4f47a1b400a4dfbb897f30d1ae78518844874aa3b422
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / enhanced_quantum_backend_selector-1.0.0-py3-none-any.whl

Download URL enhanced_quantum_backend_selector-1.0.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f63f446f630128985a3f383c4c97ce9f7146014d7b7dca97bff43348b6b5946
BLAKE2b-256 checksum
How to use checksums
857bab30a1397999f6c36a3ab3db20248777573d86210ff30d91e84bb6ee8e42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for enhanced-quantum-backend-selector 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for enhanced_quantum_backend_selector-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page