Skip to main contentIBM Quantum Documentation

Fake Provider

qiskit.providers.fake_provider


Overview

The fake provider module in Qiskit contains fake (simulated) backend classes useful for testing the transpiler and other backend-facing functionality.

Example Usage

Here is an example of using a simulated backend for transpilation and running.

from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.visualization import plot_histogram
 
# Generate a 5-qubit simulated backend
backend = GenericBackendV2(num_qubits=5)
 
# Create a simple circuit
circuit = QuantumCircuit(3)
circuit.h(0)
circuit.cx(0,1)
circuit.cx(0,2)
circuit.measure_all()
circuit.draw('mpl')
 
# Transpile the ideal circuit to a circuit that can be directly executed by the backend
transpiled_circuit = transpile(circuit, backend)
transpiled_circuit.draw('mpl')
 
# Run the transpiled circuit using the simulated backend
job = backend.run(transpiled_circuit)
counts = job.result().get_counts()
plot_histogram(counts)
../_images/providers_fake_provider-1_00.png ../_images/providers_fake_provider-1_01.png ../_images/providers_fake_provider-1_02.png

V2 Simulated Backends

GenericBackendV2(num_qubits[, basis_gates, ...])Generic BackendV2 implementation with a configurable constructor.

V1 Fake Backends (Legacy interface)

FakeOpenPulse2Q()A fake 2 qubit backend for pulse test.
FakeOpenPulse3Q()Trivial extension of the FakeOpenPulse2Q.
Fake1Q()A fake 1Q backend.
Fake5QV1()A fake backend with the following characteristics:
Fake20QV1()A fake backend with the following characteristics:
Fake7QPulseV1()A fake pulse backend with the following characteristics:
Fake27QPulseV1()A fake pulse backend with the following characteristics:
Fake127QPulseV1()A fake pulse backend with the following characteristics:

Fake Backend Base Classes

The V1 fake backends are based on a set of base classes:

FakeBackend

class qiskit.providers.fake_provider.FakeBackend(configuration, time_alive=10)

GitHub

Bases: BackendV1

This is a dummy backend just for testing purposes.

FakeBackend initializer.

Deprecated since version 1.2

The class qiskit.providers.fake_provider.fake_backend.FakeBackend is deprecated as of qiskit 1.2. It will be removed in the 2.0 release. Fake backends using BackendV1 are deprecated in favor of GenericBackendV2. You can convert BackendV1 to BackendV2 with BackendV2Converter.

Parameters

  • configuration (BackendConfiguration) – backend configuration
  • time_alive (int) – time to wait before returning result

FakeQasmBackend

class qiskit.providers.fake_provider.FakeQasmBackend

GitHub

Bases: FakeBackend

A fake OpenQASM backend.

FakeBackend initializer.

Deprecated since version 1.2

The class qiskit.providers.fake_provider.fake_backend.FakeBackend is deprecated as of qiskit 1.2. It will be removed in the 2.0 release. Fake backends using BackendV1 are deprecated in favor of GenericBackendV2. You can convert BackendV1 to BackendV2 with BackendV2Converter.

Parameters

  • configuration (BackendConfiguration) – backend configuration
  • time_alive (int) – time to wait before returning result

FakePulseBackend

class qiskit.providers.fake_provider.FakePulseBackend

GitHub

Bases: FakeQasmBackend

A fake pulse backend.

FakeBackend initializer.

Deprecated since version 1.2

The class qiskit.providers.fake_provider.fake_backend.FakeBackend is deprecated as of qiskit 1.2. It will be removed in the 2.0 release. Fake backends using BackendV1 are deprecated in favor of GenericBackendV2. You can convert BackendV1 to BackendV2 with BackendV2Converter.

Parameters

  • configuration (BackendConfiguration) – backend configuration
  • time_alive (int) – time to wait before returning result
Was this page helpful?
Report a bug or request content on GitHub.