-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Environment
- Qiskit version: 0.34.1
- Qiskit Terra version: 0.19.1
- Python version: 3.8.2
- Operating system: Ubuntu 20.04 (via Windows WSL)
What is happening?
I'm attempting to queue circuits to run on the devices that involve delays before the measurements. If I send a circuit with a delay then I may receive the error message:
TranspilerError: "This circuit None may involve a delay instruction violating the pulse controller alignment. To adjust instructions to right timing, you should call one of scheduling passes first. This is usually done by calling transpiler with scheduling_method='alap'."
If I try running qiskit.execute
with the argument scheduling_method='alap'
as suggested then I receive the same error. Furthermore if I try to pre-transpile the circuit with qiskit.transpile
with the same scheduling method argument and try to execute the transpiled circuit I get the same error.
How can we reproduce the issue?
IN
from qiskit import QuantumCircuit, execute, IBMQ, transpile
backend = reservation_provider.backend.ibmq_casablanca
test_circ = QuantumCircuit(1)
test_circ.x(0)
test_circ.delay(20, unit="dt")
test_circ.measure_all()
test_circ.draw()
OUT
┌───┐┌───────────────┐ ░ ┌─┐
q: ┤ X ├┤ Delay(20[dt]) ├─░─┤M├
└───┘└───────────────┘ ░ └╥┘
meas: 1/══════════════════════════╩═
0
IN
test_job = execute(test_circ, backend=backend, shots=10000)
OUT
Above error
IN
test_job = execute(test_circ, backend=backend, shots=10000, scheduling_method='alap')
OUT
Above error
IN
# pre-transpile the circuit
test_circ_transpiled = transpile(test_circ,backend=backend, scheduling_method='alap')
test_circ_transpiled.draw()
OUT
┌───┐ ┌───────────────┐ ░ ┌───────────────┐┌─┐
q_0 -> 0 ───────┤ X ├────────┤ Delay(20[dt]) ├─░─┤ Delay(12[dt]) ├┤M├
┌──────┴───┴───────┐└───────────────┘ ░ └───────────────┘└╥┘
ancilla_0 -> 1 ┤ Delay(26704[dt]) ├──────────────────────────────────────╫─
├──────────────────┤ ║
ancilla_1 -> 2 ┤ Delay(26704[dt]) ├──────────────────────────────────────╫─
├──────────────────┤ ║
ancilla_2 -> 3 ┤ Delay(26704[dt]) ├──────────────────────────────────────╫─
├──────────────────┤ ║
ancilla_3 -> 4 ┤ Delay(26704[dt]) ├──────────────────────────────────────╫─
├──────────────────┤ ║
ancilla_4 -> 5 ┤ Delay(26704[dt]) ├──────────────────────────────────────╫─
├──────────────────┤ ║
ancilla_5 -> 6 ┤ Delay(26704[dt]) ├──────────────────────────────────────╫─
└──────────────────┘ ║
meas: 1/══════════════════════════════════════════════════════════╩═
0
IN
test_job = execute(test_circ_transpiled, backend=backend, shots=10000)
OUT
Above error
IN
test_job = execute(test_circ_transpiled, backend=backend, shots=10000, scheduling_method='alap')
OUT
Above error
What should happen?
I expect the execute
functions to finish running in a few seconds and for the job to be queued up to run on the device.
Any suggestions?
I noticed in the traceback that when the execute function transpiles a circuit to run on the device it doesn't seem to use the scheduling_method
argument, see lines 292-303 of qiskit/execute_function.py
in my installation
else:
# transpiling the circuits using given transpile options
experiments = transpile(
experiments,
basis_gates=basis_gates,
coupling_map=coupling_map,
backend_properties=backend_properties,
initial_layout=initial_layout,
seed_transpiler=seed_transpiler,
optimization_level=optimization_level,
backend=backend
)
I tried making this edit to my local installation
else:
# transpiling the circuits using given transpile options
experiments = transpile(
experiments,
basis_gates=basis_gates,
coupling_map=coupling_map,
backend_properties=backend_properties,
initial_layout=initial_layout,
seed_transpiler=seed_transpiler,
optimization_level=optimization_level,
backend=backend,
scheduling_method=scheduling_method # <-----Added by me
)
and the code in the MWE above ran without errors, with my jobs getting queued and running with the expected results.
I'm hesitant to make a pull request with this change in case this causes problems elsewhere but it definitely solves my problem.