Skip to content

Update BreezeReactantExt to enable ReactantState on LatitudeLongitudeGrid#566

Draft
dkytezab wants to merge 15 commits into
mainfrom
fix/reactant-latlon-ext
Draft

Update BreezeReactantExt to enable ReactantState on LatitudeLongitudeGrid#566
dkytezab wants to merge 15 commits into
mainfrom
fix/reactant-latlon-ext

Conversation

@dkytezab
Copy link
Copy Markdown
Collaborator

@dkytezab dkytezab self-assigned this Mar 17, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ext/BreezeReactantExt/set_product!.jl 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread ext/BreezeReactantExt/PotentialTemperatureFormulation.jl Outdated
Comment thread ext/BreezeReactantExt/PotentialTemperatureFormulation.jl Outdated
Comment thread ext/BreezeReactantExt/set_product!.jl
Comment thread src/AtmosphereModels/set_atmosphere_model.jl Outdated
@dkytezab dkytezab added the reactant ☣ towards a differentiable earth label Mar 17, 2026
Comment thread ext/BreezeReactantExt/set_product!.jl Outdated
Comment thread src/AtmosphereModels/set_atmosphere_model.jl Outdated
Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>
@glwagner
Copy link
Copy Markdown
Member

@dkytezab can you fix the conflicts?

also we should add sharding tests.. maybe we want to wait until after this goes in?

@giordano
Copy link
Copy Markdown
Member

The new tests seem to be very expensive, might be better to move them to separate files for better load balancing. Also, maybe we want to move all the Reactant tests to a reactant/ subdirectory? If we need some common init code for all these tests it can be put in a, say, reactant/setup.jl file which all these test files will include (but remember to always delete it from the testsuite in runtests.jl)

@dkytezab
Copy link
Copy Markdown
Collaborator Author

I agree with @giordano. I also wonder if there will be cases where we want to selectively test without the Reactant tests or only with the Reactant tests

@giordano
Copy link
Copy Markdown
Member

Reactant tests at the moment are run only in a single job because they're already very expensive

@giordano
Copy link
Copy Markdown
Member

Oh, sorry, I thought I was replying to Greg, of course I know you know well how they're currently run 😄

* Add FD validation tests for Centered and WENO compilation

Adds finite-difference gradient verification to both reactant compilation
test files. AD gradients are checked against one-sided FD at two grid cells
and two step sizes (1e-4, 1e-6) with a 1% relative tolerance. Also removes
FT type aliases and cleans up test structure.

Made-with: Cursor

* Use device_arch for FD validation instead of hardcoded CPU

FD validation grids and models now use the same architecture as the
Reactant backend (GPU or CPU), so the test runs on the actual device.

Made-with: Cursor

* Apply suggestions from code review

Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>

* What kind of illiteracy is this

 - ken

* Lower rtol

* Formatting fixes

---------

Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>
@giordano
Copy link
Copy Markdown
Member

@dkytezab the rebase went wrong 🥲

@dkytezab
Copy link
Copy Markdown
Collaborator Author

dkytezab commented Mar 19, 2026

claude got a little uppity./.. but i think now this is ok? cleaning this up atm

const ReactantLatLonModel = AtmosphereModel{<:Any, <:Any, <:ReactantState, <:Any, <:LatitudeLongitudeGrid}

function AtmosphereModels.set_product!(dest::Field{<:Any, <:Any, <:Any, <:Any, <:LatitudeLongitudeGrid}, a, b)
@jit set!(dest, a * b)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Pangoraw @wsmoses is this the best approach? @jit causes MLIR re-compilation in every single call, that doesn't sound ideal.

Also, the signature of this method is effectively type piracy, did you mean to use the ReactantLatLonModel defined above? That's entirely unused.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what fails if you don't do this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this is only called during initialization (eg in set!) @giordano I agree it should be moved to Oceananigans.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what fails if you don't do this?

@dkytezab can answer that I think

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this was a workaround for setting velocity fields outside of a compiled body... which works fine on RectilinearGrid but not LatitudeLongitudeGrid

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

granted we can just only include set! in a compiled body but there's then a surprising asymmetry between the two grids

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dkytezab more specifically it is an issue with setting BinaryOperation -- right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes iirc #543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reactant ☣ towards a differentiable earth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants