Qiskit / qiskit-ibm-runtime

IBM Client for Qiskit Runtime
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime
Apache License 2.0
161 stars 157 forks source link

rzz angle validation assumes fixed parameters #1998

Closed yaelbh closed 1 month ago

yaelbh commented 1 month ago

We recently added a check that rzz angle is in the range [0, pi/2] (#1949).

As noted by @ihincks, the check assumes that the angle is a number. The following code snippet fails:

param = Parameter("p")

circ = QuantumCircuit(2)
circ.rzz(param, 0, 1)

SamplerV2(backend).run(pubs=[(circ, [1])])

It produces the error:

TypeError: '<' not supported between instances of 'Parameter' and 'float' 
yaelbh commented 1 month ago

In #1999 we only skip the validation if the angle is of type Parameter. One could expect that, if the angle is a Parameter, then we should verify that all values assigned to the parameter are in the permitted range. What do you think? (@ihincks, @jyu00)