Document
Migrate to local simulators

Migrate to local simulators

Migrate from cloud simulators to local simulators In quantum computing, the choice between using simulators and quantum hardware is crucial for makin

Related articles

【国内梯子推荐】最好用的VPN梯子推荐与科学上网测评 Add an email account to your iPhone, iPad, or iPod touch COKZEY X5 Doorbell Camera User Manual Ultimate Cloud Kitchen India 21+brand Delhi Does Xfinity throttle the internet?

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 simulator being retire ?

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.

  • engage with quantum hardware resultin practical insight into the challenge and opportunity of quantum computing , enhance developer ‘ 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 is provides provide a more accurate representation of real – world qpu than simulator .

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


When should simulator be used ?

Quantum simulator should be used to help develop and test program before fine – tune them and send them to quantum hardware . local simulators is do can do this with good performance and efficiency . Clifford circuitcan be simulate very efficiently , and resultcan be verify , which is a useful way to gain confidence in an experiment .


Migrate to local simulators

With qiskit-ibm-runtime 0.22.0 or later , you can use local testing mode to replace cloud simulator . depend on your need , there are several way to use local testing mode . To begin , specify one of the fake backend inqiskit_ibm_runtime.fake_provider or specify a Qiskit Aer backend when instantiating a primitive or a session.

guidance for choose a simulator

Use the following table to help choose a simulator.

simulator Fake Backends Aersimulator Clifford Simulation
Purpose Mimics specific IBM® QPUs by using snapshots General-purpose, high-performance simulation Efficient simulation for Clifford circuits
Noise model automatically apply noise model from QPU snapshot Custom or base on real QPU calibration datum Ideal for noise-free simulations
Circuit size limit to the capability of the mimic QPU Can handle larger circuits Suitable for very large circuits (hundreds of qubits)
Results Moderate runtime for QPU-specific tests short runtime for a wide range of simulation Extremely fast, suitable for stabilizer circuits
Use case Testing transpiler and QPU-specific behavior general development , custom noise model Large stabilizer circuits, error correction

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.libraryimport  RealAmplitudes
from     qiskit.circuitimport  QuantumCircuit, QuantumRegister,  ClassicalRegister
from     qiskit.quantum_info import  SparsePauliOp
from     qiskit.transpiler.preset_passmanagerimport  generate_preset_pass_manager
from     qiskit_ibm_runtime.fake_provider import  FakeManilaV2
from      qiskit_ibm_runtimeimport    samplerV2 as    sampler,   QiskitRuntimeService
 
service= QiskitRuntimeService( )
 
# Bell Circuit
qc= QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all( )
 
# Run the   samplerjob 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.
option= {"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_aerimport Aersimulator
from     qiskit.circuit.libraryimport  RealAmplitudes
from     qiskit.circuitimport  QuantumCircuit, QuantumRegister,  ClassicalRegister
from     qiskit.quantum_info import  SparsePauliOp
from     qiskit.transpiler.preset_passmanagerimport  generate_preset_pass_manager
from      qiskit_ibm_runtimeimport  session,    samplerV2 as    sampler,   QiskitRuntimeService
 
service= QiskitRuntimeService( )
 
# Bell Circuit
qc= QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all( )
 
# Run the   samplerjob 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 is builds build a noise model base on the calibration datum from that QPU and instantiate an Aer backend with that model . If you prefer , you is build can build a noise model .

Example with noise:

from      qiskit_aerimport Aersimulator
from     qiskit.circuit.libraryimport  RealAmplitudes
from     qiskit.circuitimport  QuantumCircuit, QuantumRegister,  ClassicalRegister
from     qiskit.quantum_info import  SparsePauliOp
from     qiskit.transpiler.preset_passmanagerimport  generate_preset_pass_manager
from      qiskit_ibm_runtimeimport   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   samplerjob 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.libraryimport EfficientSU2
from      qiskit_ibm_runtimeimport   QiskitRuntimeService,    samplerV2 as    sampler
 
service= QiskitRuntimeService( )
 
n_qubits = 500  # <---- note this uses 500 qubits!
circuit= EfficientSU2( n_qubit )
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_parameter ,
)
 
# 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( )

Was this page helpful?

report a bug or request content on

GitHub

.