Skip to content
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

Adding tsit5 as a solver #261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Adding tsit5 as a solver #261

wants to merge 3 commits into from

Conversation

psv4
Copy link

@psv4 psv4 commented Feb 3, 2025

Closes #194

Tsit5 is a Runge-Kutta method found to be more efficient than dopri5. In Diffrax and DifferentialEquations.jl, tsit5 is being recommended over dopri5 as a default non-stiff solver.

The coefficients for the dense output are functions of the interpolating point, unlike with all other methods present. I switched the mid --> _mid for all other RKAdaptiveStepsizeODESolver and added a default function mid() which returns the default coefficients. For tsit5, it takes in x which is the normalized intermediate point value and then returns the correct coefficients.

@psv4
Copy link
Author

psv4 commented Feb 3, 2025

One test is failing regarding the seminorm but I am not sure how to address it.

======================================================================
FAIL: test_seminorm (norm_tests.TestNorms) (dtype=torch.float32, device='cpu', method='tsit5')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\Gitlab\torchdiffeq\torchdiffeq\tests\norm_tests.py", line 300, in test_seminorm
    self.assertLessEqual(seminorm_nfe, default_nfe)
AssertionError: 38 not less than or equal to 32

----------------------------------------------------------------------
Ran 22 tests in 332.048s

FAILED (failures=1)

Copy link
Owner

@rtqichen rtqichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Some of the tests can be finicky, I will double check when I get some time.

I left a question about the self.mid change.

torchdiffeq/_impl/rk_common.py Outdated Show resolved Hide resolved
psv4 added 2 commits February 3, 2025 14:43
As seen from PR comments and the `dopri8` implementation, the midpoint coefficients only need to be evaluated at `x=0.`

Removing the function and precalculating the value now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to add Tsit5 solver?
2 participants