StochasticFidelityMetricEstimator¶
- class StochasticFidelityMetricEstimator[source]¶
Bases:
MetricEstimatorStochastic Fubini–Study metric via state-overlap fidelities (QN-SPSA).
Provides a
"fidelity_fn"evaluator rather than a closed-form"metric_fn": the QN-SPSA optimizer reconstructs the metric from finite differences of the state fidelity \(F(\theta_1,\theta_2)=|\langle\psi(\theta_1)|\psi(\theta_2)\rangle|^2\), estimated as the all-zeros probability of the compute-uncompute circuit \(U(\theta_1)\,U(\theta_2)^\dagger\). Like the Fubini–Study metric it is the geometry of the ansatz state — independent of the loss observable — so it applies to any qiskit-invertible ansatz. The overlap circuits are built by a preprocessor from the program’s normal post-spec ansatz cohort and averaged over preserved pipeline axes.Methods Summary
bind(program)Return the evaluators this metric provides, keyed by name.
check_compatible(program)Raise
ContractViolationif this metric cannot be applied toprogram.Methods Documentation
- 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.
- check_compatible(program)[source]¶
Raise
ContractViolationif this metric cannot be applied toprogram. Called atrun()start so an incompatible pairing fails loudly before any optimization.- Return type: