Quantum Computing Asked by Aaron Barbosa on February 11, 2021
I’m trying to simulate a basic circuit using the PulseSimulator
in Qiskit. The following Qiskit Pulse code works when I run it on the real device, but not when using the PulseSimulator
. The job monitor tells me Job Status: job incurred error
and nothing else.
Trying to run any gates native to the device causes an issue. If I remove schedule += inst_sched_map.get('u2', [qubit], P0=0.0, P1=np.pi)
then it runs fine, but I can’t figure out what I’m doing wrong. I’d deeply appreciate any support. I’m using qiskit 0.23.2
#Essential Imports
import numpy as np
# Qiskit Imports
from qiskit.providers.aer import PulseSimulator
from qiskit import IBMQ, assemble
from qiskit.tools.monitor import job_monitor
import qiskit.pulse as pulse
# Connect to an IBMQ Account and Backend
API_TOKEN = ''
IBMQ.save_account(API_TOKEN, overwrite=True)
IBMQ.load_account()
provider = IBMQ.get_provider()
backend = provider.get_backend("ibmq_armonk")
backend_pulse_simulator = PulseSimulator.from_backend(backend) #backend
# Get information about the backend
qubit = 0
backend_defaults = backend.defaults()
backend_properties = backend.properties()
qubit_frequency_updated = backend_properties.qubit_property(qubit, 'frequency')[0]
inst_sched_map = backend_defaults.instruction_schedule_map
measure_schedule = inst_sched_map.get('measure', qubits=[qubit])
# Assemble a job - circuit with a single qubit-> u2 gate -> measurement
num_shots_per_point = 1024
drive_chan = pulse.DriveChannel(qubit)
schedule = pulse.Schedule()
schedule += inst_sched_map.get('u2', [qubit], P0=0.0, P1=np.pi) # Removing this solves the issue - why?
schedule += measure_schedule << schedule.duration
pulse_program = assemble(schedule,
backend=backend_pulse_simulator,
meas_level=2, meas_return="single",
shots=num_shots_per_point,
schedule_los=[{drive_chan: qubit_frequency_updated}])
# Run the job
job = backend_pulse_simulator.run(pulse_program)
job_monitor(job)
The job incurred error with pulse can be the result of a timing problem in the different pulses execution, but in your code the PulseSimulator() class must get backends provided by Terra such as FakeArmonk(), FakeParis()..etc. Here below an example
from qiskit.test.mock import FakeArmonk
backend=FakeArmonk()
backend_pulse_simulator = PulseSimulator.from_backend(backend) # using FakeArmonk() backend
print(type(backend_pulse_simulator))
The FakeBackends() have the properties of the IBM Quantum devices data and are stored in Qiskit Terra.
Another way is to specify a PulseSystemModel() from a reel backend this time and pass the system model to the execution, here below an example with ibmq_armonk .
armonk_backend= provider.get_backend("ibmq_armonk")
armonk_model = PulseSystemModel.from_backend(armonk_backend)
backend_pulse_simulator=PulseSimulator()
job = backend_pulse_simulator.run(pulse_program, armonk_model)
hope this helps
Patrick
Answered by Patrick Mensac on February 11, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP