patrick-kidger / patrick-kidger/diffrax

Passing a state between vector_field calls

Open
#595 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
2.1k
Forks
189
Avg merge
3d 18h
Merged PRs (30d)
1

Description

Hi, first of all, thanks for this great library!

I have a use-case in which I want to solve some ODE, but at every call to the vector_field it requires running some inner iterative solver $s$ to get the time derivative of the state, i.e. $\frac{dy}{dt}=s(y)$. I would now like to give the inner solver the previous vector_field output as a warmstart, is there a clever way to do this? Ideally there would be some option to return some arbitrary auxiliary output when calling the vector_field that is directly passed over to the next call.

So far I implemented a custom Euler integrator that supports this by assuming that the state is structured as a tuple of the actual state and auxiliary outputs, and only integrating the actual state while directly passing the auxiliary output. However, I was wondering if there is some simpler way to do it, as adapting my changes to e.g. the Runge-Kutta implementation would be quite tedious. I was also considering somehow passing the auxiliary output via the SolverState but this again would require many changes it seems.

Thanks in advance!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing custom Euler integrator, the Runge-Kutta implementation, and SolverState, which the issue identifies as the relevant entry points. Define how auxiliary output from vector_field can be passed to the next call while only the actual state is integrated, and verify that the approach works across the supported integrators.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.