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

Circuit semantics changed when applying GlobalisePhasedX #1554

Open
Bennybenassius opened this issue Aug 27, 2024 · 0 comments
Open

Circuit semantics changed when applying GlobalisePhasedX #1554

Bennybenassius opened this issue Aug 27, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Bennybenassius
Copy link

Bennybenassius commented Aug 27, 2024

Ilan and I have found this bug when testing random circuits on the GlobalisePhasedX pass:

Running this code:

from pytket import Circuit, Qubit
from pytket.circuit import CircBox, OpType, MultiplexorBox, Op
import numpy as np
from pytket.passes import *

subcirc_0 = Circuit(0, "subcirc_0")
qbit_0 = Qubit("qbit_0", 0)
subcirc_0.add_qubit(qbit_0)
qbit_1 = Qubit("qbit_1", 0)
subcirc_0.add_qubit(qbit_1)

subcirc_0.Z(qbit_0)
circbox_subcirc_0 = CircBox(subcirc_0)

main_circ = Circuit(4, 2, "main_circ")

"""
# works
main_circ.add_gate(circbox_subcirc_0,[3, 1]) 
main_circ.X(0)
"""

# doesn't work
main_circ.add_gate(circbox_subcirc_0,[0, 1]) 
main_circ.X(0)

"""
# works
main_circ.X(0)
main_circ.add_gate(circbox_subcirc_0,[0, 1]) 
"""

sv1 = main_circ.get_statevector()

print(sv1)

GlobalisePhasedX().apply(main_circ)

sv2 = main_circ.get_statevector()

print(sv2)

print(abs(np.vdot(sv1, sv2)))

And when checking out the state-vector of the Circuit after the pass, we noticed that the state-vector seems to imply that the state |0000> has 100% probability of occurring, which was confirmed when we checked the circuit:
image

This seems to only happen when a multi-qubit Circbox is added before a single-qubit gate on the same qubit.

@cqc-alec cqc-alec added the bug Something isn't working label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants