Skip to content

AD/performance: avoid nested runtime differentiation for Hull-White forward rates #285

Open

Description

@alecloudenback

Problem

_hw_forward_rate(curve, t) computes the instantaneous forward by invoking DifferentiationInterface.derivative(..., AutoForwardDiff(), t) at runtime.

Hull-White fitting can therefore nest ForwardDiff: the outer derivative traces model parameters while the inner derivative traces time. Hull-White simulation also repeats this operation across the entire alpha grid. This adds compilation/runtime cost and couples this path to one AD backend.

Proposed direction

Introduce an instantaneous_forward(curve, t) interface with analytic or specialized implementations for built-in curves. Keep numerical differentiation only as a fallback. Consider preparing/caching the fallback derivative and precomputing the forward grid once for simulation.

A custom differentiation rule may be appropriate for any remaining fallback.

Acceptance criteria

  • Built-in Hull-White curve types do not invoke nested runtime ForwardDiff for forward-rate evaluation.
  • Hull-White fitting remains differentiable with respect to model and curve parameters.
  • Simulation computes the forward/alpha grid without repeated AD setup.
  • Numerical agreement with the current implementation is tested for flat and non-flat curves.

Activity

  1. alecloudenback commented on Oct 11, 2026

    @alecloudenback
    MemberAuthor

    Review update against FinanceModels v7.0.0 (6cb71714), 2026-10-11.

    Mostly implemented; medium priority for a narrower remainder. v7 has Yield.instantaneous_forward/Yield.force_of_interest, specialized forwards for many built-in curves, and a cached Hull–White α grid. Simulation does not rebuild that grid for every scenario.

    Smith-Wilson still selects the generic ForwardDiff fallback, so the acceptance criterion that every built-in Hull–White curve avoids nested runtime AD is not fully satisfied. A parameter-derivative probe through Hull–White with a fitted Smith-Wilson curve remained finite.

    See cached grid. Narrow the issue to missing specialized built-in forwards, particularly Smith-Wilson, and measure their compilation/runtime cost. Retain the generic fallback for user-defined curves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions