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

Assertion failure from getting state-vector after GlobalisePhasedX pass #1552

Open
Bennybenassius opened this issue Aug 27, 2024 · 2 comments
Assignees

Comments

@Bennybenassius
Copy link

Bennybenassius commented Aug 27, 2024

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

The circuit below fails when run:

from pytket import Circuit, Qubit
from pytket.circuit import CircBox, OpType, MultiplexorBox, Op
from sympy import Symbol
from pytket.passes import *

# Writing multiplexor 
U3_op = Op.create(OpType.U3,(-0.63,0.37,0.26))
U2_op = Op.create(OpType.U2,(-0.04,0.71))
op_map = {(0,):U3_op,(1,):U2_op}
multiplexor = MultiplexorBox(op_map)

main_circ = Circuit(4, 2, "main_circ")
# Adding qregs and qubit resources 
qbit_0 = Qubit("qbit_0", 0)
main_circ.add_qubit(qbit_0)
qreg_1 = main_circ.add_q_register("qreg_1",1)

# Adding symbols 
a = Symbol("a")
b = Symbol("b")
s_map = {a: -6.681, b: 0.844} 

# Applying gates
main_circ.U3(b,-0.2,0.79,qbit_0)
main_circ.add_gate(multiplexor,[0, 2])
main_circ.U2(b,0.66,qbit_0)
main_circ.add_gate(OpType.XXPhase,[-0.27],[2, 3])

main_circ.symbol_substitution(s_map)

GlobalisePhasedX().apply(main_circ)

sv1 = main_circ.get_statevector()

print(sv1)

Which causes an assertion failure:

Assertion '!"slice is empty"' (/root/.conan2/p/b/tketa8cd64ce2b167/b/src/Circuit/macro_circ_info.cpp : operator++ : 935) failed.  Aborting.

The issue seems to only work with this specific order of gates and qubits used. If the XXPhase gate used qubits 1 and 3, the circuit will compile without an issue.

@Bennybenassius Bennybenassius changed the title Assertion failure when using GlobalisePhasedX pass Assertion failure from getting state-vector after GlobalisePhasedX pass Aug 27, 2024
@cqc-alec
Copy link
Collaborator

cqc-alec commented Sep 3, 2024

Possibly related to #1324 .

@IlanIwumbwe
Copy link

Ah, I see. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants