Pauli LCU
Pauli LCU is a package for calculating the Pauli Decomposition of a complex matrix $A=\{a_{r,s}\}_{r,s=0}^{2^{n}-1}$:
A=\sum_{r,s=0}^{2^n-1} \alpha_{r,s} \bigotimes_{j=0}^{n-1} P(r_j, s_j)
where
\alpha_{r,s}\coloneqq \frac{i^{-|r\wedge s|}}{2^n} \sum_{q=0}^{2^n-1}a_{q\oplus r,q}(H^{\otimes n})_{q,s}, \qquad P(r_j, s_j) = i^{r_j\wedge s_j} X^{r_j} Z^{s_j} \in \{I, X, Y, Z\},
and $r_j, s_j$ are the binary expansion coefficients of $r$ and $s$, according to the algorithm presented in "Timothy N. Georges, Bjorn K. Berntson, Christoph Sünderhauf, and Aleksei V. Ivanov, Pauli Decomposition via the Fast Walsh-Hadamard Transform, https://doi.org/10.48550/arXiv.2408.06206, (2024)."
Installation
To install from PyPi:
$ pip install pauli_lcu
To install Python bindings from source:
$ git clone git@github.com:riverlane/pauli_lcu.git
$ cd pauli_lcu
$ pip install .
For use in C, pauli_decomposition.h can be used as a stand-alone library.
Windows is not currently supported. In this case, we recommend to use WSL or Linux VM.
Examples for Python
Compute Pauli coefficients of a matrix:
>>> import numpy as np
>>> from pauli_lcu import pauli_coefficients
>>> num_qubits = 1
>>> dim = 2 ** num_qubits
>>> matrix = np.arange(dim*dim).reshape(dim, dim).astype(complex) # generate your matrix
>>> pauli_coefficients(matrix) # calculate coefficients, stored in matrix, original matrix is overwritten
>>> matrix
array([[ 1.5+0.j , -1.5+0.j ],
[ 1.5+0.j , 0. -0.5j]])
One can also obtain the corresponding Pauli strings:
>>> from pauli_lcu import pauli_strings
>>> strings = pauli_strings(num_qubits) # calculate Pauli strings
>>> for p_string, p_coeff in np.nditer([strings, matrix]):
... print(p_string, p_coeff)
...
I (1.5+0j)
Z (-1.5+0j)
X (1.5+0j)
Y -0.5j
For large matrices generating all Pauli strings is memory expensive. In this case, one can access a Pauli string as follows:
>>> from pauli_lcu import pauli_string_ij
>>> it = np.nditer(matrix, flags=['multi_index'])
>>> for x in it:
... print(pauli_string_ij(it.multi_index, num_qubits), x)
I (1.5+0j)
Z (-1.5+0j)
X (1.5+0j)
Y -0.5j
If you would like to access the array and Pauli strings in lexicographical order (eg $II$, $IX$, ...) then you can do:
>>> from pauli_lcu import lex_indices
>>> for id in range(dim**2):
... mult_ind = lex_indices(id)
... print(pauli_string_ij(mult_ind, num_qubits), matrix[mult_ind])
I (1.5+0j)
X (1.5+0j)
Y -0.5j
Z (-1.5+0j)
Alternatively, you can use pauli_lcu.pauli_coefficients_lexicographic()
which uses extra memory to return lexicographically ordered coefficients.
If you would like to restore original matrix elements apply inverse Pauli decomposition:
>>> from pauli_lcu.decomposition import inverse_pauli_decomposition
>>> inverse_pauli_decomposition(matrix)
>>> matrix
array([[0.+0.j, 1.+0.j],
[2.+0.j, 3.+0.j]])
However, keep in mind that if you used pauli_lcu.pauli_coefficients_lexicographic(),
you can't use inverse_pauli_decomposition since it's not implemented for lexicographically ordered arrays.
We also added ZX-decomposition which can be used in Qiskit (you need it to install qiskit for this example):
>>> from pauli_lcu.decomposition import pauli_coefficients_xz_phase
>>> x, z, phase = pauli_coefficients_xz_phase(matrix)
>>> x
array([[0],
[1],
[0],
[1]], dtype=int8)
>>> from qiskit.quantum_info import PauliList
>>> PauliList.from_symplectic(z, x)
PauliList(['I', 'Z', 'X', 'Y'])
References
If you find this package useful please cite our paper:
Timothy N. Georges, Bjorn K. Berntson, Christoph Sünderhauf, and Aleksei V. Ivanov, Pauli Decomposition via the Fast Walsh-Hadamard Transform, New J. Phys. 27 033004 (2025), https://doi.org/10.1088/1367-2630/adb44d.
Metadata
Release files for pauli-lcu 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pauli_lcu-1.0.1.tar.gz | 10.7 kB | With provenance | Details |
Built distributions (wheels)
Total release size: 201.8 kB
Release files / pauli_lcu-1.0.1.tar.gz
| Download URL | pauli_lcu-1.0.1.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
231cdd3a4df26926f246444538094cb173ea9d3ea94a2aaff394226c39bdf1c9
|
|
BLAKE2b-256 checksum How to use checksums |
9f9a8778524f755e8ee22621b6690985501d6a690b1f75140215afc71b52bd86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pauli_lcu-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 33.3 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
01ddcc861338635703a76f7085ccf372d3c29a488fd4d717ac578212c2d9139f
|
|
BLAKE2b-256 checksum How to use checksums |
f59d7dab02f5d9c1021cd83e1cca8c697a41c7407931521b8b4f642a02f6ca52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pauli_lcu-1.0.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 15.2 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
50a28a92247a844a26311311ed978a3fed442f5d98816d7fa2c2b5127de7f158
|
|
BLAKE2b-256 checksum How to use checksums |
7bda930a8dc35ec8fb2a5282be3155a24e99cf8cc80021243d4af8b41ded999e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pauli_lcu-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 32.8 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e9a5cd2bf641af0574fe0d795f3a0e73b96b8dde86124168c6c07486a41d1582
|
|
BLAKE2b-256 checksum How to use checksums |
731f75bd816eb770824ee9f4276483db4ba3628d4d11f92ffbf956c8839a4d23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pauli_lcu-1.0.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 15.2 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
261643f70b3751328542f3c3d068d58a3fe862d33392e3fa26dac6d98ce36473
|
|
BLAKE2b-256 checksum How to use checksums |
127129f331d75d2ddfa364c18317f938280c64d720ff1945a02e4c124daa8775
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pauli_lcu-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 32.4 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
fc9ccda59509971b07995ecf3bd88a9002d29e819368ed69b9983845e864eb09
|
|
BLAKE2b-256 checksum How to use checksums |
3d66d8d95c6627ff0683c0236b107aec53a068a185ff70c8c764ba415e600e17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | pauli_lcu-1.0.1-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 15.2 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a217bec7d5b359fe8cb35694a8d23719b14407e74853845ddd43b6cb7cf068b5
|
|
BLAKE2b-256 checksum How to use checksums |
ef336802f7034873a6637742d4c3235792c11dac7b30e40aef4fff50c90b1aa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pauli_lcu-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 31.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
0e6aa104a9554b90a585ec81b57d2a46dffb11f6ce3152eecd89d944fc942dbc
|
|
BLAKE2b-256 checksum How to use checksums |
f6e895baadd864394b7a15073c974a18bc277628b0c9eee57c1039b9602deb93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logRelease files / pauli_lcu-1.0.1-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | pauli_lcu-1.0.1-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 15.2 kB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0316866c194c3fa4d46b16cc7e40eec528fcdaa1ec4743eee9b273c3875c465e
|
|
BLAKE2b-256 checksum How to use checksums |
70cd4a0cd7255a4a91bc7783cd742e25f44ad86a869bf4ca8f550049b0c413a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logSecurity for pauli-lcu 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for pauli_lcu-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.