Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.99k stars 2.32k forks source link

target.get_calibration fails for entries with a fixed parameter #11657

Open ajavadia opened 6 months ago

ajavadia commented 6 months ago

Environment

What is happening?

This is another issue about how the string identfiers (keys) in Target are conflated with the actual operation.

I think target.get_calibration's signature is problematic. It takes a string, qubits, and parameters. However if the Operation associated with this entry is a parameterized operation which has been entered with a fixed parameter, the binding of the supplied parameter fails. So this function should return the calibration for an Operation, and not have to rely on the string identifiers.

I hit this in the PulseGates pass which is run automatically in the preset passmanagers. This pass tries to look up the cal for all instructions in the Target.

How can we reproduce the issue?

cal = Schedule()  # empty schedule for demonstration purposes
rzx_props = {
(0, 1): InstructionProperties(duration=1.04e-6, error=.01, calibration=cal),
}

target.add_instruction(RZXGate(np.pi / 4), rzx_props, name='rzx')
target.get_calibration('rzx', (0, 1), np.pi/6)  # this raises with any angle value, even if it matches the original angle

What should happen?

should return the cal for RZX(np.pi/6) which has been stored in the Target. More likely, the signature of target.get_calibration() should change.

Any suggestions?

No response

MozammilQ commented 6 months ago

@ajavadia , I am familiar with Target source code, I could be assigned to this issue, if you believe so :)