Description
Opening a fresh blank issue for an approach to solving #2032, see related discussion also in #2072.
User circuits may contain RZZ gates with invalid angles (i.e., negative or greater than pi/2
). There are two types of usages of RZZ:
- Numeric - for example an RZZ gate with angle of -1.3 radians on qubits 4 and 2:
rzz(-1.3, 4, 2)
. We take care of these gates when transpiling for IBM backends, using theFoldRzzAngle
pass. - Parametrized - the angle is specified by a parameter or a parameter expression, for example
rzz(p, 4, 2), rzz(p1 + p2, 3, 4)
. The parameters are later instantiated with values, which may result in invalid angles. This issue is about this parametrized case.
#2032 focuses on invalid pubs resulting from transpilation. Another important and frequent use case relates to the original pub, as specified by the user, even before transpilation: the pub can contain many parameter sets, making it impossible for the user to detect and fix faulty parameter sets. This issue applies to both scenarios.
We will make pubs valid by following the construction of the FoldRzzAngle
pass. We will add to the circuit new rz
and rx
gates, and extra parameters for the new gates and for a modified RZZ gate. We will append values of the new parameters to the parameter values.
An interesting question is whether to implement this procedure by writing a function that receives valid pubs and outputs invalid pubs; or by writing a transpiler pass, and accompanying it with a function that modifies the parameter values. A function is a cleaner interface and easier to opt-in. It may however mess up with dynamical decoupling. I'm interested to hear opinions about these two options (@nkanazawa1989 , @wshanks, @ihincks, @jyu00, @mtreinish, @jakelishman).
A bit more clarification about dynamical decoupling: the user can run the function before or after transpilation. If before then we can get the #2032 surprise. If after then the circuit is altered after dynamical decoupling.
Finally, a smaller things to think of: Automatic addition of new parameters may cause name collision with user parameters.