Efficient, parallelized computation of the matrix permanent and its gradient for photonic quantum computing simulations, supporting both CPU and GPU execution.
PermanentBoost is a high-performance Python library for computing the permanent function and its gradient — a key component in simulating photonic quantum circuits like Boson Sampling. The library provides optimized CPU and CUDA-enabled GPU backends and integrates seamlessly with machine learning frameworks like JAX.
It is implemented in C++/CUDA and exposed via Python using pybind11
and XLA FFI bindings for full interoperability with JAX.
- 🔬 Efficient matrix permanent computation
- 🔁 Gradient support for use in QML
- ⚡ CPU & GPU acceleration
- 🧪 Comprehensive test suite
- 🧩 PyQt5 GUI included for demonstration
- 📦 Easy installation via pip
- 🔄 JAX-compatible bindings for auto-diff workflows
- Python 3.10 / 3.11 / 3.12
- pip
- OpenMP (Linux/macOS) or equivalent
- Optional: NVIDIA GPU with CUDA support
git clone https://github.com/0xSooki/permanent-boost
cd permanent-boost
pip install .
To use the GPU backend:
pip install "jax[cuda12]"
from permanent import perm
import numpy as np
A = np.array([...], dtype=np.complex128)
rows = np.array([1, 1, 1], dtype=np.uint64)
cols = np.array([1, 1, 1], dtype=np.uint64)
# Compute permanent
result = perm(A, rows, cols)
import jax
from permanent import perm
grad_fn = jax.grad(perm, holomorphic=True)
gradient = grad_fn(A, rows, cols)
Run the PyQt5 interface for demonstration:
python app/main.py
- GPU implementation outperforms CPU and existing libraries at matrix sizes ≥ 11
- Gradient computation shows significant speedup on CUDA-enabled devices
pytest # Run tests
pytest --platform=gpu # Run GPU-specific tests
CI/CD pipelines are configured via GitHub Actions. Wheels are built for macOS, Windows, and Linux.
This project is licensed under the MIT License.
If you use this library in academic work, please cite the corresponding bachelor thesis:
Bence Soóki-Tóth. "Efficient calculation of permanent function gradients in photonic quantum computing simulations", Eötvös Loránd University, 2025.