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

Use autodiff in templated network rate evaluation #1614

Merged
merged 16 commits into from
Jul 26, 2024

Conversation

yut23
Copy link
Collaborator

@yut23 yut23 commented Jul 17, 2024

No description provided.

@yut23 yut23 marked this pull request as draft July 17, 2024 16:46
@yut23 yut23 marked this pull request as ready for review July 17, 2024 20:20
@yut23
Copy link
Collaborator Author

yut23 commented Jul 17, 2024

Timings for test_aprox_rates, with a loop added around the rate_* calls. RHS::rhs() calls the version without derivatives, while the analytic Jacobian calls the version with derivatives. The previous code always calculated the derivatives, hence the same timings on the left.

CPU (n_cell=64, loops=10):
- without derivatives:  5.34s ->  4.34s (-1.00s, -19%)
- with derivatives:     5.34s ->  5.71s (+0.37s,  +7%)

CUDA (n_cell=64, loops=500):
- without derivatives:  5.25s ->  4.42s (-0.83s, -16%)
- with derivatives:     5.25s ->  5.30s (+0.05s,  +1%)

@zingale
Copy link
Member

zingale commented Jul 18, 2024

@zingale
Copy link
Member

zingale commented Jul 18, 2024

do you expect the diffs shown in the test suite?

@yut23 yut23 marked this pull request as draft July 22, 2024 19:26
@yut23
Copy link
Collaborator Author

yut23 commented Jul 22, 2024

No, I don't think the diffs should be that large. I'm even more confused by the diffs with the numerical Jacobian, as that shouldn't be using autodiff at all.

@zingale
Copy link
Member

zingale commented Jul 22, 2024

let me rerun the test

We can restore these later in a separate PR.
@yut23 yut23 marked this pull request as ready for review July 23, 2024 03:24
@yut23
Copy link
Collaborator Author

yut23 commented Jul 23, 2024

I found a few optimizations I made that were causing the differences with the numerical Jacobian, and I'm now pretty sure the other big diffs are just compounded from the roundoff diffs in the analytical Jacobian.

@zingale
Copy link
Member

zingale commented Jul 23, 2024

most test_rhs diffs are now roundoff, except for powerlaw, which is Inf
http://groot.astro.sunysb.edu/Microphysics/test-suite/gfortran/2024-07-23-001/index.html

@yut23
Copy link
Collaborator Author

yut23 commented Jul 26, 2024

This should be ready to merge. The Inf diffs for powerlaw are because we weren't calculating the temperature derivatives at all before.

@zingale zingale merged commit c75486b into AMReX-Astro:development Jul 26, 2024
29 checks passed
@yut23 yut23 deleted the autodiff_aprox_rates branch July 26, 2024 22:27
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.

2 participants