Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect conversion of parameterised gates with large angles with qiskit_to_tk #367

Open
CalMacCQ opened this issue Jul 17, 2024 · 1 comment
Labels
bug Something isn't working circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa

Comments

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Jul 17, 2024

from pytket.extensions.qiskit import qiskit_to_tk
from pytket.qasm import circuit_to_qasm_str
from qiskit import QuantumCircuit
import numpy as np

qc = QuantumCircuit(1)
qc.rx((1e14 + 0.12)*np.pi, 0) # rx gate with a large parameter value

circ = qiskit_to_tk(qc)
print(circuit_to_qasm_str(circ))

QASM output

OPENQASM 2.0;
include "qelib1.inc";

qreg q[1];
rx(0.21875*pi) q[0];

The operators for rx(0.21875*pi) and rx(0.12*pi) are not unitarily equivalent. Seems like there is some rounding error occuring when converting the large parameter value to pytket.

As far as I know for the converision from qiskit params to pytket params simply consists in dividing by sympy.pi (for numeric values) to account for the differing angle conventions.

See https://github.com/CQCL/pytket-qiskit/blob/main/pytket/extensions/qiskit/qiskit_convert.py#L571

@CalMacCQ CalMacCQ added bug Something isn't working circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa labels Jul 17, 2024
@CalMacCQ CalMacCQ changed the title Incorrect conversion of parametrised gates with large angles with qiskit_to_tk Incorrect conversion of parameterised gates with large angles with qiskit_to_tk Jul 17, 2024
@CalMacCQ
Copy link
Contributor Author

One option would be to normalise these large angles mod $2 \pi$ in qiskit_to_tk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa
Projects
None yet
Development

No branches or pull requests

1 participant