question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow the transpiler to find gate durations from calibrations

See original GitHub issue

Information

  • 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TheGupta2012commented, Jan 4, 2021

Thank you @YosephKS , I just wanted to confirm this only.

1reaction
lcapellutocommented, Dec 15, 2020

@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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

qiskit.compiler.transpile
If any user defined calibration is found in the map and this is used in a circuit, transpiler attaches the custom gate definition...
Read more >
Calibration-Aware Transpilation for Variational Quantum ...
This distribution is helpful for incremental, calibration-aware transpilation when the variational algorithm adapts its own execution to ...
Read more >
System properties - IBM Quantum
Individual elements in the properties give the times at which they were computed. Depending on the device calibration schedule, these times can be...
Read more >
Optimal calibration of gates in trapped-ion quantum computers
We develop a method to determine a fixed number (budget) of quantum gates that, ... time for maintenance and necessary calibrations of quantum...
Read more >
Minimum Quantum Run-Time Characterization and ...
computer requires periodic gate calibration and character- ... times needed to allow time for classical processing of the readout signal.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found