qiskit/releasenotes/notes/1.0/add-generic-fake-backend-c1...

70 lines
2.8 KiB
YAML

---
features_providers:
- |
Added a new class, :class:`.GenericBackendV2`, to the :mod:`qiskit.providers.fake_provider`
module. This class is configurable, and builds a :class:`~.BackendV2` backend instance that can
be run locally (in the spirit of fake backends). Users can configure the number of qubits, basis gates,
coupling map, ability to run dynamic circuits (control flow instructions), instruction calibrations and
measurement timestep of the backend without having to deal with manual target construction.
Qubit and gate properties (duration, error) are generated by randomly sampling from default ranges.
The seed for this
random generation can be fixed to ensure the reproducibility of the backend output.
It's important to note that 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
:class:`.Target` object to use for transpilation.
Example usage 1::
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import GenericBackendV2
# Create a simple circuit
circuit = QuantumCircuit(3)
circuit.h(0)
circuit.cx(0,1)
circuit.cx(0,2)
circuit.measure_all()
circuit.draw('mpl')
# Define backend with 3 qubits
backend = GenericBackendV2(num_qubits=3)
# Transpile and run
transpiled_circuit = transpile(circuit, backend)
result = backend.run(transpiled_circuit).result()
Example usage 2::
from qiskit import QuantumCircuit, ClassicalRegister, transpile
from qiskit.providers.fake_provider import GenericBackendV2
# Create a circuit with classical control
creg = ClassicalRegister(19)
qc = QuantumCircuit(25)
qc.add_register(creg)
qc.h(0)
for i in range(18):
qc.cx(0, i + 1)
for i in range(18):
qc.measure(i, creg[i])
with qc.if_test((creg, 0)):
qc.ecr(20, 21)
# Define backend with custom basis gates and control flow instructions
backend = GenericBackendV2(
num_qubits=25,
basis_gates=["ecr", "id", "rz", "sx", "x"],
control_flow=True,
)
#Transpile
transpiled_qc = transpile(qc, backend)
.. note::
The noise properties generated by these class do not mimic any concrete quantum device, and should
not be used to measure any concrete behaviors. They are "reasonable defaults" that can be used to
test backend-interfacing functionality not tied specific noise values of real quantum systems.
For a more accurate simulation of existing devices, you can manually build a noise model from the
real backend using the functionality offered in :mod:`qiskit_aer`.