Comments (1)
Thanks for making an issue,
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.
from pytket.circuit import Circuit, Unitary2qBox
from pytket.placement import LinePlacement
from pytket.passes import PlacementPass, RoutingPass
from pytket.architecture import Architecture
import numpy as np
# Define 2q unitary subroutine
unitary_2q = np.asarray([[0, 1, 0, 0],
[0, 0, 0, -1],
[1, 0, 0, 0],
[0, 0, -1j, 0]])
box_2q = Unitary2qBox(unitary_2q)
# Build Circuit
circuit = Circuit(4)
circuit.add_unitary2qbox(box_2q, 0, 1)
circuit.add_unitary2qbox(box_2q, 2, 3)
circuit.add_unitary2qbox(box_2q, 1, 2)
circuit.add_unitary2qbox(box_2q, 0, 3)
# Define architecture
arch = Architecture([(0, 1), (1, 2), (2, 3), (3, 4)])
# Perform placement pass
PlacementPass(LinePlacement(arch)).apply(circuit)
All of the above works fine.. If I now do
RoutingPass(arch).apply(circuit)
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
from pytket.passes import DecomposeBoxes
# Define architecture
arch = Architecture([(0, 1), (1, 2), (2, 3), (3, 4)])
# Route circuit
PlacementPass(LinePlacement(arch)).apply(circuit)
# Decompose the Unitary boxes to primitive gates - this is the new step
DecomposeBoxes().apply(circuit)
# Route Circuit
RoutingPass(arch).apply(circuit) # Now working
from tket.
Related Issues (20)
- Incorrect QASM conversion of `SetBits` operation HOT 2
- Update to circuit-renderer 0.9
- Add function to get wasm uid from circuit
- Wasm encoding is not defined on the json schema
- Incorrect QASM from conditional `RangePredicate`
- Error when converting `MultiBitOp` to QASM
- types-pkg-resources not available anymore HOT 2
- update docs check to use current tket dev version
- check and clean up dependencies
- Python 3.13 support
- Dependencies between the libraries when building with conan HOT 2
- QASM conversion error when multiple `RangePredicate` targeting the same bit HOT 1
- `AASRouting` doesn't work for circuits with non-defualt register names. HOT 2
- Quantum circuit with conditionals can cause RunTime error HOT 5
- QASM Conversion Error with `ClassicalExpBox` inside `CircBox` HOT 1
- `ClassicalExpBox` interacts badly with `flatten_registers` and `DecomposeBoxes`
- `circuit_to_qasm_str` proposed enhancement
- Error when concatenating WASM circuits
- Calling `copy()` or `deepcopy()` on an an object of type `Qubit` produces an object of type `Node` HOT 1
- Some `LogicExp` operations (e.g. `RegAdd`) don't have `_const_eval` implemented
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tket.