Skip to main content

Optimal Circuit Layout Synthesis, CNOT (Re)Synthesis, and Clifford (Re)Synthesis, based on Classical Planning, SAT, and QBF Solving

Project description

Quantum-Circuit Synthesis - Q-Synth v5.1

A state-of-the-art open-source optimal quantum circuit synthesis tool. This tool provides three main synthesis options Layout Synthesis, CNOT (Re)Synthesis, and Clifford (Re)Synthesis.

Key Features

  • Layout Synthesis with Classical Planning and SAT for optimizing CNOT-count/-depth (v1.0, v2.0, v4.0).
  • Layout aware CNOT (Re)Synthesis with Planning, SAT and QBF optimizing CNOT-count/-depth (v3.0).
  • Layout aware CNOT-Optimal Clifford Synthesis as SAT (v5.0).
  • Scalable layout synthesis for large platforms via maximal subarchitectures (v4.0).
  • All efficient synthesis features based on SAT are available via API (with easy PyPi installation, v5.1).
  • Additional features with planning and QBF are available via command line interface.

Getting started

Q-Synth can be installed via pypi (url):

python3 -m pip install Q-Synth

Recommended: Please use a fresh python virtual environment.

Layout Synthesis

For layout synthesis simply call layout_synthesis with your circuit (as a qiskit QuantumCircuit) and a coupling graph as input. For example:

from qsynth import get_coupling_graph, layout_synthesis
from qiskit import QuantumCircuit

# An example bidirectional coupling graph
coupling_graph = get_coupling_graph(coupling_graph=[[0,1],[1,2]], bidirectional=1)

qc = QuantumCircuit(3)
qc.cx(0,1)
qc.s(0)
qc.cx(0,2)
qc.cx(1,2)

mapped_result = layout_synthesis(circuit=qc, coupling_graph=coupling_graph, metric="cx-count", verbose=-1) # silent mode
print(mapped_result.circuit)
print(mapped_result.final_mapping)

mapped_result.circuit contains the mapped circuit with provably optimal swap count, and mapped_result.final_mapping stores the output qubit permutation.

Peephole Synthesis with CNOT and Clifford (Re)Synthesis

Q-Synth can resynthesize CNOT/Clifford sub-circuits in a peephole manner to further optimize the CNOT count or depth, while still respecting the layout constraints.

For example, we can easily resynthesize our mapped result circuit using peephole synthesis with CNOT slicing using:

from qsynth import peephole_synthesis
opt_result = peephole_synthesis(circuit=mapped_result.circuit, coupling_graph=coupling_graph, slicing="cnot", metric="cx-count")

opt_result.circuit contains the resynthesized circuit with 5 CNOTs instead of 6 without any extra single qubit gates.

Using Clifford slicing allows resynthesis of larger sub-circuits with possible further reductions. Simply using slicing="clifford" in the peephole_synthesis call enables this.

opt_result = peephole_synthesis(circuit=mapped_result.circuit, coupling_graph=coupling_graph, slicing="clifford", metric="cx-count")

opt_result.circuit now only has 4 CNOTs, but with extra single qubit gates.

Q-Synth also supports several other features such as optimizing for CNOT depth, using subarchitectures, qubit permutations, and more. Please refer to tutorials in (Jupyter Notebook) for more examples.

For optional features via command line with classical planning and QBF solvers, please see the Installation Instructions. Detail descriptions are available in README_layout.md, README_cnot.md, README_clifford.md pages.

Publications

Please refer to this publication for Layout-Synthesis based on classical-planning (v1.0):

I. Shaik, J. van de Pol, Optimal Layout Synthesis for Quantum Circuits as Classical Planning. In: Proc. IEEE/ACM IC on Computer-Aided Design, (ICCAD'23), San Francisco, California, USA, 2023.

@inproceedings{ShaikvdP2023,
  author       = {Irfansha Shaik and Jaco van de Pol},
  title        = {Optimal Layout Synthesis for Quantum Circuits as Classical Planning},
  booktitle    = {{ICCAD'23}},
  address      = {{San Diego, California, USA}},
  organization = {{IEEE/ACM}},
  year         = {2023}
}

Please refer to this publication for Layout-Synthesis based on SAT encoding (v2.0):

I. Shaik, J. van de Pol, Optimal layout synthesis for deep quantum circuits on NISQ processors with 100+ qubits.

@article{shaikvdP2024layoutsynthesis,
  author       = {Irfansha Shaik and Jaco van de Pol},
  title        = {Optimal Layout Synthesis for Deep Quantum Circuits on {NISQ} Processors with 100+ Qubits}, 
  booktitle    = {27th International Conference on Theory and Applications of Satisfiability
                  Testing, {SAT} 2024, August 21-24, 2024, Pune, India},
  series       = {LIPIcs},
  publisher    = {Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik},
  year         = {2024}
}

Please refer to this publication for CNOT synthesis (based on Planning, SAT and QBF) (v3.0):

I. Shaik, J. van de Pol, Optimal Layout-Aware CNOT Circuit Synthesis with Qubit Permutation. In: Proc. 27th European Conference on Artificial Intelligence, (ECAI'24), Santiago de Compostela, Spain, 2024.

@inproceedings{ShaikvdP2024cnotsynthesis,
  author       = {Irfansha Shaik and Jaco van de Pol},
  title        = {Optimal Layout-Aware CNOT Circuit Synthesis with Qubit Permutation},
  booktitle    = {{ECAI'24}},
  address      = {{Santiago de Compostela, Spain}},
  publisher    = {IOS Press},
  year         = {2024}
}

Please refer to this publication for Depth-Optimal Synthesis (v4.0): A. B. Clausen, A. B. Jakobsen, J. van de Pol, I. Shaik, Depth-Optimal Quantum Layout Synthesis as SAT.

@article{Jakobsen2025depthoptimal,
  author       = {Anna Blume Jakobsen, Anders Benjamin Clausen, Jaco van de Pol and Irfansha Shaik},
  title        = {Depth-Optimal Quantum Layout Synthesis as SAT},
  booktitle    = {28th International Conference on Theory and Applications of Satisfiability
                  Testing, {SAT} 2025, August 12-15, 2025, Glasgow, Scotland},
  series       = {LIPIcs},
  publisher    = {Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik},
  year         = {2025}
}

Depth-Optimal Synthesis was ported from GitHub repository.

Please refer to this publication for Sub-Architectures (v4.0): K. Milkevych, J. van de Pol, I. Shaik, Practical Subarchitectures for Optimal Quantum Layout Synthesis.

@mastersthesis{Milkevych2025subarchitectures,
  title         = {Practical Subarchitectures for Optimal Quantum Layout Synthesis},
  school        = {Aarhus University},
  author        = {Kostiantyn V. Milkevych and Jaco van de Pol and Irfansha Shaik},
  eprint        = {2507.12976},
  archivePrefix = {arXiv},
  primaryClass  = {quant-ph},
  year          = {2025}
}

Please refer to this publication for CNOT-Optimal Clifford synthesis (v5.0):

I. Shaik, J. van de Pol, CNOT-Optimal Clifford Synthesis as SAT.

@article{shaikvdP2025cliffordsynthesis,
  author       = {Irfansha Shaik and Jaco van de Pol},
  title        = {CNOT-Optimal Clifford Synthesis as SAT},
  booktitle    = {28th International Conference on Theory and Applications of Satisfiability
                  Testing, {SAT} 2025, August 12-15, 2025, Glasgow, Scotland},
  series       = {LIPIcs},
  publisher    = {Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik},
  year         = {2025}
}

Limitations

The input should only contain unary gates and binary CNOT gates. We currently do not handle multiple quantum registers in the input circuit.

The scripts are tested on Linux and macOS.

Copyright

(C) CC-BY Irfansha Shaik, Jaco van de Pol, Aarhus University, 2023, 2024, 2025

Contributors

  • Irfansha Shaik (Aarhus University, Kvantify)
  • Jaco van de Pol (Aarhus University)
  • Anna Blume Jakobsen (depth-optimal layout mapping)
  • Anders B. Clausen (depth-optimal layout mapping)
  • Kostiantyn Milkevych (subarchitectures, testing)

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

q_synth-5.0.17.tar.gz (125.1 kB view details)

Uploaded Source

Built Distribution

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

q_synth-5.0.17-py3-none-any.whl (165.4 kB view details)

Uploaded Python 3

File details

Details for the file q_synth-5.0.17.tar.gz.

File metadata

  • Download URL: q_synth-5.0.17.tar.gz
  • Upload date:
  • Size: 125.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for q_synth-5.0.17.tar.gz
Algorithm Hash digest
SHA256 78d28fb212aca54c66c19afb25e771a15bbb4c6d9d5c63d3cf6bea850bc2907b
MD5 18d34fe500327515034b2940a3d2472c
BLAKE2b-256 ad5a0d5583edff06589ce34b7a2c8ab16dfb0339b6b73efe4a531f4cf973c528

See more details on using hashes here.

File details

Details for the file q_synth-5.0.17-py3-none-any.whl.

File metadata

  • Download URL: q_synth-5.0.17-py3-none-any.whl
  • Upload date:
  • Size: 165.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for q_synth-5.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3a520051c218d78c2d80ab780541db8a548af2fe3dfd09d4a6c770ed6e86c1
MD5 e083fdc2423c92d147969e4286f85963
BLAKE2b-256 71ade045ec7ef939b9ae6e100fdc9102908cadbd22db38e2a2fbfdb5ee25ddfa

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