-
Notifications
You must be signed in to change notification settings - Fork 86
/
qiskit.providers.BackendV1.md
215 lines (112 loc) · 8.24 KB
/
qiskit.providers.BackendV1.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
---
title: BackendV1
description: API reference for qiskit.providers.BackendV1
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.BackendV1
---
# BackendV1
<span id="qiskit.providers.BackendV1" />
`qiskit.providers.BackendV1(configuration, provider=None, **fields)`
Bases: [`Backend`](qiskit.providers.Backend "qiskit.providers.backend.Backend"), [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.12)")
Abstract class for Backends
This abstract class is to be used for all Backend objects created by a provider. There are several classes of information contained in a Backend. The first are the attributes of the class itself. These should be used to defined the immutable characteristics of the backend. The `options` attribute of the backend is used to contain the dynamic user configurable options of the backend. It should be used more for runtime options that configure how the backend is used. For example, something like a `shots` field for a backend that runs experiments which would contain an int for how many shots to execute. The `properties` attribute is optionally defined [`BackendProperties`](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties") object and is used to return measured properties, or properties of a backend that may change over time. The simplest example of this would be a version string, which will change as a backend is updated, but also could be something like noise parameters for backends that run experiments.
This first version of the Backend abstract class is written to be mostly backwards compatible with the legacy providers interface. This includes reusing the model objects [`BackendProperties`](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties") and [`BackendConfiguration`](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration"). This was done to ease the transition for users and provider maintainers to the new versioned providers. Expect, future versions of this abstract class to change the data model and interface.
Subclasses of this should override the public method [`run()`](#qiskit.providers.BackendV1.run "qiskit.providers.BackendV1.run") and the internal [`_default_options()`](#qiskit.providers.BackendV1._default_options "qiskit.providers.BackendV1._default_options"):
### \_default\_options
<span id="qiskit.providers.BackendV1._default_options" />
`abstract classmethod _default_options()`
Return the default options
This method will return a [`qiskit.providers.Options`](qiskit.providers.Options "qiskit.providers.Options") subclass object that will be used for the default options. These should be the default parameters to use for the options of the backend.
**Returns**
**A options object with**
default values set
**Return type**
[qiskit.providers.Options](qiskit.providers.Options "qiskit.providers.Options")
Initialize a backend class
**Parameters**
* **configuration** ([*BackendConfiguration*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")) – A backend configuration object for the backend object.
* **provider** ([*qiskit.providers.Provider*](qiskit.providers.Provider "qiskit.providers.Provider")) – Optionally, the provider object that this Backend comes from.
* **fields** – kwargs for the values to use to override the default options.
**Raises**
[**AttributeError**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.12)") – if input field not a valid options
In addition to the public abstract methods, subclasses should also implement the following private methods:
<span id="undefined" />
`abstract classmethod _default_options()`
Return the default options
This method will return a [`qiskit.providers.Options`](qiskit.providers.Options "qiskit.providers.Options") subclass object that will be used for the default options. These should be the default parameters to use for the options of the backend.
**Returns**
**A options object with**
default values set
**Return type**
[qiskit.providers.Options](qiskit.providers.Options "qiskit.providers.Options")
## Attributes
<span id="qiskit.providers.BackendV1.options" />
### options
Return the options for the backend
The options of a backend are the dynamic parameters defining how the backend is used. These are used to control the [`run()`](#qiskit.providers.BackendV1.run "qiskit.providers.BackendV1.run") method.
<span id="qiskit.providers.BackendV1.version" />
### version
`= 1`
## Methods
### configuration
<span id="qiskit.providers.BackendV1.configuration" />
`configuration()`
Return the backend configuration.
**Returns**
the configuration for the backend.
**Return type**
[BackendConfiguration](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")
### name
<span id="qiskit.providers.BackendV1.name" />
`name()`
Return the backend name.
**Returns**
the name of the backend.
**Return type**
[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")
### properties
<span id="qiskit.providers.BackendV1.properties" />
`properties()`
Return the backend properties.
**Returns**
the configuration for the backend. If the backend does not support properties, it returns `None`.
**Return type**
[BackendProperties](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")
### provider
<span id="qiskit.providers.BackendV1.provider" />
`provider()`
Return the backend Provider.
**Returns**
the Provider responsible for the backend.
**Return type**
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
### run
<span id="qiskit.providers.BackendV1.run" />
`abstract run(run_input, **options)`
Run on the backend.
This method returns a [`Job`](qiskit.providers.Job "qiskit.providers.Job") object that runs circuits. Depending on the backend this may be either an async or sync call. It is at the discretion of the provider to decide whether running should block until the execution is finished or not: the Job class can handle either situation.
**Parameters**
* **run\_input** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *or*[*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule") *or*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) – An individual or a list of [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") or [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") objects to run on the backend. For legacy providers migrating to the new versioned providers, provider interface a [`QasmQobj`](qiskit.qobj.QasmQobj "qiskit.qobj.QasmQobj") or [`PulseQobj`](qiskit.qobj.PulseQobj "qiskit.qobj.PulseQobj") objects should probably be supported too (but deprecated) for backwards compatibility. Be sure to update the docstrings of subclasses implementing this method to document that. New provider implementations should not do this though as [`qiskit.qobj`](qobj#module-qiskit.qobj "qiskit.qobj") will be deprecated and removed along with the legacy providers interface.
* **options** – Any kwarg options to pass to the backend for running the config. If a key is also present in the options attribute/object then the expectation is that the value specified will be used instead of what’s set in the options object.
**Returns**
The job object for the run
**Return type**
[Job](qiskit.providers.Job "qiskit.providers.Job")
### set\_options
<span id="qiskit.providers.BackendV1.set_options" />
`set_options(**fields)`
Set the options fields for the backend
This method is used to update the options of a backend. If you need to change any of the options prior to running just pass in the kwarg with the new value for the options.
**Parameters**
**fields** – The fields to update the options
**Raises**
[**AttributeError**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.12)") – If the field passed in is not part of the options
### status
<span id="qiskit.providers.BackendV1.status" />
`status()`
Return the backend status.
**Returns**
the status of the backend.
**Return type**
[BackendStatus](qiskit.providers.models.BackendStatus "qiskit.providers.models.BackendStatus")