Getting Started¶
This guide covers installation and basic usage of the Enhanced Quantum Backend Selector.
Installation¶
Requirements¶
- Python 3.10 or higher
- Qiskit 2.2.3 or higher
Install from PyPI¶
Install with Poetry¶
Install from GitHub¶
pip install git+https://github.com/sevetseh28/enhanced_quantum_backend_selector.git#subdirectory=enhanced-quantum-backend-selector
Install from Source (Development)¶
git clone https://github.com/sevetseh28/enhanced_quantum_backend_selector.git
cd enhanced-quantum-backend-selector/enhanced-quantum-backend-selector
poetry install
Basic Usage¶
1. Get Available Backends¶
from qiskit_ibm_runtime import QiskitRuntimeService
service = QiskitRuntimeService()
backends = service.backends()
Using Fake Backends for Testing
Generic backends (Qiskit):
from qiskit.providers.fake_provider import GenericBackendV2
backends = [
GenericBackendV2(num_qubits=5),
GenericBackendV2(num_qubits=27),
]
Fake IBM backends (qiskit-ibm-runtime):
2. Create a Circuit¶
from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.measure_all()
3. Select the Best Backend¶
from enhanced_quantum_backend_selector import BackendSelector
selector = BackendSelector(backends)
rec = selector.select_backend(qc)
print(f"Best backend: {rec.backend.name}")
print(f"Score: {rec.score_data.score:.3f}")
print(f"Expected error: {-rec.score_data.score:.2%}")
4. Understanding Scores¶
- Score is the negative sum of all errors:
score = -total_error - Higher scores are better (less negative = lower error)
- Example:
-0.01(1% error) is better than-0.05(5% error)
The score is calculated by:
- Transpiling your circuit to the backend (optimization level 2)
- Summing error rates for all gates in the transpiled circuit
- Averaging over multiple transpilation runs (default: 3)
Complete Example¶
from qiskit import QuantumCircuit
from qiskit.providers.fake_provider import GenericBackendV2
from enhanced_quantum_backend_selector import BackendSelector
# Setup backends
backends = [
GenericBackendV2(num_qubits=5, seed=42),
GenericBackendV2(num_qubits=7, seed=43),
GenericBackendV2(num_qubits=27, seed=44),
]
# Create circuit
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.measure_all()
# Select backend
selector = BackendSelector(backends)
rec = selector.select_backend(qc)
print(f"✓ Selected: {rec.backend.name}")
print(f" Score: {rec.score_data.score:.3f}")
print(f" Expected error: {-rec.score_data.score:.2%}")
Troubleshooting¶
ModuleNotFoundError: No module named 'qiskit_ibm_runtime'¶
Authentication Error¶
from qiskit_ibm_runtime import QiskitRuntimeService
QiskitRuntimeService.save_account(
channel="ibm_quantum",
token="YOUR_API_TOKEN",
overwrite=True
)
No Compatible Backends Found¶
# Get all rankings to see what's available
rankings = selector.rank_backends(qc)
for rec in rankings:
print(f"{rec.backend.name}: {rec.score_data.score:.3f}")
Next Steps¶
- User Guide - Advanced features and configuration
- Examples - Real-world usage patterns
- API Reference - Complete API documentation