Result and state dataclasses¶
All result types are frozen=True, slots=True dataclasses. The outer
search history is an immutable tuple[IterationRecord, ...] — there is
no mutable monitor.
- class sparho.SolverResult[source]¶
Bases:
objectOutcome of one inner solve at a fixed hyperparameter.
- Parameters:
coef (numpy.ndarray[tuple[Any, ...], numpy.dtype[numpy.floating]]) – Estimated coefficient vector
β̂.active_set (numpy.ndarray[tuple[Any, ...], numpy.dtype[numpy.int32]]) – Integer indices
jwhereβ̂ⱼ ≠ 0. Sorted ascending.int32to match scipy.sparse CSC index types — the hypergradient linear solve restricts to this set.dual_gap (float) – Final duality gap (or a non-negative proxy for it). Used to assert inner-loop convergence at the tolerance the adapter targeted.
n_iter (int) – Number of inner iterations the adapter consumed.
extras (dict[str, Any]) – Adapter-specific escape hatch. SVM/SVR adapters in a future phase will stash the converged dual variable here.
- class sparho.IterationRecord[source]¶
Bases:
objectOne outer-loop snapshot. Tuples of these form a
SearchResult.history.extrasis a mapping of optional diagnostics keyed by short strings (e.g."cg_nonconvergence","cg_nonfinite") — populated by the search loop when implicit-diff fails. The schema is stability-experimental (seedocs/stability.md). Defaults to an empty dict; treat it as read-only — the record is frozen, but Python can’t enforce mapping immutability without breakingpickleon 3.11.
- class sparho.SearchState[source]¶
Bases:
objectIn-flight outer-loop state, threaded through
grad_search’s for-loop.Each algorithmic step is a pure function
(state, ...) -> state;grad_searchis the only place the loop is written imperatively.- solver_result: SolverResult¶
- history: tuple[IterationRecord, ...]¶
- __init__(iteration, hyperparam, value, grad, solver_result, optimizer_state, history)¶