This repository provides an implementation to compute the Stabilizer Rényi Entropy (SRE) for qubit systems. Using a combination of linear algebra operations and Pauli string manipulations, the code calculates the n-th Rényi entropy for both pure and mixed states.
The main computation involves evaluating expectation values of Pauli strings acting on spin configurations, then summing these contributions to obtain the Rényi entropy for a given quantum state. The code is parallel-ready.
The algorithm computes the
we make use of the fact that
to avoid ever building the matrices and having memory issues.
where:
-
$S_n$ is the$n$ -th order SRE, -
$\mathcal{P}_N$ is the set of all Pauli strings of length$N$ , -
$P$ is a Pauli string, which is an operator of the form$P = P_1 \otimes P_2 \otimes \dots \otimes P_N$ with$P_i \in { \mathbb{I}, X, Y, Z }$ , -
$\langle \psi | P | \psi \rangle$ is the expectation value of the Pauli string$P$ on the state$|\psi\rangle$ .
-
Initialize: Set up a sum
$( \text{expectation} \textunderscore \text{sum} = 0 )$ . -
Iterate Over Pauli Strings: For each Pauli string
$P$ (i.e., each combination of Pauli operators across$N$ qubits),- Apply
$P$ to the quantum state by computing the action of each Pauli operator on the individual qubit spins, obtaining a new spin configuration$s'$ and a complex coefficient$\alpha$ .
- Apply
-
Compute Expectation Value for Each Pauli String: For each spin configuration
$s$ ,- Calculate:
$\langle \psi | P | \psi \rangle = \sum_s \overline{\psi(s')} \cdot \alpha \cdot \psi(s)$ , where$s'$ is the transformed spin configuration under$P$ , and$\overline{\psi(s')}$ is the conjugate amplitude of the transformed configuration.
- Calculate:
-
Accumulate the ( 2n )-th Power: Compute ( \left| \langle \psi | P | \psi \rangle \right|^{2n} ) and add it to the
expectation_sum
. -
Final Computation of
$S_n$ : After iterating over all Pauli strings,- Compute
$S_n = \frac{1}{1 - n} \log \left( \frac{\text{expectation} \textunderscore \text{sum}}{2^N} \right)$ , where$2^N$ is the normalization factor for the number of possible spin configurations.
- Compute
- Dependencies: Make sure to have
LinearAlgebra
,ProgressMeter
,Distributed
, andSharedArrays
installed. - Running the Code:
- Define a quantum state vector
psi
as input. - Call
Mn(n, psi)
with your desired value of ( n ) and state vectorpsi
. - The function will output the Stabilizer Rényi Entropy.
- Define a quantum state vector
using LinearAlgebra, ProgressMeter
# Define a state vector `psi`
psi = [1/sqrt(2), 0, 0, 1/sqrt(2)] # Example state (|00⟩ + |11⟩)/√2
# Compute the 2nd order Stabilizer Rényi Entropy
entropy = Mn(2, psi)
println("Stabilizer Rényi Entropy (n=2): ", entropy)
This code was collaboratively developed with @laurinbrunner. While we've focused on creating a functional implementation, there may be opportunities to optimize its performance further. We noticed a lack of similar implementations available, so we hope this repository helps fill a gap in the community.
Contributions and suggestions are very welcome! If you have ideas for improvements or new features, feel free to submit a pull request.