Skip to content

Based on Pauli propagation 1.

pauli_propagation

Estimate single-qubit Pauli expectations with PauliPropagation.jl.

PauliPropagationBackend

Bases: _UnsupportedCircuitMetrics

Propagate one Pauli observable per requested qubit [@rudolph2025pauli].

The program is translated to Qiskit and written as OpenQASM 2 for PauliPropagation.OpenQASMInterface.readqasm. z_expectations and x_expectations return the expectation of Z or X on |0...0> after that circuit. Shot counts are not available.

Attributes:

  • name –

    "pauli_propagation". Stored on simulation result metadata.

  • max_weight –

    Largest Pauli weight kept during propagation. inf keeps every weight.

  • min_abs_coeff –

    Smallest coefficient magnitude kept during propagation.

Source code in shadowsim/backends/pauli_propagation.py
class PauliPropagationBackend(_UnsupportedCircuitMetrics):
    """Propagate one Pauli observable per requested qubit [@rudolph2025pauli].

    The program is translated to Qiskit and written as OpenQASM 2 for
    ``PauliPropagation.OpenQASMInterface.readqasm``. ``z_expectations`` and
    ``x_expectations`` return the expectation of Z or X on ``|0...0>`` after
    that circuit. Shot counts are not available.

    Attributes:
        name: ``"pauli_propagation"``. Stored on simulation result metadata.
        max_weight: Largest Pauli weight kept during propagation. ``inf`` keeps every weight.
        min_abs_coeff: Smallest coefficient magnitude kept during propagation.
    """

    def __init__(self, *, max_weight: float = _MAX_WEIGHT, min_abs_coeff: float = _MIN_ABS_COEFF) -> None:
        """Record the PauliPropagation backend name and truncation settings.

        Args:
            max_weight: Largest Pauli weight kept during propagation. ``inf`` keeps every weight.
            min_abs_coeff: Smallest coefficient magnitude kept during propagation.

        Raises:
            TypeError: A setting is not a real number.
            ValueError: A setting is negative, or ``min_abs_coeff`` is not finite.
        """
        self.name = "pauli_propagation"
        self.max_weight = _nonnegative_real(max_weight, "max_weight", allow_inf=True)
        self.min_abs_coeff = _nonnegative_real(min_abs_coeff, "min_abs_coeff", allow_inf=False)

    def run_counts(self, program: Program, *, shots: int, seed: int | None) -> dict[str, int]:
        """Reject a request for shot counts.

        Args:
            program: Unused. PauliPropagation does not sample a program.
            shots: Unused.
            seed: Unused.

        Raises:
            NotImplementedError: PauliPropagation does not support shot counts.
        """
        del program, shots, seed
        raise NotImplementedError("PauliPropagation does not support shot counts")

    def z_expectations(
        self,
        program: Program,
        qubits: Sequence[int],
        *,
        shots: int,
        seed: int | None,
    ) -> list[float]:
        """Return ``⟨Z⟩`` for each qubit in ``qubits``.

        Truncation uses ``max_weight`` and ``min_abs_coeff`` stored on this backend.

        Args:
            program: Program to propagate, without measurements or resets.
            qubits: 0-based indexes in ``program``. The result follows this order.
            shots: Unused. The value is not estimated from shots.
            seed: Unused.

        Returns:
            One expectation per entry of ``qubits``.

        Raises:
            ValueError: An index is outside ``program``, the Julia package is missing,
                or the program cannot be read.
            ImportError: The ``pauli_propagation`` extra is not installed.
        """
        del shots, seed
        return _expectations(self, program, qubits, "Z")

    def x_expectations(
        self,
        program: Program,
        qubits: Sequence[int],
        *,
        shots: int,
        seed: int | None,
    ) -> list[float]:
        """Return ``⟨X⟩`` for each qubit in ``qubits``.

        Truncation uses ``max_weight`` and ``min_abs_coeff`` stored on this backend.

        Args:
            program: Program to propagate, without measurements or resets.
            qubits: 0-based indexes in ``program``. The result follows this order.
            shots: Unused. The value is not estimated from shots.
            seed: Unused.

        Returns:
            One expectation per entry of ``qubits``.

        Raises:
            ValueError: An index is outside ``program``, the Julia package is missing,
                or the program cannot be read.
            ImportError: The ``pauli_propagation`` extra is not installed.
        """
        del shots, seed
        return _expectations(self, program, qubits, "X")

__init__

__init__(
    *,
    max_weight: float = _MAX_WEIGHT,
    min_abs_coeff: float = _MIN_ABS_COEFF,
) -> None

Record the PauliPropagation backend name and truncation settings.

Parameters:

  • max_weight (float, default: _MAX_WEIGHT ) –

    Largest Pauli weight kept during propagation. inf keeps every weight.

  • min_abs_coeff (float, default: _MIN_ABS_COEFF ) –

    Smallest coefficient magnitude kept during propagation.

Raises:

  • TypeError –

    A setting is not a real number.

  • ValueError –

    A setting is negative, or min_abs_coeff is not finite.

Source code in shadowsim/backends/pauli_propagation.py
def __init__(self, *, max_weight: float = _MAX_WEIGHT, min_abs_coeff: float = _MIN_ABS_COEFF) -> None:
    """Record the PauliPropagation backend name and truncation settings.

    Args:
        max_weight: Largest Pauli weight kept during propagation. ``inf`` keeps every weight.
        min_abs_coeff: Smallest coefficient magnitude kept during propagation.

    Raises:
        TypeError: A setting is not a real number.
        ValueError: A setting is negative, or ``min_abs_coeff`` is not finite.
    """
    self.name = "pauli_propagation"
    self.max_weight = _nonnegative_real(max_weight, "max_weight", allow_inf=True)
    self.min_abs_coeff = _nonnegative_real(min_abs_coeff, "min_abs_coeff", allow_inf=False)

run_counts

run_counts(
    program: Program, *, shots: int, seed: int | None
) -> dict[str, int]

Reject a request for shot counts.

Parameters:

  • program (Program) –

    Unused. PauliPropagation does not sample a program.

  • shots (int) –

    Unused.

  • seed (int | None) –

    Unused.

Raises:

  • NotImplementedError –

    PauliPropagation does not support shot counts.

Source code in shadowsim/backends/pauli_propagation.py
def run_counts(self, program: Program, *, shots: int, seed: int | None) -> dict[str, int]:
    """Reject a request for shot counts.

    Args:
        program: Unused. PauliPropagation does not sample a program.
        shots: Unused.
        seed: Unused.

    Raises:
        NotImplementedError: PauliPropagation does not support shot counts.
    """
    del program, shots, seed
    raise NotImplementedError("PauliPropagation does not support shot counts")

z_expectations

z_expectations(
    program: Program,
    qubits: Sequence[int],
    *,
    shots: int,
    seed: int | None,
) -> list[float]

Return ⟨Z⟩ for each qubit in qubits.

Truncation uses max_weight and min_abs_coeff stored on this backend.

Parameters:

  • program (Program) –

    Program to propagate, without measurements or resets.

  • qubits (Sequence[int]) –

    0-based indexes in program. The result follows this order.

  • shots (int) –

    Unused. The value is not estimated from shots.

  • seed (int | None) –

    Unused.

Returns:

  • list[float] –

    One expectation per entry of qubits.

Raises:

  • ValueError –

    An index is outside program, the Julia package is missing, or the program cannot be read.

  • ImportError –

    The pauli_propagation extra is not installed.

Source code in shadowsim/backends/pauli_propagation.py
def z_expectations(
    self,
    program: Program,
    qubits: Sequence[int],
    *,
    shots: int,
    seed: int | None,
) -> list[float]:
    """Return ``⟨Z⟩`` for each qubit in ``qubits``.

    Truncation uses ``max_weight`` and ``min_abs_coeff`` stored on this backend.

    Args:
        program: Program to propagate, without measurements or resets.
        qubits: 0-based indexes in ``program``. The result follows this order.
        shots: Unused. The value is not estimated from shots.
        seed: Unused.

    Returns:
        One expectation per entry of ``qubits``.

    Raises:
        ValueError: An index is outside ``program``, the Julia package is missing,
            or the program cannot be read.
        ImportError: The ``pauli_propagation`` extra is not installed.
    """
    del shots, seed
    return _expectations(self, program, qubits, "Z")

x_expectations

x_expectations(
    program: Program,
    qubits: Sequence[int],
    *,
    shots: int,
    seed: int | None,
) -> list[float]

Return ⟨X⟩ for each qubit in qubits.

Truncation uses max_weight and min_abs_coeff stored on this backend.

Parameters:

  • program (Program) –

    Program to propagate, without measurements or resets.

  • qubits (Sequence[int]) –

    0-based indexes in program. The result follows this order.

  • shots (int) –

    Unused. The value is not estimated from shots.

  • seed (int | None) –

    Unused.

Returns:

  • list[float] –

    One expectation per entry of qubits.

Raises:

  • ValueError –

    An index is outside program, the Julia package is missing, or the program cannot be read.

  • ImportError –

    The pauli_propagation extra is not installed.

Source code in shadowsim/backends/pauli_propagation.py
def x_expectations(
    self,
    program: Program,
    qubits: Sequence[int],
    *,
    shots: int,
    seed: int | None,
) -> list[float]:
    """Return ``⟨X⟩`` for each qubit in ``qubits``.

    Truncation uses ``max_weight`` and ``min_abs_coeff`` stored on this backend.

    Args:
        program: Program to propagate, without measurements or resets.
        qubits: 0-based indexes in ``program``. The result follows this order.
        shots: Unused. The value is not estimated from shots.
        seed: Unused.

    Returns:
        One expectation per entry of ``qubits``.

    Raises:
        ValueError: An index is outside ``program``, the Julia package is missing,
            or the program cannot be read.
        ImportError: The ``pauli_propagation`` extra is not installed.
    """
    del shots, seed
    return _expectations(self, program, qubits, "X")

  1. Manuel S. Rudolph, Tyson Jones, Yanting Teng, Armando Angrisani, and Zoë Holmes. Pauli propagation: a computational framework for simulating quantum systems. 2025. URL: https://arxiv.org/abs/2505.21606, arXiv:2505.21606. ↩