-
Notifications
You must be signed in to change notification settings - Fork 77
Refactoring of integration routines #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
|
|
Thank you! Will you let us know once we shall start reviewing the PR? |
All tests are passing now so it is ready :) |
|
@stefanradev93 the sampling methods are now ready for review, for |
This pull request introduces significant improvements to the integration utilities, focusing on broader support for stochastic integration methods. The main changes include adding new samplers, refactoring the diffusion model to cleanly separate the
scoreandvelocityfunctions, updating integration method defaults and handling, and adding comprehensive tests for deterministic and stochastic solvers.RK45 was the classical Runge-Kutta 4 method. Now it is really a Runge-Kutta method with error controlled step size selection. I updated the coefficients to be the one from Dormand-Prince, which is the standard implementation in lots of packages and has higher accuracy. I also added TSIT5, a newer Runge-Kutta method, which is the default in DifferentialEquations.jl and Diffrax. In the benchmarking, both methods were equally accurate and fast, but TSIT5 was marginally better.
I added several new SDE solvers (inspired again by Diffrax): SEA has same order as Euler with better properties, ShARK is a higher order method and the fast adaptive solver from Jolicoeur-Martineau et al. The latter outperformed all other samplers in speed and accuracy. I also added Langevin-sampling and predictor-corrector methods. However, these do not perform nearly as well as the ODE or SDE solvers.
Refactored the
DiffusionModelclass to separate thescoreandvelocityfunctions. The newscoremethod computes the score function directly, andvelocitynow callsscoreand composes the velocity using the noise schedule, clarifying their roles and simplifying downstream usage.Improved the handling of stochastic integration in the diffusion model by supporting additional stochastic methods and corrector steps, and by passing the score function to
integrate_stochasticwhere needed (e.g., for Langevin dynamics).Added extensive parameterized tests for both deterministic and stochastic integration methods, including forward and backward SDEs, zero-noise (ODE) reduction, and Langevin dynamics.
Changed the default integration methods and step settings in both the diffusion model (
two_step_adaptive,"adaptive") and flow matching model (tsit5,"adaptive"). This was a result of benchmarking both models on the Lueckmann low-dimensional problems.