Skip to main content

C++ library with Python interface to train quantum circuits, quantum gate synthesis and state preparation.

Project description

DOI

SQUANDER Logo

Sequential Quantum Gate Decomposer (SQUANDER)

A High-Performance C++/Python Library for Quantum Circuit Decomposition and Optimization

InstallationDocumentationFeaturesCitation


Overview

The Sequential Quantum Gate Decomposer (SQUANDER) is a state-of-the-art computational library designed for training parametric quantum circuits and performing quantum gate synthesis. SQUANDER provides a comprehensive Python interface that enables researchers and developers to conduct advanced numerical experiments in quantum computing, including quantum gate synthesis, variational quantum eigensolver (VQE) applications, and quantum state preparation.

Key Capabilities

SQUANDER excels in decomposing n-qubit unitaries into sequences of one-qubit rotations and two-qubit controlled gates using advanced synthesis methods. The library leverages a high-performance parallel C/C++ framework with gate fusion and vectorized AVX gate kernels, delivering exceptional computational efficiency for quantum circuit simulations.

Optimization Techniques

Beyond conventional gradient-based optimizers (gradient descent, ADAM, and BFGS), SQUANDER incorporates an innovative gradient-free optimization technique that demonstrates robust numerical behavior and is particularly effective in circumventing barren plateaus—a common challenge in quantum circuit training. The library's handcrafted optimization strategies are specifically designed to accommodate the periodicity inherent in quantum optimization landscapes, ensuring resilient numerical efficiency.


Installation

SQUANDER is available as pre-built Python wheels for Windows, Linux, and macOS, making installation straightforward for most users. The package can be installed directly from the Python Package Index (PyPI):

pip install squander

System Requirements

  • Python: 3.10 or higher (tested with Python 3.10-3.13)
  • Operating Systems: Windows, Linux, macOS

Python Dependencies

The following packages are automatically installed as dependencies:


Development Installation

For developers who wish to build SQUANDER from source or contribute to the project, the following development installation instructions are provided.

Prerequisites

The following dependencies are required to compile and build SQUANDER from source:

Build Tools

Libraries

Optional Tools

  • Doxygen (for generating documentation)
  • Ninja (speeds up compilation)

Development Build on Unix/Linux/macOS

1. Clone the Repository

git clone https://github.com/rakytap/sequential-quantum-gate-decomposer.git
cd sequential-quantum-gate-decomposer

2. Set Up Environment Variables (if needed)

If TBB is installed at a non-standard location or using GNU compiler:

export TBB_LIB_DIR=path/to/TBB/lib(64)
export TBB_INC_DIR=path/to/TBB/include

Note: When TBB is installed via the tbb-devel Python package, these environment variables are not necessary.

3. Build from Source

The SQUANDER package uses a Python build script (setup.py) that automatically detects the CBLAS library used by NumPy and configures CMake accordingly:

python3 setup.py build_ext

This command compiles the SQUANDER C++ library and builds the Python interface extensions in place.

4. Install in Development Mode

After a successful build, install the package in editable (development) mode:

python -m pip install -e .

Development Build with Conda (Recommended)

We recommend using Anaconda/Miniconda for development environments:

1. Create Environment from Configuration File

conda env create -f conda_env_example.yaml

2. Activate Environment

conda activate qgd

3. Build and Install

python3 setup.py build_ext
python -m pip install -e .

Development Build on Windows

Prerequisites

  • CMake must be in the system PATH
  • Microsoft Visual C++ compiler

Build Steps

set PATH=%PATH%;C:\Program Files\cmake\bin

set TBB_LOCATION=<Python_Folder>/LocalCache/local-packages
set TBB_INC_DIR=%TBB_LOCATION%/Library/include
set TBB_LIB_DIR=%TBB_LOCATION%/Library/lib
set LIB=<BLAS_Location>/lib;<LAPACK_Location>/lib

python setup.py build_ext -DTBB_HEADER=<TBB_Location>\Library\include\

Install DLL Files

Copy required DLL files to the package directory:

copy "%TBB_LOCATION%\Library\bin\tbb12.dll" .\squander\decomposition
copy "%TBB_LOCATION%\Library\bin\tbbmalloc.dll" .\squander\decomposition

Verify Installation

python -m pytest

Building Distribution Packages

Binary Wheel Distribution

To build a wheel binary for distribution:

python3 setup.py bdist_wheel

The wheel will be created in the dist/ directory. Note that the created wheel is not portable, as it contains hard-coded links to external libraries (TBB and CBLAS).

Source Distribution

To create a portable source distribution:

python3 setup.py sdist

The source distribution tarball will be created in the dist/ directory.


Features

SQUANDER provides a comprehensive suite of tools for quantum circuit manipulation and optimization:

Core Functionality

  • Unitary Decomposition: Decompose unitaries into quantum circuits using multiple methods:

    • Standard decomposition (N_Qubit_Decomposition)
    • Adaptive decomposition with circuit compression (N_Qubit_Decomposition_adaptive)
    • Custom topology decomposition (N_Qubit_Decomposition_custom)
    • Tree search decomposition (N_Qubit_Decomposition_Tree_Search)
    • Tabu search decomposition (N_Qubit_Decomposition_Tabu_Search)
  • Circuit Optimization: Optimize wide quantum circuits using the Wide_Circuit_Optimization class

  • State Preparation: Prepare quantum states via adaptive state preparation (N_Qubit_State_Preparation_adaptive)

  • Variational Quantum Algorithms:

    • Variational Quantum Eigensolver (VQE) (Variational_Quantum_Eigensolver)
    • Generative Quantum Machine Learning (GQML) (Generative_Quantum_Machine_Learning)
  • Circuit Simulation: High-performance state vector evolution for quantum circuit simulation

  • Circuit Synthesis: SABRE algorithm for qubit routing and mapping

  • Circuit Partitioning: Partition large circuits for efficient decomposition and optimization

  • Qiskit Integration: Seamless integration with Qiskit through the Qiskit_IO module


Python Interface

SQUANDER exposes its C++ functionality through a comprehensive Python interface. The main modules include:

Module Description
squander.decomposition Quantum gate decomposition classes for decomposing unitaries and preparing quantum states
squander.gates Quantum gate implementations and circuit building blocks (CNOT, H, RX, RY, RZ, and custom gates)
squander.VQA Classes for VQE and generative quantum machine learning algorithms
squander.synthesis Circuit synthesis tools including SABRE algorithm for qubit routing and mapping
squander.partitioning Circuit partitioning utilities for breaking down large circuits into manageable sub-circuits
squander.IO_interfaces Input/output interfaces including Qiskit integration (Qiskit_IO)
squander.utils Utility functions for working with quantum circuits and unitaries
squander.nn Experimental neural network interface for quantum machine learning

Example Usage

Comprehensive examples demonstrating SQUANDER's capabilities are available in the examples/ directory:

  • examples/decomposition/: Examples of unitary decomposition with various methods
  • examples/VQE/: Variational quantum eigensolver examples
  • examples/state_preparation/: Quantum state preparation examples
  • examples/simulation/: Quantum circuit simulation benchmarks
  • examples/partitioning/: Circuit partitioning examples

Additional usage patterns and test cases can be found in the tests/ directory.


Documentation

Comprehensive documentation for the SQUANDER package is available at:

CodeDocs[xyz]


Citation

If you use SQUANDER in your research, please cite the following publications:

[1] Péter Rakyta, Zoltán Zimborás, Approaching the theoretical limit in quantum gate decomposition, Quantum 6, 710 (2022).
[2] Péter Rakyta, Zoltán Zimborás, Efficient quantum gate decomposition via adaptive circuit compression, arXiv:2203.04426.
[3] Peter Rakyta, Gregory Morse, Jakab Nádori, Zita Majnay-Takács, Oskar Mencer, Zoltán Zimborás, Highly optimized quantum circuits synthesized via data-flow engines, Journal of Computational Physics 500, 112756 (2024).
[4] Jakab Nádori, Gregory Morse, Barna Fülöp Villám, Zita Majnay-Takács, Zoltán Zimborás, Péter Rakyta, Batched Line Search Strategy for Navigating through Barren Plateaus in Quantum Circuit Training, Quantum 9, 1841 (2025).


Acknowledgments

This project was supported by:

  • Grant OTKA PD123927
  • The Ministry of Innovation and Technology and the National Research, Development and Innovation Office within the Quantum Information National Laboratory of Hungary

Contact

For questions, support, or collaboration inquiries, please contact:


License

SQUANDER is licensed under the Apache License 2.0. See the LICENSE file for details.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

squander-1.9.6-cp313-cp313-win_amd64.whl (10.3 MB view details)

Uploaded CPython 3.13Windows x86-64

squander-1.9.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (26.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

squander-1.9.6-cp313-cp313-macosx_15_0_arm64.whl (10.0 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

squander-1.9.6-cp312-cp312-win_amd64.whl (10.3 MB view details)

Uploaded CPython 3.12Windows x86-64

squander-1.9.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (26.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

squander-1.9.6-cp312-cp312-macosx_15_0_arm64.whl (10.0 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

squander-1.9.6-cp311-cp311-win_amd64.whl (10.3 MB view details)

Uploaded CPython 3.11Windows x86-64

squander-1.9.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (26.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

squander-1.9.6-cp311-cp311-macosx_15_0_arm64.whl (10.0 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

squander-1.9.6-cp310-cp310-win_amd64.whl (10.3 MB view details)

Uploaded CPython 3.10Windows x86-64

squander-1.9.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (26.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

squander-1.9.6-cp310-cp310-macosx_15_0_arm64.whl (10.0 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file squander-1.9.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: squander-1.9.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 10.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for squander-1.9.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 715c14be9a935ea8d90e8c6933bba153c71a84a1c234945160329bfda90fc99b
MD5 a9c678145e4188c2aae5a52a7ed8c19a
BLAKE2b-256 f249ded6e508c4454878ca80b3c7977af8a74950746fe8d56a3d18415c4b9924

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe229ae73c8d8329f4b7571eedb3ba5611a54758f2a6c08256a6d96009d66e68
MD5 d7579375416d1409c78bbaa37f91292d
BLAKE2b-256 a457c2ce90ab5cb0cbc2dbf7f1f5e89a32339fd6803ce0fb93ea38c90d9b3817

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8122521bf5ad58d4315370df0966389889e8c9bcae5941db3b917254f4ab68f2
MD5 8703496b9f468c524969564befbe514a
BLAKE2b-256 9a4520db659fc82bf53a1f2e000ad83443d75561d3b86c0c2016a8b378b87ce7

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: squander-1.9.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 10.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for squander-1.9.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ca5b715b5706291cb0932835aac3cf55e1f5a23f1e79664db2df73512b362882
MD5 f11e0e5f1545d1ee3982fdc6e1ec6b47
BLAKE2b-256 ec41dc084957b0f9018b38dfbfc7d8aca4e42338555d69338dff7a7b02b82b10

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f56e3c1166de6cae7553df1b763090946a0b09ef8979e962b94c62df28729e05
MD5 937bf6cac551fb3c66ec78fb686fc48d
BLAKE2b-256 cf2ecbbe7b155bcc33676f7d551888691ead2bd30995ccc69da163dbdf476727

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9d13a92cb00633c532cccfdd479d6188edab6179b92ccf51e620e8f5d58b5fed
MD5 04caf4bb7e1031711698db0dd910c34b
BLAKE2b-256 ad0f87848cdc4ef0e4751b1c552a96c306bc4a6e51271abf3c5d37fa8a357334

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: squander-1.9.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 10.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for squander-1.9.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4defce7ea0283c218e005100aaf03150ae6e158eb08b112e11d32472d1ba9ff7
MD5 5efddb5f17ae18a9d634c7cbaf4ee032
BLAKE2b-256 9cc3fb34021615080d0123b676ae87a606d4c017aaa049b706fd02db4c9961ae

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f94ea972ce4cfc6b25bd11b529029b7832abc7809dfdc3b6b12fd8fe22512046
MD5 5cc9562785062b99dd947d3d79db31ea
BLAKE2b-256 6c241fd1c5d1bb3e94e15e6409f7195405699030cceeebc407607b50376230e2

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f26b728a4f7e21c388b944e763fcc765615b8544acd93286a2b89f5ca45e59c9
MD5 1c0125f17561ae49bd4eb8624ee27994
BLAKE2b-256 4b15985b36e1cb7a7dd6bf214e78a2ef2a64e3997e3a0156ed4645e099c3a82c

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: squander-1.9.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 10.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for squander-1.9.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fcc69d0cc50c61e3a928e0cf12da84eed6938192838fd6699c1a548875426c03
MD5 dafe6a1eeb78bbad1eff9ce39e5de63e
BLAKE2b-256 9a56d2643389ffb6a994ac23a8c06e53a0edd609e40a30088d45de5175f14272

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 341e6a9ccca46072cda3a6beb5e15442706b8df2147d917db21bd2482daf878d
MD5 5fa90279eb33c9c260fc91c332ee0d57
BLAKE2b-256 27d2b3c175ab6251fe65dece034f3cc211acbedb5686c6c5f8664a3bc9a26372

See more details on using hashes here.

File details

Details for the file squander-1.9.6-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for squander-1.9.6-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a9b9b75150f95178321359af08d6386e85b998edcdc5aae9730920d7dbea27e0
MD5 1a161163ffb4dd2bcd16b84687bf392c
BLAKE2b-256 3b26ea4bcb3ea4f437b9552212beb9d55e9d8245c8e352a408ade6562506cdc4

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