You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is the call to generate_random_op making a random 2 qubit unitary matrix? I've replaced it with a specific unitary below to ensure reproducibility.
I have actually reporoduced this... It does seem like RoutingPass gets stuck for me. I think its a problem with RoutingPass not working with Unitary2qBox in general. As a user its fair to expect this to either succeed or raise an informative error.
This seems to not terminate with python 3.11.1 and pytket v 1.27 which is indeed puzzling... we should look into that. If however I perform the DecomposeBoxes pass to decompose the unitaries to simpler gates and then do the RoutingPass everything works fine. It seems that RoutingPass is not playing nicely with the higher level box operations.
Seems like a bug to me.
Workaround below
frompytket.passesimportDecomposeBoxes# Define architecturearch=Architecture([(0, 1), (1, 2), (2, 3), (3, 4)])
# Route circuitPlacementPass(LinePlacement(arch)).apply(circuit)
# Decompose the Unitary boxes to primitive gates - this is the new stepDecomposeBoxes().apply(circuit)
# Route CircuitRoutingPass(arch).apply(circuit) # Now working
Here's my circuit and my compilation code
circuit = pytket.Circuit(n_qubits)
box = pytket.circuit.Unitary2qBox(generate_random_op())
circuit.add_unitary2qbox(box, 0, 1)
circuit.add_unitary2qbox(box, 2, 3)
circuit.add_unitary2qbox(box, 1, 2)
circuit.add_unitary2qbox(box, 0, 3)
arch = pytket.architecture.Architecture([(0,1), (1, 2), (2, 3), (3, 4)])
from pytket.placement import LinePlacement
from pytket.passes import PlacementPass, RoutingPass
PlacementPass(LinePlacement(arch)).apply(circuit)
RoutingPass(arch).apply(circuit)
If I replace the unitary2qbox components with any predefined 2 qubit gate, the code executes without issue.
The text was updated successfully, but these errors were encountered: