You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fitting: allow callers to select the automatic differentiation backend #286
All loss-based fits currently use the global __FIT_ADTYPE = SecondOrder(AutoForwardDiff(), AutoForwardDiff()).
Forward mode is a good default for small parametric models, but its cost grows with the number of fitted parameters. Spline and key-rate fits may have dozens or hundreds of parameters, where reverse or sparse differentiation can be preferable. Models containing nondifferentiable operations may also need finite differences.
Proposed direction
Add an adtype keyword to the relevant fit entry points and loss-function builders. Retain a sensible default, but allow callers to provide another DifferentiationInterface/Optimization backend.
Consider using a first-order declaration by default for first-order optimizers and reserving SecondOrder for optimizers that request Hessians.
Acceptance criteria
Existing calls retain their current behavior.
A caller can supply at least an alternative first-order backend.
The selected backend is threaded through generic, spline, and MonotoneConvex loss construction.
Tests cover the default and one non-default backend or a lightweight test backend.
Review update against FinanceModels v7.0.0 (6cb71714), 2026-10-11.
Still applicable; medium priority. The global constant described in the issue has been replaced by per-fit ForwardDiff tags, but __minimize still constructs SecondOrder(AutoForwardDiff(...), AutoForwardDiff(...)) internally. Public fitting entry points do not accept an adtype keyword.
See backend construction and fit signature. Selecting an optimizer or passing solve_kwargs is not the same as selecting the differentiation backend.
A future implementation should preserve the current safeguards against differentiating unsupported solver paths and test a genuinely different backend. Benchmark larger calibrations to justify priority; this review did not establish a current performance regression from the default.
Activity
alecloudenback commentedon Oct 11, 2026
Review update against FinanceModels v7.0.0 (
6cb71714), 2026-10-11.Still applicable; medium priority. The global constant described in the issue has been replaced by per-fit ForwardDiff tags, but
__minimizestill constructsSecondOrder(AutoForwardDiff(...), AutoForwardDiff(...))internally. Public fitting entry points do not accept anadtypekeyword.See backend construction and fit signature. Selecting an optimizer or passing
solve_kwargsis not the same as selecting the differentiation backend.A future implementation should preserve the current safeguards against differentiating unsupported solver paths and test a genuinely different backend. Benchmark larger calibrations to justify priority; this review did not establish a current performance regression from the default.