invariance
¶
Invariance checks for shadow constructions.
The invariance property (IP) from Somma et al. (arXiv:2407.21775) requires that
[H, O_m] stays in the span of the operator set S for every O_m in
S. When IP holds, expectations of operators in S evolve among
themselves under H.
This module diagnoses whether a user-supplied S is already closed under
ad_H (in the Pauli label basis) and reports how much growth is needed to
close it. It does not change ShadowHamiltonian construction, which still
auto-closes.
For a quadratic Hamiltonian whose shadow matrix is not Hermitian, use
change_of_basis to build the Sec. 2 matrix A and the Hermitian H_S.
InvarianceReport
dataclass
¶
Diagnostic for whether H and an operator set satisfy the IP.
Attributes:
-
is_closed(bool) –Whether the original Pauli support of
Salready equals its closure under commutators withH. -
original_size(int) –Number of Pauli labels in the original operator set.
-
closure_size(int) –Number of Pauli labels after ad_H closure.
-
growth(int) –closure_size - original_size. -
original_paulis(frozenset[str]) –Pauli labels appearing in the original operator set.
-
closure_paulis(frozenset[str]) –Pauli labels after closure.
-
added_paulis(frozenset[str]) –Labels in the closure that were not in the original set.
-
h_s_is_hermitian(bool) –Whether
H_Son the closed basis is Hermitian (needed for unitary shadow Schrödinger evolution). -
num_qubits(int) –Qubit count used for the Pauli presentation.
-
used_sparse_pauli_path(bool) –Whether the sparse Pauli path was used.
Source code in shadowsim/shadow/invariance.py
check_invariance
¶
check_invariance(
operator_set: OperatorSet,
H: Hamiltonian | Sequence[Hamiltonian],
*,
num_qubits: int | None = None,
tol: float = 1e-10,
) -> InvarianceReport
Check whether H and operator_set satisfy the invariance property.
Uses the same sparse/dense Pauli presentation as ShadowHamiltonian.
Reports whether the original Pauli support of S is already closed under
commutators with H, and how many labels must be added to close it.
Also reports whether the closed-basis H_S is Hermitian.
Parameters:
-
operator_set(OperatorSet) –Observables whose Pauli support defines
S. -
H(Hamiltonian | Sequence[Hamiltonian]) –A single
Hamiltonianor a non-empty sequence of terms. -
num_qubits(int | None, default:None) –Qubit count; inferred when possible (required if every term is a
LocalHamiltonian). -
tol(float, default:1e-10) –Magnitude threshold for keeping Pauli coefficients.
Returns:
-
InvarianceReport–An
InvarianceReportsummarizing closure and Hermiticity.