Skip to content

propaq.models

Compiled surrogate models produced by the surrogate propagators, and the variational wrapper that lets you evaluate one in terms of the original Qiskit parameters.

See the surrogate guide.

models

Surrogate model types for propaq.

Classes:

Name Description
PauliSurrogateModel

Compiled surrogate model for Pauli observables.

MajoranaSurrogateModel

Compiled surrogate model for Majorana observables.

VariationalSurrogateModel

Wraps a compiled PauliSurrogateModel/MajoranaSurrogateModel together with

PauliSurrogateModel

Compiled surrogate model for Pauli observables.

Methods:

Name Description
load

Load a model from a file produced by save.

save

Save to a gzip-compressed binary file.

Attributes:

Name Type Description
n_monomials int
n_params int

Number of parameter indices used by this model.

n_terms int

Number of compiled terms.

n_monomials property

n_monomials: int

n_params property

n_params: int

Number of parameter indices used by this model.

n_terms property

n_terms: int

Number of compiled terms.

load staticmethod

load(path: str) -> PauliSurrogateModel

Load a model from a file produced by save.

save method descriptor

save(path: str) -> None

Save to a gzip-compressed binary file.

MajoranaSurrogateModel

Compiled surrogate model for Majorana observables.

Methods:

Name Description
evaluate

Evaluate the expectation value. params[i] is the angle (radians) for parameter i.

Attributes:

Name Type Description
n_monomials int
n_params int
n_terms int

n_monomials property

n_monomials: int

n_params property

n_params: int

n_terms property

n_terms: int

evaluate method descriptor

evaluate(params: Sequence[float]) -> float

Evaluate the expectation value. params[i] is the angle (radians) for parameter i.

VariationalSurrogateModel

VariationalSurrogateModel(model: PauliSurrogateModel | MajoranaSurrogateModel, parameter_sources: list[ParamSource], qiskit_parameters: tuple[Parameter, ...])

Wraps a compiled PauliSurrogateModel/MajoranaSurrogateModel together with the qiskit Parameter bindings recorded by SurrogatePauliCircuit.from_qiskit/ SurrogateMajoranaCircuit.from_qiskit, so it can be evaluated directly against Qiskit Parameter values instead of raw propaq parameter-index vectors.

Attributes:

Name Type Description
parameters

Distinct Qiskit Parameters this model can be evaluated against, in the order used for positional evaluate calls.

Construct a VariationalSurrogateModel from a compiled surrogate model and its Qiskit parameter sources.

Methods:

Name Description
evaluate

Evaluate the expectation value for the given Qiskit Parameter values.

evaluate_batch

Evaluate many Qiskit Parameter assignments at once (parallelized across

n_params property

n_params: int

Number of underlying propaq parameter slots (may exceed len(parameters)).

evaluate

evaluate(values: Mapping[Parameter, float] | Sequence[float]) -> float

Evaluate the expectation value for the given Qiskit Parameter values.

Parameters:

Name Type Description Default
values Mapping[Parameter, float] | Sequence[float]

Either a mapping from Parameter to its value, or a plain sequence of values aligned with self.parameters.

required

Returns:

Type Description
float

The expectation value for the given parameter assignment.

evaluate_batch

evaluate_batch(values_batch: Sequence[Mapping[Parameter, float] | Sequence[float]]) -> list[float]

Evaluate many Qiskit Parameter assignments at once (parallelized across assignments in Rust), returning one expectation value per assignment.

Parameters:

Name Type Description Default
values_batch Sequence[Mapping[Parameter, float] | Sequence[float]]

A sequence of assignments, each accepted in either form evaluate takes.

required

Returns:

Type Description
list[float]

The expectation value for each assignment, in the same order.