qiskit/crates
Matthew Treinish b77f3c5b5c
Better align 1q euler decomposition output to multiples of π/2 (#10789)
* Better align 1q euler decomposition output to multiples of π/2

This commit updates the euler decomposer to better align the parameter
outputs to be multiples of π/2 when possible to enable the circuit to
be run under a clifford simulator.

Previously the angle was calculated as:

```
phi = angle(u11 * (det**(-0.5))) + angle(u10 * (det**(-0.5)))
```

which has been replaced with:

```
phi = angle(u11) + angle(u10) - angle(det)
```

The algebra to get the new expression is:

```
phi = angle(u11 * (det**(-0.5))) + angle(u10 * (det**(-0.5)))
    # assumes particular phase convention so not guaranteed to be the
    # valid interpretation (though it probably is).
    = angle(u11) - 0.5*angle(det) + angle(u10) - 0.5*angle(det)
    = angle(u11) + angle(u10) - angle(det)
```

A couple of tests are updated as they were testing for exact circuit
outputs and the synthesis is returning equivalent by different results
in those cases.

Co-authored-by: aeddins-ibm <60495383+aeddins-ibm@users.noreply.github.com>

* Simplify calculation

Given the same phase convention the calculation of theta and phase can
be simplified to remove the need of computing the coeff. This commit
implements this change which should speed up the calculation slighty as
we're doing less work to reach an equivalent result.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>

* Remove complex_phase function

The complex phase function previously defined in
euler_one_qubit_decomposer.rs was duplicated with an existing `arg()`
method of the Complex<T> type from num-complex. This commit removes the
duplicated definition in favor of the built-in method.

* Try removing rz gate from qpy tests to side step differing decomposition of controlled gate

* Update crates/accelerate/src/euler_one_qubit_decomposer.rs

Co-authored-by: aeddins-ibm <60495383+aeddins-ibm@users.noreply.github.com>

---------

Co-authored-by: aeddins-ibm <60495383+aeddins-ibm@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-10-10 11:36:13 +00:00
..
accelerate Better align 1q euler decomposition output to multiples of π/2 (#10789) 2023-10-10 11:36:13 +00:00
qasm2 Handle final comments with no terminating newline in OpenQASM 2 (#10773) 2023-09-05 21:20:29 +00:00