QUIVEROptimizer¶
- class QUIVEROptimizer(learning_rate=0.1, epsilon=0.1, V_init=1, V_min=1, V_max=50, M_init=100, M_min=10, M_max=10000, adapt_V=True, adapt_M=True, derivative_mode='finite_diff', lipschitz=None, mu=0.99, b=1e-06, alpha=0.0, gamma=0.0, A=None, blocking=False, blocking_history=5, blocking_tol=2.0, exact_loss=False)[source]¶
Bases:
_SPSAConfigMixin,OptimizerAdaptive directional (forward) gradients — QUIVER (arXiv 2606.09734).
Reconstructs the full gradient from
Vrandom Rademacher directional derivatives, independent of the parameter countN:\[\tilde\nabla^{\mathsf F} f = \frac{1}{V}\sum_{\ell=1}^{V} \Big(\frac{f(\theta+\varepsilon v_\ell) - f(\theta-\varepsilon v_\ell)} {2\varepsilon}\Big)\, v_\ell , \qquad \theta \leftarrow \theta - a_k\,\tilde\nabla^{\mathsf F} f ,\]costing
2Vevaluations per step. This unifies SPSA (V=1, finite-difference), random coordinate descent (V=1, parameter-shift directional derivative) and the full parameter-shift rule (V=N) under one tunableV.QUIVER additionally adapts
Vand the per-direction shot countMeach step (iCANS/gCANS-style), maximising expected progress per measurement shot:``V`` from the sample spread (no backend variance needed). The
Vi.i.d. directional samples already estimate the forward-gradient varianceS²; more directions are spent when the relative gradient variance is high and fewer as the estimate concentrates. This encodes the paper’s assumption that measurement noise concentrates uniformly across random directions, so allocation is by number of directions, not per-parameter.``M`` from the injected measurement variance. When the variational algorithm’s cost closure exposes a shot-noise variance (shot-based backends), QUIVER reads the single-shot cost variance and sets
Mto balance derivative noise against the gradient signal. On native-expval backends or a plaincost_fn(no variance channel) it falls back to a fixedMandV-from-spread only — still a valid forward-gradient optimizer.
Note
A per-evaluation shot budget is delivered to the backend as explicit per-circuit
shot_groups, which disables circuit-template batching for that submission. On template-capable backends (e.g. the Qoro cloud) an adaptingMtherefore trades template reuse for shot adaptivity; if submission overhead dominates, preferadapt_M=Falsethere and keepadapt_Mfor local shot-based simulators.Single-point optimizer (
n_param_sets == 1); gradient-free, so anyjac/metric_fnsupplied by the variational algorithm is ignored.- Parameters:
learning_rate (
float) – Step-size numeratora(constant by default; the gain schedule reuses Spall’sa/(A+k+1)**alphawithalpha=0).epsilon (
float) – Finite-difference stepε(paper default0.1); forderivative_mode='parameter_shift'the shiftπ/2is used instead.V_init/V_min/V_max – Initial / minimum / maximum number of random directions per step.
M_init/M_min/M_max – Initial / minimum / maximum shots per directional evaluation (only adapted on shot-based backends).
adapt_V (
bool) – Adapt the number of directions from the sample spread.adapt_M (
bool) – Adapt the shot budget from the injected measurement variance.derivative_mode (
Literal['finite_diff','parameter_shift']) –'finite_diff'(default, central difference with stepε) or'parameter_shift'(directional shiftπ/2; exact only for equal-eigenvalue generators along basis directions, otherwise an approximation).lipschitz (
float|None) – Smoothness constantLfor the gain bound; whenNonethe optimal stepa = 1/Lis taken to belearning_rate.mu (
float) – EMA decay for the running gradient / variance estimates.b (
float) – Small floor guarding divisions by a vanishing gradient norm.alpha/gamma/A – Spall gain-schedule knobs (default to constant gains).
blocking/blocking_history/blocking_tol/exact_loss – Inherited look-ahead blocking and loss-recording behaviour (see
SPSAOptimizer).
Methods Summary
optimize(cost_fn[, initial_params, callback_fn])Run QUIVER for
max_iterationssteps.validate_program(program)Warn when
adapt_Mis combined with a configured shot distribution.Methods Documentation
- optimize(cost_fn, initial_params=None, callback_fn=None, **kwargs)[source]¶
Run QUIVER for
max_iterationssteps.- Parameters:
cost_fn (
Callable[[ndarray[tuple[Any,...],dtype[double]]],float|ndarray[tuple[Any,...],dtype[double]]]) – Cost function; called with a two-row batch per directional sample. When it acceptsshots/return_variance(the variational algorithm’s closure), QUIVER drives the adaptive shot budget and reads the measurement variance forM-adaptivity.initial_params (
ndarray[tuple[Any,...],dtype[double]] |None) – Starting parameters (1D, or 2D with a single row).callback_fn (
Callable[[OptimizeResult],Any] |None) – Called after each step with anOptimizeResultwhosexis 2D andfunis 1D. May raiseStopIteration.**kwargs –
max_iterations(default 50, must be >= 1) andrng.jacandmetric_fnare accepted and ignored (QUIVER is gradient-free).
- Return type:
- validate_program(program)[source]¶
Warn when
adapt_Mis combined with a configured shot distribution.M-adaptivity recovers the single-shot cost variance asVar(<H>)·M, which assumes every measurement group received the sameMshots. A shot distribution splits the budget unevenly across groups, so that recovery is miscalibrated — the gradient and loss stay correct, but the adaptedMmay be off. Disableadapt_Mor drop the shot distribution to silence this.- Return type: