Skip to content

Generalize stochastic observations beyond drift-owned node aux #5

Description

@jlperla

Motivation

The 2.0 stochastic contract deliberately keeps saved output narrow:

  • solve_sde: drift may return (drift_value, saved_aux); diffusion is value-only.
  • solve_semi_explicit_sdae: algebraic context is passed to drift and diffusion, but only drift-owned aux is saved.
  • Outputs are stored only at actual stochastic nodes.

This is efficient and unambiguous for current Euler–Maruyama solves, but future models may need diffusion diagnostics, quantities depending jointly on drift and diffusion, or per-step noise-dependent observations.

Design questions

  • Should stochastic solvers gain a separate, optional observer callback, or tagged drift/diffusion outputs?
  • How should a combined observer receive drift, diffusion, algebraic context, and the realized Brownian increment without recomputing expensive model work?
  • Which quantities belong to left nodes, right nodes, or completed intervals?
  • How should rejected attempts be excluded once adaptive stochastic stepping exists?
  • Can explicit False keep the current compiled no-observer scan byte-for-byte unchanged?

AD and numerical contract

  • Preserve pathwise JVP/VJP under a fixed key/common random numbers.
  • Keep discrete leaves internal; saved/interpolated outputs remain real floating pytrees.
  • Never use deterministic dense interpolation for rough paths.
  • Define finite-failure prefix behavior consistently with current drift-owned aux.
  • Test jit, vmap, JVP, VJP, mixed-success batches, float32/float64, CPU, and GPU.

Adaptive stepping itself is already tracked in #3. This issue should build on its Brownian-tree/rejected-step semantics rather than duplicate that implementation.

Acceptance criteria

  1. A documented static API for drift-, diffusion-, combined-, and/or interval-owned observations.
  2. No measurable compiled overhead when disabled.
  3. Node/interval alignment tests proving observations correspond to the stated stochastic point.
  4. Pathwise JVP/VJP and batched failure-safety tests.
  5. Benchmarks for scalar, vector, pytree, and vmapped ensembles on CPU/GPU.

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