Skip to main contentIBM Quantum Documentation Preview

Migrate from cloud simulators to local simulators

In quantum computing, the choice between using simulators and quantum hardware is crucial for making progress in the field. While simulators are useful for testing and debugging, in this era of quantum utility, quantum development and industry advancement requires actual hardware. As part of the move to quantum utility, IBM Quantum™ cloud simulators were retired on 15 May 2024. This guide explains the retirement in more detail, and how to migrate from cloud-based simulators, such as ibmq_qasm_simulator, to local simulators.


Why are the cloud simulators being retired?

The cloud simulators are being retired for several reasons:

Simulators can be useful, but they are too limited to use for research or experimentation:

  • Simulators are valuable for understanding small-scale QPUs (quantum processing units), but their usefulness maxes out at around 50 qubits, even with access to high-performance supercomputers. This ceiling comes from the exponential growth in computational resources required to simulate larger quantum computers (review Massively parallel quantum computer simulator, eleven years later for the full explanation). Exploring quantum computers of 100 qubits and more requires hardware.

  • While some simulators offer noise models, it is a very hard problem to capture the entire dynamics of a real QPU. Quantum hardware offers the potential for researchers to confront the challenges inherent in quantum computers, such as noise, errors, and decoherence in a realistic testing environment.

Interacting with quantum hardware grows skills and experience unattainable by only using simulators:

  • Direct interaction with quantum hardware builds skills because you must implement or use error mitigation or suppression techniques, for reliable computation.

  • Hands-on experience with quantum hardware develops a deeper understanding of quantum phenomena and how to tailor algorithms to the characteristics of quantum processors.

  • Engaging with quantum hardware results in practical insights into the challenges and opportunities of quantum computing, enhancing developers' ability to drive innovation in the field.

Successful quantum algorithms must be adapted to exploit the capabilities of quantum hardware, optimizing performance and efficiency.

  • Quantum hardware provides a more accurate representation of real-world QPUs than simulators.

  • Fine-tuning algorithms for quantum hardware involves adjusting ansatz, circuit implementations, parameters, and configuration to maximize performance. This process is best achieved through direct experimentation with quantum hardware.


When should simulators be used?

Quantum simulators should be used to help develop and test programs before fine-tuning them and sending them to quantum hardware. Local simulators can do this with good performance and efficiency. Clifford circuits can be simulated very efficiently, and results can be verified, which is a useful way to gain confidence in an experiment.

Note

Local testing mode does not have built-in error suppression or mitigation. Instead, you must specify those options explicitly. See Configure error mitigation for Qiskit Runtime for details.


Migrate to local simulators

With qiskit-ibm-runtime 0.22.0 or later, you can use local testing mode to replace cloud simulators. Depending on your needs, there are several ways to use local testing mode. To begin, specify one of the fake backends in qiskit_ibm_runtime.fake_provider or specify a Qiskit Aer backend when instantiating a primitive or a session.

Guidance for choosing a simulator

Use the following table to help choose a simulator.

SimulatorFake BackendsAerSimulatorClifford Simulation
PurposeMimics specific IBM® QPUs by using snapshotsGeneral-purpose, high-performance simulationEfficient simulation for Clifford circuits
Noise modelAutomatically applies noise model from QPU snapshotsCustom or based on real QPU calibration dataIdeal for noise-free simulations
Circuit sizeLimited to the capabilities of the mimicked QPUCan handle larger circuitsSuitable for very large circuits (hundreds of qubits)
ResultsModerate runtime for QPU-specific testsShorter runtime for a wide range of simulationsExtremely fast, suitable for stabilizer circuits
Use caseTesting transpiler and QPU-specific behaviorGeneral development, custom noise modelsLarge stabilizer circuits, error correction
Note

For most users, AerSimulator is a good choice, due to its flexibility and performance. However, if your work targets a specific QPU, a fake backend might be a better choice.

Fake backends

The fake backends mimic the behaviors of IBM QPUs by using snapshots. The snapshots contain important information about the QPU, such as the coupling map, basis gates, and qubit properties, which are useful for testing the transpiler and performing noisy simulations of the QPU. The noise model from the snapshot is automatically applied during simulation.

Example:

from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_ibm_runtime import SamplerV2 as Sampler, QiskitRuntimeService
 
service = QiskitRuntimeService()
 
# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
 
# Run the sampler job locally using FakeManilaV2
fake_manila = FakeManilaV2()
pm = generate_preset_pass_manager(backend=fake_manila, optimization_level=1)
isa_qc = pm.run(qc)
 
# You can use a fixed seed to get fixed results.
options = {"simulator": {"seed_simulator": 42}}
sampler = Sampler(mode=fake_manila, options=options)
 
result = sampler.run([isa_qc]).result()

AerSimulator

You can use local testing mode with simulators from Qiskit Aer, which provides higher-performance simulation that can handle larger circuits and custom noise models. It also supports Clifford simulation mode, which can efficiently simulate Clifford circuits with a large number of qubits.

Example with sessions, without noise:

from qiskit_aer import AerSimulator
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import Session, SamplerV2 as Sampler, QiskitRuntimeService
 
service = QiskitRuntimeService()
 
# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
 
# Run the sampler job locally using AerSimulator.
# Session syntax is supported but ignored because local mode doesn't support sessions.
aer_sim = AerSimulator()
pm = generate_preset_pass_manager(backend=aer_sim, optimization_level=1)
isa_qc = pm.run(qc)
with Session(backend=aer_sim) as session:
    sampler = Sampler()
    result = sampler.run([isa_qc]).result()

To simulate with noise, specify a QPU (quantum hardware) and submit it to Aer. Aer builds a noise model based on the calibration data from that QPU and instantiates an Aer backend with that model. If you prefer, you can build a noise model.

Example with noise:

from qiskit_aer import AerSimulator
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler
 
service = QiskitRuntimeService()
 
# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
 
# Specify a QPU to use for the noise model
real_backend = service.backend("ibm_brisbane")
aer = AerSimulator.from_backend(real_backend)
 
# Run the sampler job locally using AerSimulator.
pm = generate_preset_pass_manager(backend=aer, optimization_level=1)
isa_qc = pm.run(qc)
sampler = Sampler(mode=aer)
result = sampler.run([isa_qc]).result()

Clifford simulation

Because Clifford circuits can be simulated efficiently with verifiable results, Clifford simulation is a very useful tool. For an in-depth example, see Efficient simulation of stabilizer circuits with Qiskit Aer primitives.

Example:

import numpy as np
from qiskit.circuit.library import EfficientSU2
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler
 
service = QiskitRuntimeService()
 
n_qubits = 500  # <---- note this uses 500 qubits!
circuit = EfficientSU2(n_qubits)
circuit.measure_all()
 
rng = np.random.default_rng(1234)
params = rng.choice(
    [0, np.pi / 2, np.pi, 3 * np.pi / 2],
    size=circuit.num_parameters,
)
 
# Tell Aer to use the stabilizer (clifford) simulation method
aer_sim = AerSimulator(method="stabilizer")
 
pm = generate_preset_pass_manager(backend=aer_sim, optimization_level=1)
isa_circuit = pm.run(circuit)
sampler = Sampler(mode=aer_sim)
result = sampler.run([(isa_circuit, params)]).result()