MetricEstimator

class MetricEstimator[source]

Bases: ABC

Strategy that produces natural-gradient evaluators for a program.

Methods Summary

bind(program)

Return the evaluators this metric provides, keyed by name.

check_compatible(program)

Raise ContractViolation if this metric cannot be applied to program.

Methods Documentation

abstractmethod bind(program)[source]

Return the evaluators this metric provides, keyed by name.

Deterministic estimators (pullback, Fubini–Study) provide "metric_fn" — a pure function of the parameters returning the metric matrix — and the pullback estimator additionally returns the loss gradient under "jac". The stochastic-fidelity estimator instead provides "fidelity_fn": the QN-SPSA optimizer builds its metric from finite differences of that fidelity rather than from a closed-form matrix. The variational algorithm forwards whichever keys appear to the optimizer; keys absent fall back to the algorithm’s parameter-shift defaults.

Return type:

dict[str, Callable[..., Any]]

abstractmethod check_compatible(program)[source]

Raise ContractViolation if this metric cannot be applied to program. Called at run() start so an incompatible pairing fails loudly before any optimization.

Return type:

None