Skip to main content

Exact solvers of the qubit routing problem

Project description

Quariadne Qiskit Plugins

This README provides basic usage instructions for the Quariadne MILP-based layout and routing plugins for Qiskit transpilation.

Installation

Install Quariadne using pip:

pip install quariadne

The plugins are automatically registered as Qiskit transpiler entry points upon installation.

Plugin Overview

Quariadne provides two transpiler plugins:

  • Layout Plugin: quariadne_milp - MILP-based initial qubit placement
  • Routing Plugin: quariadne_milp - MILP-based SWAP insertion for circuit routing

Both plugins are registered as entry points in pyproject.toml and must be used together - they do not work when separated.

Basic Usage

Using with Preset Pass Manager

The plugins must be used together with Qiskit's generate_preset_pass_manager():

import qiskit
from qiskit_ibm_runtime.fake_provider import FakeManilaV2

# Create a quantum circuit
circuit = qiskit.QuantumCircuit(3, 3)
circuit.h(0)
circuit.cx(0, 1)
circuit.cx(1, 2)

# Set up backend
backend = FakeManilaV2()

# Generate pass manager with BOTH Quariadne plugins
pass_manager = qiskit.transpiler.generate_preset_pass_manager(
    backend=backend,
    optimization_level=3,
    layout_method="quariadne_milp",
    routing_method="quariadne_milp"  # Both must be used together
)

# Transpile the circuit
transpiled_circuit = pass_manager.run(circuit)

Important Limitations

Circuit Size Constraints

For optimal performance, test with circuits that have:

  • Less than 50 gates
  • Less than 5 qubits

Larger circuits may experience significant performance degradation due to MILP complexity.

Plugin Dependencies

Critical: The layout and routing plugins are interdependent and cannot be used separately. Using only one plugin will result in failure.

Testing and Validation

Use Real Samplers for Testing

Regular circuit execution won't detect illegal operations on backends. Always test with real samplers as shown in the example:

from qiskit_ibm_runtime import Session
from qiskit_ibm_runtime import SamplerV2 as Sampler

# Proper testing cycle with real sampler
with Session(backend=backend) as session:
    sampler = Sampler(mode=session)
    job = sampler.run([transpiled_circuit])
    result = job.result()[0]
    print(result)

This approach ensures illegal operations on the backend are properly detected during testing.

Example Workflow

A complete example is available in notebook/Testing.ipynb, demonstrating:

  1. Circuit creation with random Clifford gates (within size limits)
  2. Backend setup using IBM's Manila fake provider
  3. Transpilation using both Quariadne MILP plugins together
  4. Proper validation using real sampler execution

Technical Details

  • Layout Plugin: Converts Qiskit DAG to Quariadne's internal representation, solves MILP optimisation, and returns optimal qubit layout
  • Routing Plugin: Uses MILP-determined SWAP operations from the layout stage and applies them layer-by-layer to the circuit

The routing plugin depends on results from the layout plugin, making them inseparable.

Requirements

  • Python >=3.13
  • Qiskit >=2.0.1
  • Backend with defined coupling map
  • Both plugins must be used together in the same pass manager
  • Test circuits should be small (< 50 gates, < 5 qubits)
  • Use real samplers for proper testing validation

For more details on Qiskit transpiler plugins, refer to the Qiskit Transpiler Documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quariadne-1.0.0.tar.gz (14.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quariadne-1.0.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file quariadne-1.0.0.tar.gz.

File metadata

  • Download URL: quariadne-1.0.0.tar.gz
  • Upload date:
  • Size: 14.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for quariadne-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cde201f664c2608d692b1e55e9531941d6887d69ec8513a766f2f177c18d909c
MD5 6fd28e3bd916931b0fcb61b981ff9b5c
BLAKE2b-256 fbdb13814f28b893c4d2febbfe5b3ed379aa68bf6e06e899ed8ef65e907057b8

See more details on using hashes here.

File details

Details for the file quariadne-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: quariadne-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for quariadne-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b216239c5a8afc63aae9327003d3e7630448ff09e353e06719facc038002cb05
MD5 18d81261a4f651cabc539bfdce924527
BLAKE2b-256 7c4ea92705c479d697ddadb743e959123bf21e3935bf33e52083c4e5b980a867

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page