Skip to content

Fix accurate AD summation in residual equations - #1035

Merged
Debraheem merged 2 commits into
mainfrom
EbF/bugfix/accurate_ad_sums
Jul 31, 2026
Merged

Fix accurate AD summation in residual equations#1035
Debraheem merged 2 commits into
mainfrom
EbF/bugfix/accurate_ad_sums

Conversation

@Debraheem

@Debraheem Debraheem commented Jul 9, 2026

Copy link
Copy Markdown
Member

I believe the accurate AD summation types in mesa's residual equations were just being assigned the result of a normal AD expression sum, so the (dp) cancellation had already happened before the compensated summation logic even runs. So the accurate AD summation was not really being leveraged at all. I would call this an inconsequential bug, but fixing it could yield benefits.

This pr fixes the accurate AD sums to accumulate term-by-term through the accurate type, so each add/subtract actually uses the compensation algorithm. I added this type to a couple other locations where it might make sense (summing sources in hydro energy and in RSP2 turbulent energy and luminosity equations), and I did some minor clean up.

I'm not sure if this will help mesa convergence or not, it could in principle, but the point remains: this branch makes the intended behavior on main actually happen in practice. We will have to test and see if any thing changes in practice...

@Debraheem Debraheem added numerics issues with math/num/mtx modules solver labels Jul 9, 2026
@warrickball

warrickball commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

LGTM but double_bh is failing. I'll try to run this on bluebear tomorrow and see if I can get some output.

@warrickball

Copy link
Copy Markdown
Contributor

Not sure if you just need to rebase/merge main. The preceding commits also look like they had failures but main is clean.

@Debraheem

Copy link
Copy Markdown
Member Author

yeah, i plan to take a closer look soon as well. Might just need to merge main in.

@Debraheem
Debraheem force-pushed the EbF/bugfix/accurate_ad_sums branch from 746d93a to fe12add Compare July 29, 2026 13:56
@Debraheem

Copy link
Copy Markdown
Member Author

@warrickball i rebased to main and checked the double_bh test case photo checksum locally. Hopefully it passes the test_suite now and we can merge.

@Debraheem Debraheem added the release-blocker Things that should be fixed before the next release label Jul 29, 2026
@warrickball

Copy link
Copy Markdown
Contributor

I've just launched a test on bluebear, too. 🤞

@warrickball

Copy link
Copy Markdown
Contributor

We've got different failures on different machines, possibly related to bluebear running full inlists (i.e., including optional parts). I'll have a look at the output of make_o_ne_wd a bit later.

@warrickball

Copy link
Copy Markdown
Contributor

There's no smoking gun in the logs IMO. There's a minor convergence issue at model 639 with inlist_c_burn_header first then a major problem around model 920 with inlist_o_ne_wd_header. There are then sporadic problems that I guess keep the timestep lower than expected and the model stops because it hits the max model number of 3500.

I guess try a local run with all inlists? 🤷 I don't know these tests at all.

@Debraheem

Copy link
Copy Markdown
Member Author

Interesting. I would definitely put this down to sensitivity. LLNL DANE might need the mod files regenerated to work as well on a partial test. but I'm not sure. If you share the terminal output with me for the make_o_ne_wd i could tweak it. But i will run these both locally as well.

@warrickball

Copy link
Copy Markdown
Contributor

All passing on bluebear! 🥳

@Debraheem
Debraheem merged commit 5268b6b into main Jul 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

numerics issues with math/num/mtx modules release-blocker Things that should be fixed before the next release solver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants