CQCL / pytket-docs

User manual and example notebooks for the pytket quantum computing toolkit
https://docs.quantinuum.com/tket/user-guide/
Apache License 2.0
331 stars 90 forks source link

Wrong result with pytket-qulacs #35

Closed georgios-ts closed 3 years ago

georgios-ts commented 3 years ago
from numpy import pi
import pytket as tket
from pytket.qulacs import tk_to_qulacs
from qulacs import QuantumState

qc = tket.Circuit(1)
qc.Rx(0.5, 0)

qc = tk_to_qulacs(qc)

state = QuantumState(1)
qc.update_quantum_state(state)

print(state.get_vector())
----
Output:
[0.70710678+0.j         0.+0.70710678j]
Expected Output:
[0.70710678+0.j         0.-0.70710678j]

From Qulacs documentation: Rotation gates RX, RY, and RZ operate as Pauli rotation exp(𝑖𝜃/2𝑃) based on corresponding Pauli operator 𝑃 and argument 𝜃

Since tket uses exp(-𝑖aπ/2𝑃) representation, arguments of rotation gates should be multiplied by -1 inside tk_to_qulacs.

cqc-alec commented 3 years ago

Thank you for the report. This is indeed a bug in the pytket-qulacs backend. We will fix it in the next release, due around the beginning of February.

(In the meantime if you want to patch your 0.3.3 installation you should change param to -param at line 73 of qulacs_convert.py.)

ss2165 commented 3 years ago

Fixed in pytket-qulacs 0.4.0