Open Qottmann opened 2 years ago
That's an interesting feature! Are you aware of any other use-cases where the complex conjugate might be useful?
If we were to implement this, we could probably do this analogously to the inverse
: add complex_conjugate
methods to the gates and then delegate QuantumCircuit.complex_conjugate
to the gates. Technically, I don't think that would be a lot of effort and if you need this feature now, @Qottmann, you could also monkey-patch these methods onto the circuit and the gates you need 🙂
Maybe some quantum-info related stuff, otherwise I am not aware of any other use-cases but I'd say this is a pretty big one.
That sounds like exactly the behavior I was looking for!
For the moment though, my workaround above seems to work just fine as well.
If the QuantumCircuit
is small (or of a special type like Clifford
) then one can convert it into and Operator
and use:
https://qiskit.org/documentation/stubs/qiskit.quantum_info.Operator.conjugate.html
What is the expected behavior?
It would be extremely useful for quantum-assisted-quantum-compilation to have a method
complex_conjugate()
for QuantumCircuit objects that returns the same circuit but complex conjugated (not transposed).If that is too much to ask, already having the option for individual circuit elements in the (circuit library)[https://qiskit.org/documentation/apidoc/circuit_library.html] additional to the
inverse()
(=adjoint for unitaries) method.At the moment, one can do this by hand for Two-Local gates knowing that
ry(x)* = ry(x)
,rx(x)*=rx(-x)
andrz(x)* = rz(-x)
, assuming one is only usingry
,rz
and entangling gates that are not complex-valued. Then one can apply a mask consisting of +/-1 for the respective parameters.I provide a short example that highlights how the problem can be circumvented and at the same time where this feature could be useful. Here, we compute the Hilbert Schmidt Test (HST) circuit, see fig. 4 in QAQC. I create a simple TwoLocal Ansatz
circ
and assign it random parameters. I then perform the HST betweencirc
and itself. The output probablity of all-zeros (i.e. "0000") is proportional totr(UV^\dagger)
for two circuitsU
andV
. So in the case of using the same circuit, we expect probability1
, which is the case when the parameters and therefore the target circuit is transformed appropriately, i.e. to the complex conjugate.Output:
and probability
p("0000")=1
In case asking for a general method in
QuantumCircuit
is too much to ask, one could at least include it forTwoLocal
circuits, which should we rather straight-forward in a similar fashion as in the example above. I would be happy to assist.