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
¶
Compiled surrogate model for Pauli observables.
Methods:
| Name | Description |
|---|---|
load |
Load a model from a file produced by |
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. |
load
staticmethod
¶
load(path: str) -> PauliSurrogateModel
Load a model from a file produced by save.
MajoranaSurrogateModel
¶
Compiled surrogate model for Majorana observables.
Methods:
| Name | Description |
|---|---|
evaluate |
Evaluate the expectation value. |
Attributes:
| Name | Type | Description |
|---|---|---|
n_monomials |
int
|
|
n_params |
int
|
|
n_terms |
int
|
|
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 |
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
¶
Number of underlying propaq parameter slots (may exceed len(parameters)).
evaluate
¶
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 |
required |
Returns:
| Type | Description |
|---|---|
float
|
The expectation value for the given parameter assignment. |
evaluate_batch
¶
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 |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
The expectation value for each assignment, in the same order. |