Skip to content

Commit 3443adb

Browse files
Merge pull request #3827 from CliMA/dy/auto_dense_jacobian
Add AutoDenseJacobian algorithm for implicit solver
2 parents 5be90de + c597725 commit 3443adb

22 files changed

+880
-123
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ version = "0.5.17"
363363
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
364364

365365
[[deps.ClimaAtmos]]
366-
deps = ["Adapt", "ArgParse", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Dates", "Insolation", "Interpolations", "LazyArtifacts", "LazyBroadcast", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "NullBroadcasts", "RRTMGP", "Random", "SciMLBase", "StaticArrays", "Statistics", "SurfaceFluxes", "Thermodynamics", "UnrolledUtilities", "YAML"]
366+
deps = ["Adapt", "ArgParse", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Dates", "ForwardDiff", "Insolation", "Interpolations", "LazyArtifacts", "LazyBroadcast", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "NullBroadcasts", "RRTMGP", "Random", "SciMLBase", "StaticArrays", "Statistics", "SurfaceFluxes", "Thermodynamics", "UnrolledUtilities", "YAML"]
367367
path = ".."
368368
uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
369369
version = "0.30.3"

.buildkite/pipeline.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,14 @@ steps:
320320
--job_id baroclinic_wave
321321
artifact_paths: "baroclinic_wave/output_active/*"
322322

323+
- label: ":computer: baroclinic wave dense autodiff"
324+
key: baroclinic_wave_dense_autodiff
325+
command: >
326+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
327+
--config_file $CONFIG_PATH/baroclinic_wave_dense_autodiff.yml
328+
--job_id baroclinic_wave_dense_autodiff
329+
artifact_paths: "baroclinic_wave_dense_autodiff/output_active/*"
330+
323331
- label: ":computer: no lim baroclinic wave equilmoist"
324332
command: >
325333
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
@@ -385,6 +393,16 @@ steps:
385393
slurm_mem: 20GB
386394
slurm_constraint: icelake|cascadelake|skylake|epyc
387395

396+
- label: ":umbrella: aquaplanet nonequil allsky monin_obukhov varying insol gravity wave (gfdl_restart) high top 1-moment dense autodiff"
397+
command: >
398+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
399+
--config_file $CONFIG_PATH/aquaplanet_nonequil_allsky_gw_res_dense_autodiff.yml
400+
--job_id aquaplanet_nonequil_allsky_gw_res_dense_autodiff
401+
artifact_paths: "aquaplanet_nonequil_allsky_gw_res_dense_autodiff/output_active/*"
402+
agents:
403+
slurm_mem: 20GB
404+
slurm_constraint: icelake|cascadelake|skylake|epyc
405+
388406
- label: ":computer: aquaplanet equil allsky monin_obukhov varying insol gravity wave (raw_topo) high top zonally asymmetric"
389407
command: >
390408
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
@@ -731,6 +749,16 @@ steps:
731749
slurm_mem: 20GB
732750
slurm_constraint: icelake|cascadelake|skylake|epyc
733751

752+
- label: ":genie: Diagnostic EDMFX aquaplanet dense autodiff"
753+
command: >
754+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
755+
--config_file $CONFIG_PATH/diagnostic_edmfx_aquaplanet_dense_autodiff.yml
756+
--job_id diagnostic_edmfx_aquaplanet_dense_autodiff
757+
artifact_paths: "diagnostic_edmfx_aquaplanet_dense_autodiff/output_active/*"
758+
agents:
759+
slurm_mem: 20GB
760+
slurm_constraint: icelake|cascadelake|skylake|epyc
761+
734762
- group: "Prognostic EDMFX"
735763
steps:
736764

@@ -896,6 +924,16 @@ steps:
896924
slurm_mem: 20GB
897925
slurm_constraint: icelake|cascadelake|skylake|epyc
898926

927+
- label: ":genie: Prognostic EDMFX aquaplanet dense autodiff"
928+
command: >
929+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
930+
--config_file $CONFIG_PATH/prognostic_edmfx_aquaplanet_dense_autodiff.yml
931+
--job_id prognostic_edmfx_aquaplanet_dense_autodiff
932+
artifact_paths: "prognostic_edmfx_aquaplanet_dense_autodiff/output_active/*"
933+
agents:
934+
slurm_mem: 20GB
935+
slurm_constraint: icelake|cascadelake|skylake|epyc
936+
899937
- group: "GPU"
900938
steps:
901939

@@ -924,6 +962,19 @@ steps:
924962
slurm_gpus: 1
925963
slurm_mem: 16GB
926964

965+
- label: "GPU: baroclinic wave dense autodiff"
966+
key: "baroclinic_wave_gpu_dense_autodiff"
967+
command: >
968+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
969+
--config_file $CONFIG_PATH/baroclinic_wave_dense_autodiff.yml
970+
--job_id baroclinic_wave_gpu_dense_autodiff
971+
artifact_paths: "baroclinic_wave_gpu_dense_autodiff/output_active/*"
972+
env:
973+
CLIMACOMMS_DEVICE: "CUDA"
974+
agents:
975+
slurm_gpus: 1
976+
slurm_mem: 16GB
977+
927978
- label: "GPU: compare BW with CPU"
928979
command: >
929980
tar xvf baroclinic_wave/output_active/hdf5_files.tar -C baroclinic_wave
@@ -1137,6 +1188,15 @@ steps:
11371188
agents:
11381189
slurm_mem: 32GB
11391190

1191+
- label: ":fire: Flame graph: prognostic edmf dense autodiff"
1192+
command: >
1193+
julia --color=yes --project=.buildkite perf/flame.jl
1194+
--config_file $PERF_CONFIG_PATH/bm_aquaplanet_progedmf_dense_autodiff.yml
1195+
--job_id flame_aquaplanet_progedmf_dense_autodiff
1196+
artifact_paths: "flame_aquaplanet_progedmf_dense_autodiff/*"
1197+
agents:
1198+
slurm_mem: 32GB
1199+
11401200
- label: ":fire: Flame graph: diffusion"
11411201
command: >
11421202
julia --color=yes --project=.buildkite perf/flame.jl

Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
1616
ClimaUtilities = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513"
1717
CloudMicrophysics = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
1818
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
19+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1920
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
2021
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
2122
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
@@ -40,14 +41,15 @@ Adapt = "4"
4041
ArgParse = "1"
4142
Artifacts = "1"
4243
AtmosphericProfilesLibrary = "0.1.7"
43-
ClimaComms = "0.6.6"
44-
ClimaCore = "0.14.24"
44+
ClimaComms = "0.6.8"
45+
ClimaCore = "0.14.34"
4546
ClimaDiagnostics = "0.2.12"
4647
ClimaParams = "0.10.31"
4748
ClimaTimeSteppers = "0.8.2"
4849
ClimaUtilities = "0.1.22"
4950
CloudMicrophysics = "0.23.0"
5051
Dates = "1"
52+
ForwardDiff = ">= 0.10"
5153
Insolation = "0.9.2"
5254
Interpolations = "0.15.1, 0.16"
5355
LazyArtifacts = "1"
@@ -64,6 +66,6 @@ StaticArrays = "1.7"
6466
Statistics = "1"
6567
SurfaceFluxes = "0.11, 0.12"
6668
Thermodynamics = "0.12.8"
67-
UnrolledUtilities = "0.1.6"
69+
UnrolledUtilities = "0.1.9"
6870
YAML = "0.4"
6971
julia = "1.9"

config/default_configs/default_config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ eisenstat_walker_forcing_alpha:
8686
jvp_step_adjustment:
8787
help: "Amount by which the step size of the forward difference approximation of the Jacobian-vector product in the Krylov method should be scaled (only used if `use_krylov_method` is `true`)"
8888
value: 1.0
89+
use_dense_jacobian:
90+
help: "Whether to use a dense Jacobian matrix that is computed using forward-mode automatic differentiation and inverted using LU factorization [`true`, `false` (default)]"
91+
value: false
92+
update_jacobian_every:
93+
help: "Frequency at which the Jacobian matrix should be updated (once per timestep, once per timestepper stage, or once per linear solve) [`dt`, `stage`, `solve` (default)]"
94+
value: "solve"
8995
# Radiation
9096
rad:
9197
help: "Radiation model [`nothing` (default), `gray`, `clearsky`, `allsky`, `allskywithclear`]"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
z_max: 60000.0
2+
z_elem: 31
3+
dz_bottom: 50.0
4+
rayleigh_sponge: true
5+
dt: "360secs"
6+
t_end: "6hours" # This takes 2 hours to run in CI when t_end is 1 day.
7+
dt_save_state_to_disk: "6hours"
8+
vert_diff: "DecayWithHeightDiffusion"
9+
implicit_diffusion: true
10+
use_dense_jacobian: true
11+
update_jacobian_every: dt
12+
moist: "nonequil"
13+
precip_model: "1M"
14+
rad: "allskywithclear"
15+
aerosol_radiation: true
16+
prescribe_clouds_in_radiation: true
17+
radiation_reset_rng_seed: true
18+
insolation: "timevarying"
19+
non_orographic_gravity_wave: true
20+
orographic_gravity_wave: "gfdl_restart"
21+
surface_setup: "DefaultMoninObukhov"
22+
prescribe_ozone: true
23+
prescribed_aerosols: ["SO4", "CB1", "OC1", "DST01", "SSLT01"]
24+
toml: [toml/sphere_aquaplanet_1M.toml]
25+
diagnostics:
26+
- short_name: [edt, evu, mmrso4, mmrbcpo, mmrocpo, mmrdust, mmrss, loadss, o3, od550aer, odsc550aer]
27+
reduction_time: average
28+
period: 6hours
29+
- short_name: [reffclw, reffcli]
30+
period: 6hours
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dt_save_state_to_disk: "2days"
2+
initial_condition: "DryBaroclinicWave"
3+
use_dense_jacobian: true
4+
update_jacobian_every: dt
5+
dt: "400secs"
6+
t_end: "10days"
7+
disable_surface_flux_tendency: true
8+
diagnostics:
9+
- short_name: [pfull, ua, wa, va, rv, ta, ke]
10+
period: 1days
11+
- short_name: [pfull, ua, wa, va, rv, ta, ke]
12+
period: 1days
13+
writer: h5
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
z_max: 60000.0
2+
z_elem: 31
3+
dz_bottom: 50.0
4+
rayleigh_sponge: true
5+
surface_setup: DefaultMoninObukhov
6+
rad: clearsky
7+
co2_model: fixed
8+
turbconv: diagnostic_edmfx
9+
implicit_diffusion: true
10+
use_dense_jacobian: true
11+
update_jacobian_every: dt
12+
prognostic_tke: true
13+
edmfx_upwinding: first_order
14+
edmfx_entr_model: "Generalized"
15+
edmfx_detr_model: "Generalized"
16+
edmfx_nh_pressure: true
17+
edmfx_sgs_mass_flux: true
18+
edmfx_sgs_diffusive_flux: true
19+
moist: equil
20+
cloud_model: "quadrature_sgs"
21+
precip_model: 0M
22+
dt: 120secs
23+
t_end: 1hours
24+
toml: [toml/diagnostic_edmfx_0M.toml]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This job takes too long so we use a lower top and coarser vertical resolution
2+
# z_max: 60000.0
3+
# z_elem: 31
4+
# dz_bottom: 50.0
5+
# rayleigh_sponge: true
6+
surface_setup: DefaultMoninObukhov
7+
rad: clearsky
8+
co2_model: fixed
9+
turbconv: prognostic_edmfx
10+
prognostic_tke: true
11+
edmfx_upwinding: first_order
12+
edmfx_entr_model: "Generalized"
13+
edmfx_detr_model: "Generalized"
14+
edmfx_nh_pressure: true
15+
edmfx_filter: true
16+
edmfx_sgs_mass_flux: true
17+
edmfx_sgs_diffusive_flux: true
18+
implicit_diffusion: true
19+
implicit_sgs_advection: true
20+
implicit_sgs_entr_detr: true
21+
implicit_sgs_nh_pressure: true
22+
implicit_sgs_mass_flux: true
23+
use_dense_jacobian: true
24+
update_jacobian_every: dt
25+
max_newton_iters_ode: 3
26+
moist: equil
27+
cloud_model: "quadrature_sgs"
28+
precip_model: 0M
29+
dt: 20secs
30+
t_end: 40mins
31+
dt_save_state_to_disk: 600secs
32+
toml: [toml/prognostic_edmfx.toml]
33+
output_default_diagnostics: false
34+
diagnostics:
35+
- short_name: [ts, ta, thetaa, ha, pfull, rhoa, ua, va, wa, hfes, hur, hus, cl, clw, cli, evspsbl, pr, rsd, rsu, rld, rlu]
36+
reduction_time: average
37+
period: 40mins
38+
- short_name: [arup, waup, taup, thetaaup, haup, husup, hurup, clwup, cliup, waen, tke, lmix]
39+
reduction_time: average
40+
period: 40mins
41+
use_itime: true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
h_elem: 12
2+
z_elem: 25
3+
dt: 10secs
4+
t_end: 61mins
5+
dt_save_state_to_disk: "Inf"
6+
log_progress: false
7+
rayleigh_sponge: true
8+
viscous_sponge: true
9+
implicit_diffusion: true
10+
implicit_sgs_advection: true
11+
implicit_sgs_entr_detr: true
12+
implicit_sgs_nh_pressure: true
13+
implicit_sgs_mass_flux: true
14+
use_dense_jacobian: true
15+
update_jacobian_every: dt
16+
moist: equil
17+
surface_setup: DefaultMoninObukhov
18+
rad: allskywithclear
19+
dt_rad: 1hours
20+
dt_cloud_fraction: 1hours
21+
turbconv: prognostic_edmfx
22+
max_newton_iters_ode: 3
23+
prognostic_tke: true
24+
edmfx_upwinding: first_order
25+
edmfx_entr_model: "Generalized"
26+
edmfx_detr_model: "Generalized"
27+
edmfx_nh_pressure: true
28+
edmfx_filter: true
29+
edmfx_sgs_mass_flux: true
30+
edmfx_sgs_diffusive_flux: true
31+
cloud_model: "quadrature_sgs"
32+
precip_model: 0M
33+
toml: [toml/prognostic_edmfx.toml]

docs/src/api.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,24 @@ ClimaAtmos.InitialConditions.Bomex
4343
ClimaAtmos.InitialConditions.Soares
4444
```
4545

46-
### Jacobian
46+
### Helper
47+
48+
```@docs
49+
ClimaAtmos.InitialConditions.ColumnInterpolatableField
50+
```
51+
52+
## Jacobian
4753

4854
```@docs
4955
ClimaAtmos.Jacobian
5056
ClimaAtmos.JacobianAlgorithm
5157
ClimaAtmos.ManualSparseJacobian
58+
ClimaAtmos.AutoDenseJacobian
5259
```
5360

54-
### Helper
61+
### Internals
5562

5663
```@docs
57-
ClimaAtmos.InitialConditions.ColumnInterpolatableField
64+
ClimaAtmos.parallel_lu_factorize!
65+
ClimaAtmos.parallel_lu_solve!
5866
```

0 commit comments

Comments
 (0)