qiskit-documentation/docs/api/qiskit/1.2/qiskit.providers.fake_provi...

341 lines
18 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: GenericBackendV2 (v1.2)
description: API reference for qiskit.providers.fake_provider.GenericBackendV2 in qiskit v1.2
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.fake_provider.GenericBackendV2
---
# GenericBackendV2
<Class id="qiskit.providers.fake_provider.GenericBackendV2" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/fake_provider/generic_backend_v2.py#L506-L1019" signature="qiskit.providers.fake_provider.GenericBackendV2(num_qubits, basis_gates=None, *, coupling_map=None, control_flow=False, calibrate_instructions=None, dtm=None, seed=None, pulse_channels=True, noise_info=True)" modifiers="class">
Bases: [`BackendV2`](qiskit.providers.BackendV2 "qiskit.providers.backend.BackendV2")
Generic [`BackendV2`](qiskit.providers.BackendV2 "qiskit.providers.BackendV2") implementation with a configurable constructor. This class will return a [`BackendV2`](qiskit.providers.BackendV2 "qiskit.providers.BackendV2") instance that runs on a local simulator (in the spirit of fake backends) and contains all the necessary information to test backend-interfacing components, such as the transpiler. A [`GenericBackendV2`](#qiskit.providers.fake_provider.GenericBackendV2 "qiskit.providers.fake_provider.GenericBackendV2") instance can be constructed from as little as a specified `num_qubits`, but users can additionally configure the basis gates, coupling map, ability to run dynamic circuits (control flow instructions), instruction calibrations and dtm. The remainder of the backend properties are generated by randomly sampling from default ranges extracted from historical IBM backend data. The seed for this random generation can be fixed to ensure the reproducibility of the backend output. This backend only supports gates in the standard library, if you need a more flexible backend, there is always the option to directly instantiate a [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") object to use for transpilation.
**Parameters**
* **num\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) Number of qubits that will be used to construct the backends target. Note that, while there is no limit in the size of the target that can be constructed, this backend runs on local noisy simulators, and these might present limitations in the number of qubits that can be simulated.
* **basis\_gates** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")*] | None*) List of basis gate names to be supported by the target. These must be part of the standard qiskit circuit library. The default set of basis gates is `["id", "rz", "sx", "x", "cx"]` The `"reset"`, `"delay"`, and `"measure"` instructions are always supported by default, even if not specified via `basis_gates`.
* **coupling\_map** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")*\[*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]] |* [*CouplingMap*](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap") *| None*)
Optional coupling map for the backend. Multiple formats are supported:
1. [`CouplingMap`](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap") instance
2. List, must be given as an edge list representing the two qubit interactions supported by the backend, for example: `[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]`
If `coupling_map` is specified, it must match the number of qubits specified in `num_qubits`. If `coupling_map` is not specified, a fully connected coupling map will be generated with `num_qubits` qubits.
* **control\_flow** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) Flag to enable control flow directives on the target (defaults to False).
* **calibrate\_instructions** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)") *|*[*InstructionScheduleMap*](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap") *| None*)
Instruction calibration settings, this argument supports both boolean and [`InstructionScheduleMap`](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap") as input types, and is `None` by default:
1. If `calibrate_instructions==None`, no calibrations will be added to the target.
2. **If `calibrate_instructions==True`, all gates will be calibrated for all**
qubits using the default pulse schedules generated internally.
3. **If `calibrate_instructions==False`, all gates will be “calibrated” for**
all qubits with an empty pulse schedule.
4. **If an [`InstructionScheduleMap`](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap") instance is given, the calibrations**
in this instruction schedule map will be appended to the target instead of the default pulse schedules (this allows for custom calibrations).
* **dtm** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)") *| None*) System time resolution of output signals in nanoseconds. None by default.
* **seed** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) Optional seed for generation of default values.
* **pulse\_channels** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) If true, sets default pulse channel information on the backend.
* **noise\_info** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) If true, associates gates and qubits with default noise information.
## Attributes
### coupling\_map
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.coupling_map">
Return the [`CouplingMap`](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap") object
</Attribute>
### dt
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.dt">
Return the system time resolution of input signals
This is required to be implemented if the backend supports Pulse scheduling.
**Returns**
The input signal timestep in seconds. If the backend doesnt define `dt`, `None` will be returned.
</Attribute>
### dtm
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.dtm">
Return the system time resolution of output signals
</Attribute>
### instruction\_durations
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.instruction_durations">
Return the [`InstructionDurations`](qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations") object.
</Attribute>
### instruction\_schedule\_map
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.instruction_schedule_map">
Return the [`InstructionScheduleMap`](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap") for the instructions defined in this backends target.
</Attribute>
### instructions
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.instructions">
A list of Instruction tuples on the backend of the form `(instruction, (qubits)`
</Attribute>
### max\_circuits
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.max_circuits" />
### meas\_map
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.meas_map" />
### num\_qubits
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.num_qubits">
Return the number of qubits the backend has.
</Attribute>
### operation\_names
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.operation_names">
A list of instruction names that the backend supports.
</Attribute>
### operations
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.operations">
A list of [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") instances that the backend supports.
</Attribute>
### options
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.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.fake_provider.GenericBackendV2.run "qiskit.providers.fake_provider.GenericBackendV2.run") method.
</Attribute>
### provider
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.provider">
Return the backend Provider.
**Returns**
the Provider responsible for the backend.
**Return type**
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
</Attribute>
### target
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.target" />
### version
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.version" attributeValue="2" />
### name
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.name">
Name of the backend.
</Attribute>
### description
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.description">
Optional human-readable description.
</Attribute>
### online\_date
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.online_date">
Date that the backend came online.
</Attribute>
### backend\_version
<Attribute id="qiskit.providers.fake_provider.GenericBackendV2.backend_version">
Version of the backend being provided. This is not the same as [`BackendV2.version`](qiskit.providers.BackendV2#version "qiskit.providers.BackendV2.version"), which is the version of the [`Backend`](qiskit.providers.Backend "qiskit.providers.Backend") abstract interface.
</Attribute>
## Methods
### acquire\_channel
<Function id="qiskit.providers.fake_provider.GenericBackendV2.acquire_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/fake_provider/generic_backend_v2.py#L1007-L1012" signature="acquire_channel(qubit)">
Return the acquisition channel for the given qubit.
This is required to be implemented if the backend supports Pulse scheduling.
**Returns**
The Qubit measurement acquisition line.
**Return type**
[AcquireChannel](qiskit.pulse.channels.AcquireChannel "qiskit.pulse.channels.AcquireChannel")
**Raises**
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") if the backend doesnt support querying the measurement mapping
</Function>
### control\_channel
<Function id="qiskit.providers.fake_provider.GenericBackendV2.control_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/fake_provider/generic_backend_v2.py#L1014-L1019" signature="control_channel(qubits)">
Return the secondary drive channel for the given qubit
This is typically utilized for controlling multiqubit interactions. This channel is derived from other channels.
This is required to be implemented if the backend supports Pulse scheduling.
**Parameters**
**qubits** ([*Iterable*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) Tuple or list of qubits of the form `(control_qubit, target_qubit)`.
**Returns**
The multi qubit control line.
**Return type**
List\[[ControlChannel](qiskit.pulse.channels.ControlChannel "qiskit.pulse.channels.ControlChannel")]
**Raises**
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") if the backend doesnt support querying the measurement mapping
</Function>
### drive\_channel
<Function id="qiskit.providers.fake_provider.GenericBackendV2.drive_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/fake_provider/generic_backend_v2.py#L993-L998" signature="drive_channel(qubit)">
Return the drive channel for the given qubit.
This is required to be implemented if the backend supports Pulse scheduling.
**Returns**
The Qubit drive channel
**Return type**
[DriveChannel](qiskit.pulse.channels.DriveChannel "qiskit.pulse.channels.DriveChannel")
**Raises**
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") if the backend doesnt support querying the measurement mapping
</Function>
### measure\_channel
<Function id="qiskit.providers.fake_provider.GenericBackendV2.measure_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/fake_provider/generic_backend_v2.py#L1000-L1005" signature="measure_channel(qubit)">
Return the measure stimulus channel for the given qubit.
This is required to be implemented if the backend supports Pulse scheduling.
**Returns**
The Qubit measurement stimulus line
**Return type**
[MeasureChannel](qiskit.pulse.channels.MeasureChannel "qiskit.pulse.channels.MeasureChannel")
**Raises**
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") if the backend doesnt support querying the measurement mapping
</Function>
### qubit\_properties
<Function id="qiskit.providers.fake_provider.GenericBackendV2.qubit_properties" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L493-L525" signature="qubit_properties(qubit)">
Return QubitProperties for a given qubit.
If there are no defined or the backend doesnt support querying these details this method does not need to be implemented.
**Parameters**
**qubit** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *|*[*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) The qubit to get the [`QubitProperties`](qiskit.providers.QubitProperties "qiskit.providers.QubitProperties") object for. This can be a single integer for 1 qubit or a list of qubits and a list of [`QubitProperties`](qiskit.providers.QubitProperties "qiskit.providers.QubitProperties") objects will be returned in the same order
**Returns**
The [`QubitProperties`](qiskit.providers.QubitProperties "qiskit.providers.QubitProperties") object for the specified qubit. If a list of qubits is provided a list will be returned. If properties are missing for a qubit this can be `None`.
**Raises**
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") if the backend doesnt support querying the qubit properties
**Return type**
[*QubitProperties*](qiskit.providers.QubitProperties "qiskit.providers.backend.QubitProperties") | [*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")\[[*QubitProperties*](qiskit.providers.QubitProperties "qiskit.providers.backend.QubitProperties")]
</Function>
### run
<Function id="qiskit.providers.fake_provider.GenericBackendV2.run" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/fake_provider/generic_backend_v2.py#L910-L968" signature="run(run_input, **options)">
Run on the backend using a simulator.
This method runs circuit jobs (an individual or a list of [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") ) and pulse jobs (an individual or a list of [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") or [`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock")) using [`BasicSimulator`](qiskit.providers.basic_provider.BasicSimulator "qiskit.providers.basic_provider.BasicSimulator") or Aer simulator and returns a [`Job`](qiskit.providers.Job "qiskit.providers.Job") object.
If qiskit-aer is installed, jobs will be run using the `AerSimulator` with noise model of the backend. Otherwise, jobs will be run using the `BasicSimulator` simulator without noise.
Noisy simulations of pulse jobs are not yet supported in [`GenericBackendV2`](#qiskit.providers.fake_provider.GenericBackendV2 "qiskit.providers.fake_provider.GenericBackendV2").
**Parameters**
* **run\_input** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *or*[*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule") *or*[*ScheduleBlock*](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock") *or*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")) An individual or a list of [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit"), [`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock"), or [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") objects to run on the backend.
* **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 whats set in the options object.
**Returns**
The job object for the run
**Return type**
[Job](qiskit.providers.Job "qiskit.providers.Job")
**Raises**
[**QiskitError**](exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") If a pulse job is supplied and qiskit\_aer is not installed.
</Function>
### set\_options
<Function id="qiskit.providers.fake_provider.GenericBackendV2.set_options" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L594-L611" signature="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.13)") If the field passed in is not part of the options
</Function>
</Class>