Allow the transpiler to find gate durations from calibrations
See original GitHub issueInformation
- Qiskit Terra version:
- Python version:
- Operating system:
What is the current behavior?
The scheduling_method of the transpiler fails when gate durations are determined by provided gate calibrations.
Steps to reproduce the problem
Make a program with a calibration. (This is a brand new feature!)
from qiskit import pulse, QuantumCircuit
prog = QuantumCircuit(1, 1)
qc.rx(np.pi / 2, [0])
qc.x(0)
qc.delay(2, [0], unit='us')
qc.measure(0, 0)
qc.add_calibration('x', [0], pulse.Schedule(name='dummy_x')) # The schedules can be empty for our purposes
qc.add_calibration('rx', [0], pulse.Schedule(name='dummy_x90'), [np.pi / 2])
The times are fully specified, since each operation plays immediately after the last. The duration of the rx and x gates can be determined by the duration property of the provided schedule, in this silly example, the durations are 0. The delay duration is 2 microseconds.
The following fails because the transpiler doesn’t know how long x and rx(pi/2) are.
qc = transpile(qc, backend, scheduling_method='asap', dt=dt)
It works if you add it explicitly:
qc = transpile(qc, backend, scheduling_method='asap', dt=dt,
instruction_durations=[('x', [qubit], pi_pulse.duration),
('rx', [qubit], x90_pulse.duration)]
What is the expected behavior?
I should be able to transpile this program with only: transpile(qc, backend, scheduling_method='asap', dt=dt). I shouldn’t have to provide instruction_durations.
Suggested solutions
The scheduling passes shouldn’t have to be modified. I believe there is a place in transpiler.py where the InstructionDurations are determined from a backend, or from the function arguments. This part should be updated to first look for durations in the input circuit.calibrations. The calibrations table is in this format:
qc.calibrations = {
'<gatename (ex: "rx")>': {
{(<qubits tuple (ex: (0,))>, (<params tuple (ex: (np.pi/2,))>)): Schedule(...)},
... # other cals for that gate, on different qubits or with different parameters
},
...
}
It’s important that the durations look to the calibrations first, since the cals overwrite whatever definition the backend would use.
This might be challenging for more than one circuit, since each circuit can have different durations. I would recommend getting this to work for one circuit first, or multiple circuits with the same calibrations.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Thank you @YosephKS , I just wanted to confirm this only.
@YosephKS Thank you! If you have questions, let me know. You can ask here, but I will be more responsive if you ask on Qiskit slack (
@lauren.capelluto)