-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
SRK #344
SRK #344
Conversation
9872349
to
b58343b
Compare
Whoops, looks like GitHub auto-closed this due to merging the If you can rebase on top of main then I'd be happy to review this now. :) (Getting this in is my next priority.) |
No worries, I rebased it :) |
Thanks for letting me know! Seems the file got corrupted. It was perfectly
fine in my local branch, just had to force push it again.
…On Thu, 25 Jan 2024 at 21:09, Owen Lockwood ***@***.***> wrote:
I think there is an error with the SRK notebook, I see these when I look
at it on the branch or in the diff
Screenshot.2024-01-25.at.2.08.32.PM.png (view on web)
<https://github.com/patrick-kidger/diffrax/assets/42878312/7c5159a6-ef43-4951-b43a-04e242a8101a>
Screenshot.2024-01-25.at.2.08.48.PM.png (view on web)
<https://github.com/patrick-kidger/diffrax/assets/42878312/81e8d9e7-e717-4a25-85f6-432e642ef737>
—
Reply to this email directly, view it on GitHub
<#344 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APY2OSR77AMUVDRBAZVROHDYQLCYJAVCNFSM6AAAAABBCKVBMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJRGAYDAOJRHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Thanks, yes, I'll take care of that 😊. There are a few more things that
need to be modified anyway - I'll do that once Patrick is done with his
review.
…On Fri, 26 Jan 2024, 5:52 am Owen Lockwood, ***@***.***> wrote:
Awesome, thanks for that! Seems like a local comment also got left on ;)
image.png (view on web)
<https://github.com/patrick-kidger/diffrax/assets/42878312/1b618032-d6e1-4587-8c60-169c86e92768>
Excited to see these methods make it to main!
—
Reply to this email directly, view it on GitHub
<#344 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APY2OSVTFMPINYM4WCS23P3YQNACLAVCNFSM6AAAAABBCKVBMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJRGUZDIMRUGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, sorry for taking so long to get around to reviewing this; I've been on a long holiday. :)
I still need to review the mathematics of the SRK step itself, but I wanted to start by leaving some first-pass comments on everything else. (Also, because notebooks don't support commenting yet -- note that langevin.ipynb
seems to import from the private diffrax._custom_types
module.)
Overall, my impression is that this looks pretty good! It's also really highlighting how we really need a way to say something about the control in the term (see also #359), so that we can write something like
term_structure: MultiTerm[tuple[ODETerm, AbstractTerm[AbstractBrownianMotion[SpaceTimeLevyArea]]]]
and try to avoid the current heuristic Levy area checks happening in AbstractSRK.init
.
No worries about doing this here, but if you'd find it interesting, then I'd welcome any thoughts on the cleanest way to do that. (Maybe in the future we find ourselves wanting to say something else about our controls as well, e.g. that they return terms from the log-signature of the path?)
Thanks for these comments, I made the appropriate corrections.
Yes, I will think about that. So I don't think the type of Levy area generated is important enough to make its way into the type annotation, and could be left at the level of an attribute. Probably the least invasive way would be to generally just determine compatibility with the control based on the if sttla:
assert bm_inc.K is not None If the control doesn't have the right shape we throw a well-explained error. In either case it is up to the user to make sure the BM has the correct shape (to match the diffusion VF), so maybe Levy area doesn't need any more special treatment than that. I'm not really sure what is "nice enough" though. You are certainly much more of an expert on how to write good code. |
Also, regarding |
457a7f2
to
30dbeab
Compare
6f5903e
to
eecef67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, just done a review. I think the implementation looks really clean. I want to scrutinise the mathematics more carefully, but I think this now looks to be most of the way there!
(And yup, let's go ahead and remove langevin.ipynb
for now.)
(let me know when you next want my input on this PR btw) |
So I made the changes you suggested (except eqxi.scan) on the pr_correction branch. I also made some changes to |
Hi Patrick, I made the edits you suggested. In addition I also reformed convergence testing. This includes comparing the values of solutions at several times (not only at t1) as well as addressing the concern about Euler and Heun being way too imprecise to be used in establishing the order of high-order solvers. I explain more in this comment: |
Or is this related to Patricks PR which does "I realised that it's not sufficient to have term_compatible_contr_kwargs have a single thing on the solver -- we need something with essentially the same tree structure as term_structure, so that we can map the kwargs to each term. So I reworked this." |
Can confirm, it runs off Patricks branch |
Hi @lockwo! Yes indeed any descendant of I'll soon merge in Patrick's branch, so it won't stay broken for long. |
Ok, sounds good. Maybe a weakly controlled srk could also be a unit test? (Whenever something doesn’t work my first impulse is to make it a test so I know it’s good from then on) |
The intention was to add that with the next PR, when Langevin terms are introduced (which use a different |
@patrick-kidger I merged in your changes and added some fixes of my own on top of that. All of these additional fixes are explained in my comments on your PR. |
I defer to Patrick and you on this, I just encounter things and want to make sure they don't slip by on other PRs, I don't have a strong preference on which PR adds the tests. |
@patrick-kidger I am very confused about the tests failing eariler. I reran on my laptop the tests that failed here, and everything passed. And the stack-trace is very confusing. Something about I looked into it further and I suspect it has to do with lines 960/961 of |
@lockwo I added a test for the SRKs which involves a weakly diagonal control term. Thanks again for bringing this up! |
@patrick-kidger Another update: I found that when using an SRK wrapped in a
I will try to investigate and will let you know if I find a fix. |
I fixed the I don't know what to do to stop the very weird error one of the other tests keeps throwing. It seems entirely unrelated to my work. This first appeared when I merged your srk-tweaks branch (before I added edits of my own) and it kept appearing since. I think I know what is the cause, but it is in a part of Diffrax that I'd rather not meddle in. |
I made another commit (7ff1029), which I think fixes the issue that kept appearing. I strongly think it wasn't caused by any of my changes, probably just some typechecking module got updated and caught this?? Anyway, this is just a quick temporary fix, let me know if you'd like something more principled. |
More things are broken apparently. It seems to me that |
Awesome stuff! I'm glad things are passing. I'll try to look at what you've done this weekend. FWIW I don't think |
For some reason it got floated to the user in this case. You can look at the log from the latest failed test run and search for: In general I think something broke with the latest version of Equinox or JAX and now some tests in Diffrax are spuriously failing. Try to run tests on the main branch of Diffrax, I think they might fail, because these failures don't seem to be related to the changes we made. |
Try updating to the latest Equinox :) Something on the JAX side changed without how they output errors. Equinox has since been updated to work in both regimes. |
76a9441
to
34cbe5c
Compare
Btw it looks like there are now many merge conflicts here. I think these are probably spurious, e.g. I can see that your If you're able to squash all your changes into a single commit on top of |
I squashed everything and removed the last commit (which was just something to do with handling of |
And merged! 🎉🎉 This was a pretty gigantic PR, so thank you very much for all your effort to implement this. I am incredibly excited that we'll be able to introduce this in the next release of Diffrax. Great work on getting all of this done! |
This PR adds all the shiny new SRK methods, while leaving out the Langevin-only methods (ALIGN and SORT).
A few things to keep in mind: