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

DecomposeBoxes doesn't decompose CircBox with nested classical control #1583

Open
sjdilkes opened this issue Sep 16, 2024 · 1 comment
Open
Labels
bug Something isn't working classical-logic issues related to classical logical expressions

Comments

@sjdilkes
Copy link
Contributor

See:

from pytket.circuit import CircBox, Circuit, Bit, Qubit
from pytket.qasm import circuit_to_qasm_str
from pytket.passes import DecomposeBoxes

c_inner: Circuit = Circuit(4, 1)
cbox: CircBox = CircBox(Circuit(4).H(0).H(1).H(2).H(3).CX(0, 1).CX(1, 2).CX(2, 3))
c_inner.add_circbox(cbox, [Qubit(i) for i in range(4)], condition=Bit(0))

c_outer: Circuit = Circuit(4, 2)
c_outer.add_circbox(CircBox(c_inner), c_inner.qubits + c_inner.bits, condition=Bit(1))

DecomposeBoxes().apply(c_outer)
print(circuit_to_qasm_str(c_outer, header="hqslib1"))

This code gives an error as c_outer still has a CircBox internally. Printing the circuit commands will give IF ([c[1]] == 1) THEN IF ([c[0]] == 1) THEN CircBox q[0], q[1], q[2], q[3];.

@sjdilkes sjdilkes added the classical-logic issues related to classical logical expressions label Sep 16, 2024
@sjdilkes
Copy link
Contributor Author

Alternatively, applying auto_rebase_pass({OpType.ZZPhase, OpType.PhasedX, OpType.Rz}).apply(c_outer) to the circuit throws a BadOpType error, complaining about a conditional operation.

@cqc-alec cqc-alec added the bug Something isn't working label Oct 8, 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 classical-logic issues related to classical logical expressions
Projects
None yet
Development

No branches or pull requests

2 participants