Skip to content

grageragarces/DQopt

Repository files navigation

Distributed Quantum Circuit Optimisation

Code accompanying the paper "Distributed Quantum Circuit Optimisation: Evaluating Global and Local Encodings"

This repository contains the compilation pipeline, analysis scripts, and pre-computed results used to study how the ordering of circuit optimisation and hypergraph partitioning affects gate counts and communication cost when distributing quantum circuits across multi-QPU networks.


Note: this README was generated by Claude


Repository structure

File Description
main.py Main pipeline — loads .qasm circuits from ./MQT/, partitions them with KaHyPar, and evaluates four compilation strategies across QPU counts k = 2…10. Results are written to results_telegate.csv.
analysis.py Generates all exploratory SVG figures from results_telegate.csv into ./figures/.
analysis_paper.py Generates publication-ready SVGs sized for a single IEEE column into ./figures_paper/.
results_telegate.csv Pre-computed results used in the paper.
MQT/ Input circuits — application benchmarks from MQT Bench, in .qasm format.

Compilation model

Quantum circuits are modelled as hypergraphs:

  • Vertices = qubits
  • Hyperedges = multi-qubit gates (single-qubit gates are ignored); 3-qubit gates produce size-3 hyperedges and are not decomposed into pairwise interactions

Communication cost (telegate cost) = number of cross-partition multi-qubit gates. Each such gate is assumed to be implemented via a distributed gate protocol consuming shared entanglement (ebits); one cross-partition 2-qubit gate costs 1 ebit.

Optimisation is Qiskit's hardware-agnostic transpile(optimization_level=3) with no backend target — gate-count reduction without constraining to any device topology.

Partitioning uses KaHyPar minimising the km1 (connectivity − 1) objective with 3 % imbalance tolerance.

QPUs tested: k = 2 … min(10, n_qubits).


Compilation strategies

Four strategies are evaluated per (circuit, k) pair:

Strategy key Description
global Optimise the full circuit → KaHyPar partition → telegate sub-circuits
local KaHyPar partition on original → telegate sub-circuits → optimise each sub-circuit
hybrid Optimise the full circuit → KaHyPar partition → re-optimise each sub-circuit
nonopt KaHyPar partition on original → telegate sub-circuits (no optimisation — per-partition baseline)

global and hybrid share the same partitioning step and therefore always produce the same telegate cost; hybrid adds a second per-partition optimisation pass that can further reduce local gate counts.


Getting started

Requirements: Python 3.10+

python -m venv .venv
source .venv/bin/activate   # or .venv/bin/activate.fish
pip install qiskit numpy pandas matplotlib scipy kahypar

KaHyPar requires a .ini configuration file. The pipeline searches several locations automatically; set KAHYPAR_CONFIG=/path/to/km1_kKaHyPar_sea20.ini to override.

Run the pipeline (writes results_telegate.csv; resumes automatically if interrupted):

python main.py

Run the test suite:

python main.py --test

Generate exploratory figures (saved as SVG to ./figures/):

python analysis.py
# or, with a custom CSV path:
python analysis.py path/to/results_telegate.csv

Generate paper figures (saved as SVG to ./figures_paper/):

python analysis_paper.py

Output

results_telegate.csv columns:

Column Description
algorithm_name Circuit name (from filename stem)
num_qubits Number of qubits in the circuit
original_2q_gate_count 2Q gate count before any processing
original_1q_gate_count 1Q gate count before any processing
original_3q_gate_count 3Q gate count before any processing
original_depth Circuit depth before any processing
method Compilation strategy (global, local, hybrid, nonopt)
num_qpus_tested Number of QPUs (k)
telegate_cost Cross-partition multi-qubit gate count (= ebits needed)
cross_partition_3q_gates Cross-partition 3-qubit gate count specifically
partition_balance (max − min partition size) / avg; 0 = perfectly even
avg_2q_gates_per_partition Mean 2Q gates per sub-circuit
avg_1q_gates_per_partition Mean 1Q gates per sub-circuit
avg_3q_gates_per_partition Mean 3Q gates per sub-circuit
avg_depth_per_partition Mean circuit depth per sub-circuit
avg_total_gates_per_partition Mean total gates per sub-circuit
2q_gates_partition_{A…J} Per-partition 2Q gate counts
qubits_partition_{A…J} Per-partition qubit counts
time_sec Wall-clock time for this (circuit, k, method) combination

Figures produced by analysis.py

Figure Description
fig1_avg_2q*.svg Average 2Q gates per partition vs circuit size
fig1b_avg_1q*.svg Average 1Q gates per partition vs circuit size
fig1c_avg_depth*.svg Average circuit depth per partition vs circuit size
fig1d_avg_3q*.svg Average 3Q gates per partition vs circuit size (skipped if no 3Q data)
fig2_comm_cost*.svg Communication cost (telegates) vs circuit size
fig2b_cross_3q.svg Cross-partition 3Q gate count vs circuit size
fig3_gate_reduction_vs_comm*.svg 2Q gate reduction vs communication cost (scatter)
fig_drivers_comm_cost_pct.svg Partial-R² stacked bars — drivers of telegate cost
fig_drivers_computation_pct.svg Partial-R² stacked bars — drivers of 2Q gate reduction
fig4_time_vs_size.svg Execution time vs circuit size (linear Y)
fig4_time_vs_size_log.svg Execution time vs circuit size (log Y)
fig4_time_overhead.svg Execution time normalised to non-optimised baseline
timing_summary.csv Mean/median/std timing summary per method

Citation

If you use this code or data, please cite the accompanying paper:

@inproceedings{grageragarces2026distqc,
  title     = {Distributed Quantum Circuit Optimisation: Evaluating Global and Local Encodings},
  author    = {Gragera Garces, Maria},
  year      = {2026},
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors