You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing with the trotterize_exp_qubop_to_qasm function, and I think it may be outputting incorrect circuits. I have constructed the following minimal broken example to demonstrate.
If we consider the Hamiltonian $H = \sigma^x + \sigma^z$, then the expected time evolution of $H$ is given by
$$| \psi(t) \rangle = \exp \left( -i H t \right) | \psi(0) \rangle.$$
To perform this evolution, we can use the first order Trotter formula
$$\exp \left( A + B \right) = \lim_{n \to \infty} \left( \exp{\left( \frac{A}{n} \right)} \exp{\left(\frac{B}{n} \right )} \right)^n.$$
If we approximate this series using $n = 1$ (perform the evolution using a single trotter step) and consider an evolution time of $t = 1$, we obtain
According to the documentation for Cirq, the definition for cirq.Rx is Rx(rads) = exp(-i X rads / 2) and the definition for cirq.Rz is Rz(rads) = exp(-i Z rads / 2). This means that the qasm circuit for the above described problem would be the following (note that I am using the identity that Rx(rads) = H Rz(rads) H to be consistent with the output of trotterize_exp_qubop_to_qasm)
H 0
Rz 2.0 0
H 0
Rz 2.0 0
However, when I implement the circuit in openfermion using the following code:
import openfermion as of
H = of.QubitOperator('X0') + of.QubitOperator('Z0')
trotter_generator = of.trotterize_exp_qubop_to_qasm(H, evolution_time = 1)
[print(op) for op in trotter_generator]
the output is the following:
H 0
Rz 1.0 0
H 0
Rz 1.0 0
which implies that the rotation angles are half of what they should be. I believe that the bug arises from src/openfermion/circuits/trotter_exp_to_qgates.py in the function pauli_exp_to_qasm at lines 250 and 254. In these lines, the factor of 2 is not multiplied in and seems to cause the issue.
I am not sure whether there are more instances of this potential mistake in the code base. Hopefully my logic is sound, and I am not just missing something.
Thank you.
The text was updated successfully, but these errors were encountered:
Hello,
I was playing with the
trotterize_exp_qubop_to_qasm
function, and I think it may be outputting incorrect circuits. I have constructed the following minimal broken example to demonstrate.If we consider the Hamiltonian$H = \sigma^x + \sigma^z$ , then the expected time evolution of $H$ is given by
To perform this evolution, we can use the first order Trotter formula
If we approximate this series using$n = 1$ (perform the evolution using a single trotter step) and consider an evolution time of $t = 1$ , we obtain
According to the documentation for Cirq, the definition for
cirq.Rx
isRx(rads) = exp(-i X rads / 2)
and the definition forcirq.Rz
isRz(rads) = exp(-i Z rads / 2)
. This means that the qasm circuit for the above described problem would be the following (note that I am using the identity that Rx(rads) = H Rz(rads) H to be consistent with the output oftrotterize_exp_qubop_to_qasm
)However, when I implement the circuit in openfermion using the following code:
the output is the following:
which implies that the rotation angles are half of what they should be. I believe that the bug arises from
src/openfermion/circuits/trotter_exp_to_qgates.py
in the functionpauli_exp_to_qasm
at lines 250 and 254. In these lines, the factor of 2 is not multiplied in and seems to cause the issue.I am not sure whether there are more instances of this potential mistake in the code base. Hopefully my logic is sound, and I am not just missing something.
Thank you.
The text was updated successfully, but these errors were encountered: