This repository contains the implementation of K-SWAP SABRE, an extension to the classical SABRE algorithm developed as part of my master thesis.
In order to transpile quantum circuits, so-called SWAP gates need to be inserted into the circuit in order to support two-qubit operations between two logical qubits. During the process of inserting SWAPs, the precedence relations defined in the DAG have to be respected.
The following circuit resembles a 4-qubit adder that is given as an input circuit.
The circuit below shows the result when transpiling the circuit using K-SWAP SABRE algorithm based on a trivial initial mapping.
- Python 3.10 or later
- Rust (via rustup)
- maturin for building Python ↔ Rust extensions
- make (if using a Makefile)
If you just want to try it out in Docker:
docker build -t microscope .-
Clone the repo
git clone https://github.com/yourusername/myproject.git cd myproject -
Create a virtual environment
python3 -m venv .venv source .venv/bin/activate -
Install dependencies
pip install --upgrade pip pip install maturin pip install -r requirements.txt
-
Build and install the Rust extension
maturin develop --release
-
Run the project
make
If you don’t want to install Rust locally, build inside Docker:
docker build -t microscope .-
Use
maturin developfor editable installs while developing. -
For a production build, create a wheel and install it:
maturin build --release -o dist pip install dist/*.whl
- Fork the repo
- Create a new branch (
git checkout -b feature/my-feature) - Make changes
- Commit (
git commit -m "Add my feature") - Push (
git push origin feature/my-feature) - Open a Pull Request