pdft#
Learning parametric quantum Fourier transforms via manifold optimization, in JAX.
pdft approximates the discrete Fourier transform with a trainable,
parameterized quantum circuit and optimizes it on the unitary manifold so an
image becomes sparse in the learned basis. It is a faithful Python port of
ParametricDFT.jl, with results
checked against committed Julia goldens, and the reference implementation for
the paper Fast Trainable Multilinear Bases for Image Compression.
Bases, Riemannian optimizers, losses, training loops, I/O and coherence tools, generated from the source docstrings.
Short runnable scripts that train bases and compare optimizers, with their loss curves rendered at build time.
The arXiv paper this package accompanies, and the BibTeX entry to cite it.
Installation#
From PyPI (Python 3.11+):
pip install "pdft>=0.2.3"
Note: the older
pdft==0.2.2wheel predatesDCT4Basisand theparametrization="u4"option ofTEBDBasis/MERABasis, so it cannot run the paper’s DCT-IV, TEBD-U4, or MERA-U4 configurations. Ifpdft.__version__reports0.2.2, upgrade withpip install -U pdft.
From source:
git clone https://github.com/zazabap/pdft.git
cd pdft
pip install -e ".[dev]"
Optional extras: pdft[plot] adds matplotlib for the plotting helpers in
pdft.viz, and pdft[gpu] installs a CUDA 12 build of JAX.
Note
Importing pdft turns on JAX’s 64-bit mode for the whole process. Julia
parity depends on complex128 arithmetic, so import pdft before you create
any JAX arrays.
Quick start#
Train a parametric QFT basis on a target image with Riemannian gradient descent:
import jax
import jax.numpy as jnp
import pdft
target = jax.random.normal(jax.random.PRNGKey(7), (4, 4)).astype(jnp.complex128)
basis = pdft.QFTBasis(m=2, n=2)
result = pdft.train_basis(
basis,
target=target,
loss=pdft.L1Norm(),
optimizer=pdft.RiemannianGD(lr=0.01),
steps=50,
seed=0,
)
print(result.loss_history[0], "->", result.loss_history[-1])
What’s in the package#
Area |
Contents |
|---|---|
Circuit bases |
|
Block bases |
|
Optimizers |
|
Losses |
|
Training |
|
Coherence |
|
I/O |
|