Conversation
dkytezab
commented
Mar 17, 2026
- Adds Enzyme, Reactant to deps for docs
- Adds an AD visualization to the Breeze documentation
- Computes derivative of density perturbation at point after an acoustic wave has propagated
|
excited to see the docs preview |
There was a problem hiding this comment.
Note that you need to add the example to
Lines 30 to 46 in 7fa5816
| using Oceananigans.Architectures: ReactantState | ||
| using Reactant: @trace | ||
|
|
||
| Reactant.set_default_backend("cpu") |
There was a problem hiding this comment.
Out of curiosity, any specific reason for running this on CPU?
There was a problem hiding this comment.
This is a cheap case, so it doesn't require the GPU. I think our default thinking is to run expensive things on GPU, cheap things on CPU to save resources. Do you agree with that strategy or should we run everything on GPU?
There was a problem hiding this comment.
Sure, sounds sensible! I just wanted to understand the motivation. If it's fast already on CPU no need to use the GPU.
There was a problem hiding this comment.
I guess the main motivation then is the fact that the example on main is on CPU:
Breeze.jl/examples/acoustic_wave.jl
Lines 38 to 39 in 7fa5816
There was a problem hiding this comment.
The bulk of the time here is spent in compilation. Oh reactant, my reactant.... ❤️
There was a problem hiding this comment.
One day CompilerCaching.jl will make our lives easier.
|
@dkytezab is there a way we can compare to an estimate or exact solution to make sure the answer is correct? |
CC @Pangoraw |
Co-authored-by: Gregory L. Wagner <[email protected]> Co-authored-by: Mosè Giordano <[email protected]>
we can reproduce with
|
|
#575 will allow new Ocenanigans, which will get the fix for the docs crash in. |
|
Unless we build docs on 1.11 it will also need CliMA/Oceananigans.jl#5415 (or upcoming call conv reactant fix) to get around the next crash in the pipeline. |
|
Ok, now we're getting (unfortunately Literate swallows full error messages and stacktraces): Is that what CliMA/Oceananigans.jl#5415 addresses? |
|
Still getting the same error after checking out CliMA/Oceananigans.jl@4da9e65 |
|
Yeah, there is some underlying issue with Reactant + Julia 1.12 codegen. See EnzymeAD/Reactant.jl#2701 |
|
Should we switch the docs to using julia v1.11 then? It's doable, but I'll need to change the docker image. |
I'm ok with this esp if its computationally feasible |
|
Docs job is failing because stuff like (not the only case, there are multiple errors) Breeze.jl/src/ParcelModels/parcel_dynamics.jl Lines 68 to 72 in fab76dc [...] (...)). I can't fix it now
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Preview at https://numericalearth.github.io/BreezeDocumentation/previews/PR565/literated/acoustic_wave/#Differentiability:-sensitivity-to-the-initial-perturbation. Should we wait for EnzymeAD/Reactant.jl#2704 to make it into a new release so that we can go back to Julia v1.12 here? Edit: Reactant tests in #577 with Julia v1.12 are passing, so we may wait for a new Reactant version and go back to building the docs with Julia v1.12 👀 |
|
Does log10(error) larger than 0 mean that the relative error is larger than 100%? 🤔 Edit: yes, that's visible in the generated docs:
|
|
After playing with some parameters locally, I'm convinced that the thing here is that the derivative in those two points is "very small", and with AD vs FD we get two different "very small" derivatives (things like -3.69401e-6 vs -1.42948e-5), but by its nature, finite differences isn't necessarily The Right Answer™️. Should we add a comment along the lines of "while it's useful to compare the patterns between AD and FD, FD is inherently unstable, and as such it doesn't necessarily provide a reliable reference", to justify the difference? |
|
Maybe we should figure out how to compute a gradient that will be reasonably smooth and easy to access accuracy |
e6e9614 to
c3ddd47
Compare
|
I can work on a suitable example |

