Skip to main content

Intelligent quantum backend selection for Qiskit circuits

Project description

Enhanced Quantum Backend Selector

Tests Coverage PyPI Python License Code style: ruff

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

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: Sums actual error rates for the specific qubits and gates used
  • Multiple Runs: Averages over multiple transpilation runs for stability (default: 3, configurable)
  • Direct Quality Metric: Score = negative total error (higher is better)

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}")  # Negative error sum
print(f"Expected error: {-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: Automatically evaluates with/without fractional gates for chemistry circuits
  • Provider Agnostic: Works with any Qiskit BackendV2 provider (IBM, Aer, etc.)
  • Multiple Run Averaging: Configurable transpilation runs (default: 3) for stable scoring
  • Smart Caching: 1-hour TTL cache minimizes backend queries
  • 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 = -rec.score_data.score * 100
    print(f"#{rec.rank}. {rec.backend.name}: {rec.score_data.score:.4f} ({error_pct:.2f}% error)")

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 example benchmarks
poetry run python examples/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 = {sevetseh28},
  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.

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

enhanced_quantum_backend_selector-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

File details

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

File metadata

File hashes

Hashes for enhanced_quantum_backend_selector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef9f8500dc0ac992109d05c90fa13e8d3ae2e000ef38e69d5b7f462565cf135f
MD5 72b9b885071538190757564fe862ebd7
BLAKE2b-256 0fb334603b107bc95a8fc0a76350a68b5ea2aec50bdeb7806afd7d5499d417b4

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on sevetseh28/enhanced_quantum_backend_selector

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

File details

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

File metadata

File hashes

Hashes for enhanced_quantum_backend_selector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae99b1e5f143c942f3f36c758592b23342afd3a047e435623c0faf554f3a10c4
MD5 def730103b7d3c0d6aef3b68b18ac463
BLAKE2b-256 e548ea89d328ec4673d4a17dc0b067cc9cbd5a80473b37ecf8f4be7011f56b93

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on sevetseh28/enhanced_quantum_backend_selector

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