Support for the inversion modifier of OpenQASM 3.0 #26
Labels
Core
Anything related to the Core library and IR
enhancement
New feature or request
good first issue
Good for newcomers
Milestone
The new OpenQASM standard introduces gate modifiers in order to more efficiently describe quantum circuits. Any modifier
mod
can be applied to a gateg
viamod @ g
. For more details, see Section 4.2 in https://arxiv.org/pdf/2104.14722.pdf or the Live Specification.The inversion modifier
inv
can be used to invert any gateg
viainv @ g
. The inverse of any gate can be computed as:U = U_m-1 ... U_0
its inverseU^-1
is defined by reversing the order of operations and inverting each individual gate, i.e.,U^-1 = U_0^-1 ... U_m-1^-1
.inv @ ctrl @ g = ctrl @ inv @ g
.inv @ U(a, b, c) = U(-a, -c, -b)
andinv @ gphase(a) = gphase(-a)
Note that the global phase gate
gphase(a)
is not yet introduced and its implementation is left for another issue at the moment.We should be able to handle many of these inversions in a cleverer fashion, e.g., if it is known, that a gate is self-inverse, or e.g., in case of the phase gate, where the inverse is obtained by negating the parameter.
Enhancing the OpenQASM parser with this feature provides greater flexibility for describing circuits in a standardized way.
Tasks
The text was updated successfully, but these errors were encountered: