A Qiskit transpiler pass implementing multi-level SABRE algorithm
Project description
MultiLevel SABRE
A Python implementation of the MultiLevel SABRE algorithm for quantum circuit optimization.
Installation
Since this package is not yet published on PyPI, you can install it locally using pip:
pip install -e .
Usage
Check the examples directory for detailed example notebooks and scripts demonstrating how to use the MultiLevel SABRE algorithm. The examples include:
- Simple circuit optimization
- Comparison with the original SABRE algorithm
- Performance analysis and benchmarking
Simple Example
Here's a basic example of how to use the MultiLevel SABRE algorithm with a simple circuit:
from qiskit import QuantumCircuit
from qiskit.transpiler import CouplingMap
from multilevel_sabre import MultiLevelSabre
# Create a quantum circuit
circuit = QuantumCircuit(5)
circuit.h(0)
circuit.cx(0, 1)
circuit.cx(1, 2)
circuit.cx(2, 3)
circuit.cx(3, 4)
# Define the hardware topology (example: linear chain)
coupling_map = CouplingMap.from_line(5)
# Create and run the MultiLevel SABRE pass
pass_manager = PassManager([
MultiLevelSabre(
coupling_graph=coupling_map,
cycles=10, # Number of optimization cycles
random_seed=1, # Random seed for reproducibility
coarsest_solving_trials=50, # Number of trials at coarsest level
num_interpolation=10, # Number of interpolation steps
use_initial_embedding=True, # Use initial qubit mapping
verbose=0 # Verbosity level (0: off, 1: minimal, 2: full)
)
])
# Run the pass
optimized_circuit = pass_manager.run(circuit)
Comparison with SABRE
The package includes a comparison example that demonstrates the performance difference between MultiLevel SABRE and the original SABRE algorithm. You can run it using:
python examples/comparison_example.py
This example:
- Loads a QASM circuit
- Runs both SABRE and MultiLevel SABRE on the same circuit
- Compares the number of SWAP gates and compilation time
- Shows the speedup and SWAP reduction achieved by MultiLevel SABRE
Parameters
The MultiLevelSabre class accepts the following parameters:
coupling_graph(CouplingMap): The hardware topology defining which qubits can interact directly.cycles(int, default=10): Number of times to run the multi-level algorithm. Each cycle may produce different results due to randomization. The best result (fewest SWAPs) is kept.random_seed(int, default=1): Seed for the random number generator. Use this for reproducible results.coarsest_solving_trials(int, default=50): Number of trials to attempt at the coarsest level of the circuit. More trials may find better solutions but take longer to run.num_interpolation(int, default=10): Number of interpolation steps used when refining the circuit from the coarsest level back to the original size. More steps may produce better results but take longer to compute.use_initial_embedding(bool, default=True): Whether to use an initial qubit mapping/embedding before starting the optimization. If True, uses a simple heuristic to find an initial mapping. If False, starts with a random mapping.verbose(int, default=0): Controls the verbosity level of the output:- 0: No output (off)
- 1: Minimal output (basic progress information)
- 2: Full output (detailed progress and statistics)
License
This project is licensed under the MIT License - see the LICENSE file for details.
@inproceedings{2025MultilevelQuantum,
title={A High-Performance Multilevel Framework for Quantum Layout Synthesis},
author={Ping, Shuohao and Sathishkumar, Naren and Lin, Wan-Hsuan and Wang, Hanyu and Cong, Jason},
year={2025},
organization={Computer Science Department, University of California, Los Angeles, CA, USA}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multilevel_sabre-0.1.0.tar.gz.
File metadata
- Download URL: multilevel_sabre-0.1.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
307abf3ec3505fdea57413c6e8b45b17db87fd1a3d600884fefd1c9fbbdf3a83
|
|
| MD5 |
6ce120b49238bf2bdcc93470b49ab280
|
|
| BLAKE2b-256 |
c57ce52fc4758b21bd6ccf78ad021a1a3315cadd380a8a4c6fc45601e55520d1
|
File details
Details for the file multilevel_sabre-0.1.0-py3-none-any.whl.
File metadata
- Download URL: multilevel_sabre-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df6202106e610e28057d4d73a6de36764b7bfa823bfa0c1e989d7c313a0984e3
|
|
| MD5 |
e11cddc9d0bfb55a1c2b0b7395a14982
|
|
| BLAKE2b-256 |
b59709a9fbd9197c0c9e4c53e43df71f58286e4b748dab035369f3153f766c9c
|