Skip to content

[WIP] Oceananigans integration tests#2775

Merged
wsmoses merged 4 commits into
EnzymeAD:mainfrom
glwagner:oceananigans-integration
Jul 9, 2026
Merged

[WIP] Oceananigans integration tests#2775
wsmoses merged 4 commits into
EnzymeAD:mainfrom
glwagner:oceananigans-integration

Conversation

@glwagner

@glwagner glwagner commented Nov 12, 2025

Copy link
Copy Markdown
Collaborator

This PR starts adding some integration tests. I noticed that the first thing I tried failed, so we'll have to work our way up.

Working on this with @giordano and @jtbuch

@github-actions

github-actions Bot commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/test/integration/Oceananigans/runtests.jl b/test/integration/Oceananigans/runtests.jl
index 45f388a4..92db3f64 100644
--- a/test/integration/Oceananigans/runtests.jl
+++ b/test/integration/Oceananigans/runtests.jl
@@ -3,14 +3,14 @@ using GPUArraysCore: @allowscalar
 using Oceananigans
 using Test
 
-function kinetic_energy(model, ν, K, dt=1)
+function kinetic_energy(model, ν, K, dt = 1)
     vitd = VerticallyImplicitTimeDiscretization()
     new_closure = ScalarDiffusivity(vitd; ν)
     tracer_names = keys(model.tracers)
     new_closure = Oceananigans.TurbulenceClosures.with_tracers(tracer_names, new_closure)
     model.closure = new_closure
 
-    for n = 1:10
+    for n in 1:10
         time_step!(model, dt)
     end
 
@@ -21,17 +21,19 @@ function kinetic_energy(model, ν, K, dt=1)
 end
 
 @testset "Column model with ScalarDiffusivity" begin
-    ν = 1e-3
-    grid = RectilinearGrid(size=128, z=(-64, 64), topology=(Flat, Flat, Bounded))
+    ν = 1.0e-3
+    grid = RectilinearGrid(size = 128, z = (-64, 64), topology = (Flat, Flat, Bounded))
     vitd = VerticallyImplicitTimeDiscretization()
     closure = ScalarDiffusivity(vitd; ν)
-    m = HydrostaticFreeSurfaceModel(; grid, closure, coriolis=FPlane(f=1e-4),
-        tracers=:b, buoyancy=BuoyancyTracer())
+    m = HydrostaticFreeSurfaceModel(;
+        grid, closure, coriolis = FPlane(f = 1.0e-4),
+        tracers = :b, buoyancy = BuoyancyTracer()
+    )
 
-    N² = 1e-6
+    N² = 1.0e-6
     bᵢ(z) = N² * z
     uᵢ(z) = exp(-z^2 / 10)
-    set!(m, b=bᵢ, u=uᵢ)
+    set!(m, b = bᵢ, u = uᵢ)
 
     u, v, w = m.velocities
     ke = (u^2 + v^2) / 2
@@ -40,11 +42,13 @@ end
     dm = Enzyme.make_zero(m)
     dK = Enzyme.make_zero(K)
 
-    dKdν = autodiff(set_strong_zero(Enzyme.ReverseWithPrimal),
-                    kinetic_energy, Active,
-                    Duplicated(m, dm),
-                    Active(ν),
-                    Duplicated(K, dK))
+    dKdν = autodiff(
+        set_strong_zero(Enzyme.ReverseWithPrimal),
+        kinetic_energy, Active,
+        Duplicated(m, dm),
+        Active(ν),
+        Duplicated(K, dK)
+    )
 
     @test dKdν[1][1] != 0
 end

Comment thread test/integration/Oceananigans/Project.toml
Comment thread test/integration/Oceananigans/runtests.jl Outdated
@glwagner

Copy link
Copy Markdown
Collaborator Author

Looks like I need to be a little less ambitious probably


compute!(K)

return @allowscalar first(K)

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.

@giordano @glwagner so this is failing atm because allowscalar isn't currently supported in enzyme.jl natively [we should add cc @vchuravy ]

@wsmoses wsmoses force-pushed the oceananigans-integration branch from 9b8a278 to 727981b Compare January 19, 2026 07:26
@jtbuch

jtbuch commented Jan 19, 2026

Copy link
Copy Markdown

This might be relevant for you @dkytezab

@wsmoses

wsmoses commented Jan 20, 2026

Copy link
Copy Markdown
Member

1.10 just needs to be marked runtime activity.

1.11 hits a weird issue in an error handler, @vchuravy was looking at a while back but I don't think had cycles to look into for completion

@wsmoses wsmoses force-pushed the oceananigans-integration branch from 727981b to 3b78685 Compare June 18, 2026 22:19
@wsmoses

wsmoses commented Jun 19, 2026

Copy link
Copy Markdown
Member

@glwagner @giordano this code is now passing, anything else you wanted to add

@wsmoses

wsmoses commented Jun 22, 2026

Copy link
Copy Markdown
Member

I'm going to merge this for now @glwagner please update this with whatever else you care to have integration tested

@glwagner

Copy link
Copy Markdown
Collaborator Author

I think this is good to go -- we can keep working on it in future PRs

@wsmoses wsmoses force-pushed the oceananigans-integration branch from 06596ca to a3e78a1 Compare June 24, 2026 04:40
@wsmoses wsmoses force-pushed the oceananigans-integration branch from a3e78a1 to de0f446 Compare July 1, 2026 12:34
@wsmoses wsmoses force-pushed the oceananigans-integration branch from de0f446 to 762da99 Compare July 9, 2026 17:10
@wsmoses wsmoses merged commit c722053 into EnzymeAD:main Jul 9, 2026
42 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants