0
# Hardware Providers
1
2
Qiskit's provider system abstracts quantum hardware backends, enabling unified access to different quantum devices and simulators through consistent interfaces for job management, backend configuration, and execution.
3
4
## Capabilities
5
6
### Backend Interface
7
8
```python { .api }
9
class Backend:
10
def __init__(self):
11
"""Abstract base class for quantum backends."""
12
13
def run(self, circuits, **kwargs):
14
"""Execute quantum circuits on backend."""
15
16
@property
17
def target(self):
18
"""Backend target specification."""
19
20
@property
21
def num_qubits(self):
22
"""Number of qubits."""
23
24
class BackendV2(Backend):
25
def __init__(self, provider=None, name=None, description=None,
26
online_date=None, backend_version=None, **fields):
27
"""Version 2 backend interface."""
28
29
@property
30
def instructions(self):
31
"""Supported instructions."""
32
33
@property
34
def operation_names(self):
35
"""Supported operation names."""
36
37
@property
38
def coupling_map(self):
39
"""Backend coupling constraints."""
40
```
41
42
### Job Management
43
44
```python { .api }
45
class Job:
46
def result(self):
47
"""Get job result (blocking)."""
48
49
def status(self):
50
"""Get job status."""
51
52
def cancel(self):
53
"""Cancel job if possible."""
54
```
55
56
### Backend Configuration and Properties
57
58
```python { .api }
59
class BackendConfiguration:
60
n_qubits: int
61
coupling_map: List[List[int]]
62
basis_gates: List[str]
63
gate_set: str
64
local: bool
65
simulator: bool
66
conditional: bool
67
open_pulse: bool
68
memory: bool
69
max_shots: int
70
max_experiments: int
71
72
class BackendProperties:
73
last_update_date: str
74
qubits: List
75
gates: List
76
general: List
77
78
class QubitProperties:
79
def __init__(self, t1=None, t2=None, frequency=None, anharmonicity=None):
80
"""
81
Properties of individual qubits.
82
83
Parameters:
84
- t1: T1 relaxation time
85
- t2: T2 dephasing time
86
- frequency: Qubit frequency
87
- anharmonicity: Anharmonicity
88
"""
89
90
class InstructionProperties:
91
def __init__(self, duration=None, error=None, calibration=None):
92
"""
93
Properties of quantum instructions.
94
95
Parameters:
96
- duration: Instruction duration
97
- error: Gate error rate
98
- calibration: Calibration data
99
"""
100
```
101
102
### Options and Configuration
103
104
Backend runtime options and execution parameters.
105
106
```python { .api }
107
from qiskit.providers import Options
108
109
class Options:
110
def __init__(self, **kwargs):
111
"""
112
Configurable backend execution options.
113
114
Common options:
115
- shots: Number of measurements (default: 1024)
116
- memory: Whether to return memory data
117
- max_credits: Maximum credits to spend
118
- seed_simulator: Random seed for simulators
119
"""
120
121
def update_options(self, **fields):
122
"""Update option values."""
123
124
def get(self, field, default=None):
125
"""Get option value with default."""
126
```
127
128
### Advanced Job Management
129
130
Extended job control and monitoring capabilities.
131
132
```python { .api }
133
from qiskit.providers import JobStatus, JobError, JobTimeoutError
134
135
class JobV1(Job):
136
def __init__(self, backend, job_id, **kwargs):
137
"""Legacy V1 job interface."""
138
139
def submit(self):
140
"""Submit job to backend."""
141
142
def wait_for_final_state(self, timeout=None, wait=5,
143
callback=None):
144
"""Wait until job reaches final state."""
145
146
def error_message(self):
147
"""Get error message if job failed."""
148
149
class JobStatus:
150
"""Job status enumeration."""
151
INITIALIZING = 'job is being initialized'
152
QUEUED = 'job is queued'
153
VALIDATING = 'job is being validated'
154
RUNNING = 'job is actively running'
155
CANCELLED = 'job has been cancelled'
156
DONE = 'job has successfully run'
157
ERROR = 'job incurred error'
158
159
class JobError(Exception):
160
"""Exception raised by job operations."""
161
162
class JobTimeoutError(JobError):
163
"""Exception raised when job times out."""
164
165
# Job result access
166
class Result:
167
def __init__(self, backend_name, backend_version, qobj_id,
168
job_id, success, results, **kwargs):
169
"""
170
Result of quantum job execution.
171
172
Parameters:
173
- backend_name: Name of backend that executed job
174
- backend_version: Version of backend
175
- qobj_id: Quantum object identifier
176
- job_id: Job identifier
177
- success: Whether job completed successfully
178
- results: List of experiment results
179
"""
180
181
def get_counts(self, experiment=None):
182
"""Get measurement counts."""
183
184
def get_memory(self, experiment=None):
185
"""Get individual measurement results."""
186
187
def get_statevector(self, experiment=None):
188
"""Get final statevector (simulators only)."""
189
190
def get_unitary(self, experiment=None):
191
"""Get circuit unitary (simulators only)."""
192
```
193
194
### Usage Examples
195
196
```python
197
from qiskit.providers.fake_provider import FakeManila
198
from qiskit import QuantumCircuit, transpile
199
200
# Use fake backend
201
backend = FakeManila()
202
circuit = QuantumCircuit(2, 2)
203
circuit.h(0)
204
circuit.cx(0, 1)
205
circuit.measure_all()
206
207
# Transpile and execute
208
transpiled = transpile(circuit, backend)
209
job = backend.run(transpiled, shots=1024)
210
result = job.result()
211
counts = result.get_counts()
212
```