CQCL/tket

`ComposePhasePolyBoxes` doesn't work for circuits with non-default register names

Opened this issue · 0 comments

The ComposePhasePolyBoxes pass doesn't seem to work unless you use the default names for qubits q[0], q[1], q[2].

Example circuit

from pytket import Circuit

circ = Circuit()
P = circ.add_q_register("p", 3)
circ.CX(P[0], P[1]).T(P[1]).CX(P[0], P[1]).H(P[0]).CX(P[0], P[2])
circ.T(P[2]).CX(P[0], P[2]).CX(P[0], P[1]).T(P[1]).H(P[0]).CX(P[0], P[1])

This circuit looks like the following...

circuit

Note how I have labelled my qubits p[0], p[1], p[2] as opposed to the default q[0], q[1], q[2].

Now if I perform the ComposePhasePolyBoxes pass on the circuit...

from pytket.passes import ComposePhasePolyBoxes

ComposePhasePolyBoxes().apply(circ)

I get the error

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[13], line 1
----> 1 ComposePhasePolyBoxes().apply(circ)

RuntimeError: Circuit does not contain unit with id: q[0]

It would be nice if this restriction were removed so that this pass will work with a wider range of circuits. Renaming the qubits or flattening the registers seems to work but complicates my use case significantly.