Adjoint status
This page marks the current boundary of the adjoint implementation: what can be run and tested today, and which combinations are deliberately rejected. The LinRood adjoint and TM5-style inversion scaffold are implemented and covered by the core test suite, but real-data parity with TM5-4DVAR remains a validation gap.
For a first introduction, start with Learning adjoints and inversions and the executed footprint tutorial. This page is the support reference, not the starting lesson.
What is shipped
Forward operators (unchanged)
The forward transport model — advection (four schemes: UpwindScheme, SlopesScheme, PPMScheme, LinRoodPPMScheme), convection (CMFMC + TM5), implicit vertical diffusion (Beljaars–Viterbo / Holtslag–Boville Kz fields), and surface flux sources — is implemented for the runtime's supported topology/backend combinations and covered by the test suite documented in Conservation budgets.
Tape, checkpoint, and reverse pass
src/Adjoints/ ships a full discrete-adjoint pipeline for the cubed-sphere split-sweep path, with a separate kernel-level pipeline for LinRoodPPMScheme integrated through cs_surface_emission_footprint.
The shipped pieces, all exported through AtmosTransport.Adjoints:
| Surface | What it does |
|---|---|
cs_surface_emission_footprint | Forward → tape → reverse pass driver for CS, returning dJ/dE_t at every surface step |
cs_surface_emission_footprint_from_seed | Same, but accepts an explicit final dJ/drm seed for arbitrary observation operators |
cs_surface_flux_jacobian | Batches layer/column objectives on one recorded tape (one reverse walk per objective), aggregates per-step footprints into named user windows |
cs_surface_flux_4dvar | 4D-Var cost / gradient with named controls, scalar observations sampled at one step or over a time window (layer, column-mean, point samples placed in the column, and averaging-kernel columns), diagonal background; one forward run, which samples the observations and records the tape, and one reverse pass per gradient, whatever the number of observations (single-sweep gradient, observation operators, averaging-kernel columns) |
cs_surface_flux_4dvar_optimize | Dependency-free gradient-descent driver for the above |
cs_surface_flux_4dvar_solve | Production driver with optimizer choice (CSGradientDescent / CSLBFGS) |
The adjoint supports the following advection schemes (full union in CSAdjointSupportedScheme):
UpwindScheme()SlopesScheme(NoLimiter())PPMScheme(NoLimiter())PPMScheme(MonotoneLimiter())andPPMScheme(CW84Limiter())— via the limiter branches of the base trajectory, recorded on the tape (one byte per cell and sweep; what the tape stages)LinRoodPPMScheme(5)andLinRoodPPMScheme(7), with either vertical sweep: FV3'skord = 8profile (vertical = "fv3_kord8", the configured default, or"fv3_kord8_signed") or upwind (vertical = "upwind"). The FV3 sweeps are transposed at the limiter branches of the recorded state; see the adjoint of the FV3 vertical sweep
The split-sweep PPMScheme with the FV3 vertical profile has no adjoint; neither do limited SlopesScheme and NoAdvection. The per-step air-mass reset of advection-off runs ([run] air_mass_update = "step", their default) has no adjoint record either; the setup guard names both. require_adjoint_support(scheme) returns a supported scheme and otherwise throws an error that names the missing piece. The inversion driver applies it to its [advection] table; a Lin–Rood table without vertical selects fv3_kord8 there as in forward runs.
The supporting kernel adjoints in src/Operators/Advection/linrood_adjoint_*.jl are transposition-tested (test/core/test_linrood_kernel_adjoints.jl) and finite-difference VJP-tested via single-panel and cross-panel halo compositions. The full LinRood footprint, including its two Upwind Z half-sweeps, matches central differences to about 1e-11 relative on a smooth base field. test/core/test_cs_linrood_fv3_adjoint.jl asserts 1e-9 with upward vertical flux and a surface-layer objective, the case most sensitive to which air mass the Z records hold. Every tape records the air mass entering a Z sweep, because the upwind adjoint coefficient F / m_donor uses the pre-sweep donor mass; the FV3 profile's records also hold the tracer mass entering the sweep. test/core/test_cs_linrood_fv3_adjoint.jl checks the FV3 vertical sweeps' transpose in 256-bit arithmetic and the Lin–Rood footprints with them against central differences (1e-9, upward and downward flux, ORD 5 and 7, both profiles), and Full/Stride parity.
The opt-in test/diagnostic/test_cs_transport_adjoint_gpu.jl also exercises transporting PPM and LinRood footprints on CUDA with scalar indexing disabled. It checks Float32/Float64 CPU/GPU agreement, Float64 directional finite differences, and full/stride checkpoint parity, plus the single-panel recording and reverse wrappers. LinRood copy-back and halo-gradient updates run on the array backend; the tape path does not require host scalar reads.
The CS reverse pass also supports the default, unclamped/full-column/unmerged forms of TM5Convection, CMFMCConvection, and CMFMCMatrixConvection. IFSConvection is forward-only; adjoint setups reject it. CMFMC and CMFMC-matrix have column adjoint-identity tests (for CMFMC also the transpose of the forward column matrix, sub-cloud mixing included, in test_cmfmc_ras_cloud_base.jl); the TM5/CMFMC footprint paths are checked against finite-difference emission gradients in test_cs_ppm_adjoint_footprint.jl.
The step plan: the adjoint replays production
The forward model the reverse pass transposes is the production step by construction (owner decision D31). A StepPlan (Operators/StepPlan) describes a run's step in four phases — window advance, window start, every step, window end — with the physics cadence, the binary window contract and the air-mass reset mode resolved once. TransportModel.step! and DrivenSimulation execute it; the adjoint replays the same plan with the production operators on a single-tracer state (CSStepSchedule; for a driven run CSStepSchedule(sim)) and records its tape through the recorder hooks of the production step (AbstractStepRecorder; production passes NoStepRecorder(), whose hooks are no-ops). Consequences:
physics_cadence = :window(the driven-run default under a binary window contract): convection is recorded once per met window, after the window's last step and the air-mass reset to the window's end mass, over the window length, with the window's forcing and (CMFMC) the CFL sub-step count of the forward call. Formerly the adjoint applied convection every step (finding OF-114).A configuration without surface sources has the center
; footprints and 4D-Var always carry a surface-flux operator (zero rates allowed), and cs_surface_emission_footprint_from_seed(...; surface_flux = false)gives the initial-condition sensitivity of a no-emission run (initial_adjoint). Formerly the replay always built the coupled center(finding OF-115). The replay carries production's persistent operator state (the Kahan compensation of the surface source, the convection and Kz/Dkg diffusion ledger carries, the CMFMC CFL cache), and checkpoints save it, so the forward replay, the tape recording and every checkpoint restart equal the production run bit for bit.
require_adjoint_support(plan, ops)(alsorequire_adjoint_support(sim)) rejects, before recording, every stage or operator without a record and an adjoint (adjoint_support(x)is the trait), naming it.cs_adjoint_inputs(sim; tracer)captures the adjoint's inputs from a productionDrivenSimulation(the face fluxes of every step as production refreshes them, one copy per met window that the window's steps share, or one per step when they are interpolated within the window; per-window convection forcing, diffusion layer thickness and Kz, emission rates, the schedule, a fresh convection workspace). Capture rejects initial nonzero compensation or carries and valid CMFMC CFL caches, including models continued across binaries at iteration zero.CSStepSchedule(sim)validates the production operators and retains chemistry. Reset windows and targets use the model backend. The fresh convection workspace is allocated on that backend too, including the cell-area metrics copied from the host mesh. Diffusion records carry the forward's clock, so time-varying Kz fields are transposed at the times production evaluated them.
test/core/test_cs_adjoint_step_plan_parity.jl is the parity matrix: Upwind, unlimited slopes, monotone PPM and Lin–Rood (plus CW84 PPM, unlimited PPM and Lin–Rood ORD 5 with upwind vertical) under :window and :substep cadence, with and without the binary window contract, TM5, CMFMC and CMFMC-matrix convection, both diffusion couplings, diffusion without surface sources and both reset modes, also with continuous windows whose shared reset targets give the footprints of separate copies bit for bit. Each case compares the forward replay, the tape recording and a restart from a checkpoint inside a met window with the production DrivenSimulation (== in one thread), Full/Stride footprints with each other, the captured fluxes with production's at every step (one copy per met window; shared and per-step copies give the same footprints) and, on a subset, footprints and the initial-condition sensitivity with central differences of the production simulation (Upwind
Memory of the captured inputs
With the default residency = :device the captured inputs stay on the device for the whole 4D-Var period (a streamed HostCSWindowSource, below, keeps them in host memory instead). Per met window they are one set of face fluxes, the convection forcing, the diffusion operator (its Kz panels) and layer thickness, and the reset targets; per step there are only references. Two duplicates are removed at capture, both without changing any result bit:
Diffusion. The adjoint takes the per-window layer thickness (
diffusion_layer_thickness, six(Nc, Nc, Nz)panels, read only). The replay owns its diffusion workspace and one scratch for every reverse solve; each reverse kernel overwrites a column of the scratch before it reads it. Formerly every window held a fullDiffusionWorkspace(factors, layer thickness, exchange, elimination), four times the data.Reset targets. With the window contract and a mass reset the plan resets to window
w's end massm + dmand, on entering windoww + 1, to its start mass.CSStepSchedule(sim)stores one array for both when they are equal bit for bit, halos included (_window_reset_targets); otherwise two copies. Sharing is exact because the replay writes a target only when a reset refreshes its halos from its interior (fill_panel_halos!(…; dir = 1)rewrites every halo cell), so both resets install what separate copies would. In the MERRA-2 binaries measured every interior window boundary of a daily binary was bitwise continuous; days captured separately (onecs_adjoint_inputsper binary) keep two arrays at the day boundary.
At C90 L72 Float32 a window held 178.5 MB of device inputs before (fluxes 48.3, convection 28.4, Kz 14.0, diffusion workspace 56.0, reset targets 31.9) and holds 121.3 MB now (layer thickness 14.0; reset targets 16.6 on average over a day). Seven C90 days of inputs fell from 27.97 to 19.01 GiB, a 31-day C48 Lin–Rood 4D-Var now fits on a 46 GiB GPU, and C90 Lin–Rood fits 11 days; costs and gradients are unchanged bit for bit on one CPU thread. The measurements are in docs/memos/2026-11-08_adjoint_input_dedup.md.
How the replay reads the met: window sources
The replay reads every met input of a step through the step's met window (CSWindowMet): the window's face fluxes, convection forcing, diffusion operator and layer thickness, and reset targets. It acquires the window from a window source (acquire_window!) at the window's first step, or at a checkpoint restart inside the window, and returns it with release_window!:
an untaped forward run (and the counting run that sizes a tape) releases its window when it acquires the next one;
a recording run keeps the windows it reads until the driver has released the records that reference them. Before the segmented driver walks a re-recorded segment, it checks that every window the segment holds is still the one it acquired (
require_current; otherwise aStaleWindowSlotError).
Two sources ship:
ResidentCSWindowSource(the default). The entry points build it from their per-step arguments, so every window stays in memory and releasing one does nothing. It groups the steps by window once (one flux state per window, or one per step when the fluxes change within the window; aflux_scale ≠ 1is applied once per set) and validates each window once. The convection forcing, the diffusion operator and the layer thickness must be constant within a met window, as production refreshes them at the window's first step. Results are the same bit for bit as with the per-step vectors the source replaced.HostCSWindowSource, a streamed source.cs_adjoint_inputs(sim; residency = :host, device_slots = 2, host_budget_bytes)builds it: each completed window's captured met (the same arrays the resident capture keeps) is copied to host memory and its device copies are freed; the reset targets are kept on the host too. Pass it asmet_sourcewithnothingfor the three per-step flux vectors (the diffusion and convection-forcing keywords come from the source; the schedule carries no reset targets). The source keepsdevice_slotswindows on the device. Acquiring a window that no slot holds refills the least recently used slot without a lease, in place, from the host copy; a slot is synchronized before its last lease ends, so a refill never overwrites data a queued kernel still reads. Every refill increments the slot'sgeneration, whichrequire_currentcompares. Loads are synchronous (prefetching is a later step). One source serves any number of calls (every evaluation of an optimization);close(source)frees its slots.
A streamed source accepts only MetWindowCheckpoint (plain, split, or as the AutoTape constraint) with StateTape: each re-recorded segment references one met window. FullCheckpoint, StrideCheckpoint (fixed K, or with a resident tail whose records outlive their windows' leases), AirMassTape (held across evaluations) and an unconstrained AutoTape() are an ArgumentError before the forward run, also for a cost-only evaluation. The setup checks read the source's window layout instead of acquiring every window, and a Lin–Rood tape is sized from window 1 and the longest later window: a Lin–Rood step has a fixed record structure, so each step takes the layout of the counted step of its class (window 1 or later, first or last step of its window); a class those windows lack falls back to counting every step. Recording still throws TapeReservationExceeded if a step needed more.
Exactness: the slots hold copies of the resident arrays and the replay runs the same operators on them, so costs, simulated values, footprints and gradients equal the resident inputs' bit for bit on one CPU thread (test/core/test_cs_window_source.jl, and on two days of MERRA-2 C24 meteorology for the PPM and Lin–Rood schemes).
Host memory per C90 L72 Float32 window is about 135 MB (face fluxes 48.3, convection forcing 28.4, Kz panels 14.0 plus the operator's host Kz staging copy 14.0, layer thickness 14.0, reset targets 16.6 on average): about 3.2 GB per day, so a month of windows (about 100 GB) does not fit a process budget of 60 GB on a shared host. Device memory holds the slots (about 0.3 GB for two at C90) instead of every window.
The tape: AdjointTape
Every reverse-pass entry point (cs_surface_emission_footprint, cs_surface_emission_footprint_from_seed, cs_surface_flux_jacobian, cs_surface_flux_4dvar, cs_surface_flux_4dvar_optimize) takes one tape keyword, defaulting to AutoTape(). It resolves and reserves one concrete tape before recording. An explicit AdjointTape(; content, storage, checkpoint) fixes three typed axes; its constructor defaults are listed below (src/Tape/AdjointTape.jl):
| Axis | Choices | Default |
|---|---|---|
| content: what each record stages, how long a recording serves | StateTape() (what each operator's reverse reads of this forward run; recorded by every forward run), AirMassTape() (the air mass only; recorded once per call or optimization) | StateTape() |
| storage: where the staged states live | DeviceCSTapeStorage(), PinnedHostCSTapeStorage(), MmapCSTapeStorage(dir) | DeviceCSTapeStorage() |
| checkpoint: how much of the run is taped at once | FullCheckpoint(), StrideCheckpoint(K), MetWindowCheckpoint() | FullCheckpoint() |
Every storage and schedule is valid for the split-sweep schemes; the Lin–Rood tape supports device storage only; AirMassTape() takes FullCheckpoint() and a scheme whose reverse reads the air mass only (below). The 4D-Var driver reads the same choices from [adjoint.tape] (scripts/inversions/cs_4dvar.jl).
What the tape stages
The reverse of a split-sweep step reads, per operator, the air mass that entered it in the forward run (the sweeps rebuild each face coefficient from the donor air mass, the diffusion and convection solves and the air-mass reset read it too) and, for a monotone or CW84 PPM sweep, the limiter branches the forward took. A record stages each of these once (StateTape, the recorders in src/Adjoints/Footprint/TapeRecorder.jl):
| Record | Stages | Shares |
|---|---|---|
| sweep (X, Y, Z) | the air mass entering it; limited PPM: one byte of limiter branches per cell | — |
| palindrome center (diffusion) | the air mass at the center | the reverse half's first Z sweep reads the same slot |
| convection | — | the next step's first X sweep's slot, or the old air mass of a following :preserve_vmr reset; its own slot only before a :preserve_tracer_mass reset or at the end of a recording |
:preserve_vmr reset | the old and the target air mass | — |
| Lin–Rood records | every state they read (unchanged; device copies outside the pool for the horizontal operator) | nothing |
The sharing is exact, not an approximation:
The center's air mass is the buffer the first reverse-half Z sweep enters with: the midpoint writes only the tracer (surface fluxes, the diffusion of the mixing ratio), and no halo fill runs in between.
Convection leaves the air mass unchanged, and its reverse (
_apply_cs_convection_adjoint!: CMFMC, TM5 and the CMFMC matrix, which delegates to TM5) reads interior columns only. Until the next sweep, only the step-start halo fill writes the air mass, and only its halos; an air-mass reset is recorded before it runs, so its old air mass equals the convection's, halos included.For fixed limiter branches the limited PPM face flux is linear in the tracer mass, and its derivative depends on the tracer mass only through those branches. With
, the face flux for is where the edges
of cell 1 are the fourth-order edge (monotone) or CW84 eq. 1.7 with minmod slopes, reset by the monotonicity constraints (CW84 eqs. 1.10), and the CW84 curvature term (zero for the monotone limiter). Every piece is linear in once the minmod branch of each slope (zero, centred, forward, backward) and the profile branch of each cell (extremum, left edge reset, right edge reset, unchanged) are fixed; and give the rest. So the tape keeps one byte per cell and sweep ( PPMLimiterCodes, bits 0–1 the profile branch, bits 2–3 the CW84 minmod branch), computed when the record is made from the staged state with the predicates and values the reverse used to evaluate on the tracer mass, each cell's stencil clamped to its axis as the reverse clamps it (y at the padded panel edges, z at the column ends; the minmod is zero whenever two of its cells are equal, so the clamped stencil of a cell gives the code of every face that reads it). The reverse kernels (_ppm_face_coeffs) apply the derivative of the recorded branch in the operation order of the previous tracer-mass reverse; on one CPU thread the gradients are bit for bit those of the tracer-mass tape (the bitwise gate below; 0 of 1.6 million random faces differed in a direct comparison, all branches taken). One fused launch computes the codes of a sweep's six panels.
Tape per palindrome pass, with :preserve_vmr reset and :preserve_tracer_mass reset). cs_tape_byte_estimate counts it, and the mmap tier reserves it, with the recorder's own hooks (_CSCountingRecorder). On the C90 MERRA-2 day of the benchmarks (Float32, 48 steps,
| scheme, physics | before: states, MB per step (GB per day) | now: states, MB per step (GB per day) |
|---|---|---|
| upwind, slopes, PPM; no physics | 6, 95.6 (21.5) | 6, 95.6 (21.5) |
| upwind, slopes, PPM; convection + diffusion | 8, 127.4 (28.7) | 6.02, 95.9 (21.6): −25 % |
| monotone, CW84 PPM; no physics | 12, 191.1 (43.0) | 7.5, 119.4 (26.9): −38 % |
| monotone, CW84 PPM; convection + diffusion | 14, 223.0 (50.2) | 7.52, 119.8 (27.0): −46 % |
States are air-mass-state equivalents (a code panel counts 1/4); a day is 225.14 steps. CMFMC convection and diffusion every step, CFL subcycles of the replay (one pass per step on this day). The counted bytes equal the bytes of a recorded device tape (first 4 steps), and cs_tape_byte_estimate equals the count.
The record of a limited PPM sweep makes one code launch in place of six tracer-mass copies, and the center and convection records make none in place of six copies each: per step with convection and diffusion, 84 staging launches become 42 for limited PPM and 48 become 36 for the linear schemes. The reverse pass launches the same kernels as before, reading one byte per cell instead of the tracer mass.
AirMassTape() is for the schemes whose reverse reads the air mass only, tape_dependence(scheme) isa AirMassDependence: UpwindScheme(), SlopesScheme(NoLimiter()) and PPMScheme(NoLimiter()), whose sweeps are linear in the tracer mass; the reverse of every other operator with an adjoint (convection, diffusion, surface fluxes, resets) reads only the air mass, the met forcing and the clock. Its tape does not depend on the tracer or the emissions, so the first forward run of a call records it and every later forward run of the call (the later evaluations of cs_surface_flux_4dvar_optimize) runs without a recorder and walks it. Before a reuse the call recomputes the forward run's identity and compares it with the recording's: the grid, the number of taped steps, the met windows (window, step length and clock of every step), the scheme, step plan and operators, and content checksums of the met inputs (initial air mass, face fluxes, convection forcing, diffusion layer thickness, and the interiors of the reset targets, whose halos a reset refreshes in place; a position-weighted wrapping sum of bit patterns, the same on any backend); and the tape pool's generation. Device reductions collect all checksums into one result vector with one host transfer per evaluation. The checksums detect permutations but remain a within-runtime guard, not a collision-free fingerprint. Holding the tape also rejects records with tracer payloads. A difference is an ArgumentError naming it. Limited PPM and Lin–Rood (TracerDependence) with AirMassTape() are an ArgumentError before any forward run, as is AirMassTape() with StrideCheckpoint or MetWindowCheckpoint (their windows are re-recorded from tracer-dependent checkpoints in every reverse pass). On one CPU thread (C32 L20 Float64, 8 steps, upwind with TM5 convection and diffusion, a three-evaluation optimization, before the position-weighted checksum change) there was no measurable difference with a CPU device-array tape (min-of-three −0.4 %, within run-to-run spread), and an mmap evaluation took 1.5 % less time; the costs were the same bit for bit. GPU timings remain pending. With flux_scale ≠ 1, the held tape retains the first evaluation's scaled flux copies throughout the optimization; later evaluations allocate another set, so peak scaled-flux memory is twice one set.
Checkpoint schedules
| Policy | Memory | Recompute |
|---|---|---|
FullCheckpoint | O(N) state snapshots | none — fastest reverse pass |
StrideCheckpoint(K) | one K-step window plus N/K checkpoints | one extra forward run |
StrideCheckpoint(K; resident_tail = n, snapshots = PinnedHostCSTapeStorage()) | the resident tail, one head window and host tracer/air-mass checkpoints | re-records the head only |
MetWindowCheckpoint(; split_steps = 0, snapshots = PinnedHostCSTapeStorage()) | the longest met window (or split_steps-bounded piece) plus one checkpoint per segment, tracer/air mass on the host by default | one extra forward run |
MetWindowCheckpoint places its checkpoints at the met-window boundaries of the step schedule (CSStepSchedule.steps_per_window, variable in real binaries: 2–3 steps per window at C24, 5–6 at C48 and 8–11 at C90 in the first week of December 2021 of the MERRA-2 binaries), so no segment straddles two met windows and a segment's tape refers to one window's met inputs only, the property a streamed reverse pass needs. split_steps > 0 cuts a window of n steps into cld(n, split_steps) pieces of nearly equal length, never across a window boundary; a run that ends inside a met window ends its last segment there. It uses the StrideCheckpoint driver with a different segment list, built in one pass from the met window of every step. The pool reserves the largest per-type count over the segments; there is no resident tail. Explicit AdjointTape(; checkpoint = MetWindowCheckpoint(...)) and AutoTape(; checkpoint = MetWindowCheckpoint(...)) (sized and checked against the budget, then reserved) are supported; unconstrained AutoTape() does not consider it, so its choices are unchanged. On one CPU thread the 4D-Var cost, simulated values and gradient equal FullCheckpoint's bit for bit on 2 days of C24 MERRA-2 binaries (ppm_linear and linrood7, CMFMC convection and Holtslag–Boville diffusion), as do the bitwise gate's variants.
The schedules share one driver per policy for every scheme family; a checkpoint is a replay snapshot (tracer and air mass with halos plus the persistent operator state), so a restart inside a met window runs that window's remaining steps and window-end stages exactly as the recording run. StrideCheckpoint records each window once and walks it for every adjoint start (all objectives of a Jacobian). On one CPU thread every schedule and tape storage reproduces FullCheckpoint with device storage bit for bit; the bitwise gate below checks it. There is no logarithmic-memory schedule: the bisection RevolveCheckpoint was removed (it measured 2.0–2.1× the time of StrideCheckpoint with no lower device peak); an optimal binomial schedule will be added when a case needs it.
Tape storage and its pools
The tape records can live on the device, in pinned host memory, or on disk. AutoTape() tries device storage first; supplied fields constrain selection. Each call reserves its runtime pools from the resolved storage (src/Tape/TapeStorage.jl, HostTapeArena.jl, MmapTapeStorage.jl), records every tape of the call into it (each stride window rewinds it and reuses its memory), and releases it explicitly when it returns: device arrays go back to the GPU pool and pinned host memory to the system then, not at a later garbage collection. cs_surface_flux_4dvar_optimize keeps one pool for all its evaluations. A record read after its pool was rewound or released throws a StaleTapeSlotError. The pinned-host pool reserves its host memory and registers its chunks with the GPU driver before recording, so staging a state copies into memory that is already pinned. Staging and reads are synchronous copies; the read caches are reserved too.
Measured on an L40S (C90 MERRA-2, 48 steps of 7.5 min, convection and diffusion, Float32, single runs comparing the pool-reuse implementation against the earlier per-window tapes, before AutoTape reservation):
| before | after pool reuse | |
|---|---|---|
device peak, StrideCheckpoint, upwind / monotone PPM | 7.13 / 11.38 GiB | 2.35 / 3.03 GiB |
device peak, 4-evaluation optimization, device FullCheckpoint / StrideCheckpoint (upwind) | 22.5 / 22.5 GiB | 7.3 / 2.9 GiB |
| pinned-host re-record of a tape into its pool | 29–48 ms/step | 9.7–13.9 ms/step (≈ 24 GB/s device-to-host) |
pinned-host footprint or evaluation, StrideCheckpoint / FullCheckpoint | — | 50–56 % / 4–19 % less time |
optimization evaluation, mmap / pinned-host FullCheckpoint | — | 55–56 % / 42–44 % less time |
| single device-tape call | — | 0–2 % more time (the tape is freed inside the call) |
The on-disk tier needs a scratch directory; there is no default (a C90 day of PPM tape is tens of GB, more than a typical /tmp). Before recording, the call sizes the largest tape from the binary schedule or one cached CFL/Lin–Rood counting replay, checks that dir has that much space plus 10 %, and reserves an anonymous file with fallocate. The file is mapped once, reused within its reservation, and unmapped and closed when the call returns. An entry point raises TapeReservationError if an explicit reservation fails; Auto tries another permitted candidate. Recording beyond the reservation raises TapeReservationExceeded. Reserved extents on ext4 or XFS protect writes against a full-disk SIGBUS; file systems that cannot reserve in-place writes (including ZFS) are rejected by name. Tapes are not persisted.
Bitwise gate of the tape
test/core/test_cs_adjoint_tape_bitwise.jl runs a pairwise set of ten configurations in a single-threaded subprocess (test/helpers/cs_adjoint_tape_harness.jl): upwind, unlimited slopes and PPM, monotone and CW84 PPM, Lin–Rood, Float64 and Float32, TM5, CMFMC and CMFMC-matrix convection at substep and window cadence, both diffusion couplings, every air-mass reset mode and CFL subcycles. The fields are rough (random values, spikes, exact zeros and ties, sign changes; fluxes from a random streamfunction per panel plus noise; nonzero emission rates), and the test requires every branch of the monotone profile limiter and of the CW84 minmod slopes to occur in the limiter codes of the recorded tape, per axis and next to the panel seams. Footprints, initial adjoints, seeded and multi-objective footprints (the Jacobian also under StrideCheckpoint, whose windows serve both objectives), the 4D-Var cost, simulated values and gradient (with a co-sample after the last assimilated step) and a two-iteration gradient-descent optimization (whose evaluations share one tape pool) of every storage × schedule variant (including MetWindowCheckpoint with and without split met windows, with host and device snapshots, on met windows of 2, 3 and 2 steps), and for the linear schemes of AirMassTape() (the optimization's later evaluations reuse the first one's tape), must equal the default tape's reference bit for bit, and the reference must equal the SHA-1 digests recorded from main on the reference host (test/fixtures/cs_adjoint_tape_digests.toml). Main recorded the tracer mass of every limited sweep, so the gate holds the limiter codes, the shared center and convection slots and the reused air-mass tape to the gradients of the uncompacted tape. Two of the configurations also evaluate every observation operator of the 4D-Var (a time window, placed points by height and by pressure, averaging-kernel columns with the rebin and the hat projection, a cell average, a column the surface-pressure screen leaves out, so that the reverse pass starts before the end of the tape, and a co-sample after it), with background terms and in the preconditioned space. Two others take their inputs from cs_adjoint_inputs of a production DrivenSimulation with rough met windows, so the gate also covers the capture: each met window's shared fluxes under CFL subcycles, full-window flux storage scaled per window, CMFMC sub-steps and per-window diffusion layer thickness, and under the binary window contract with a window-end reset. The full matrix (50 configurations, two Lin–Rood ones and the two captured ones) is the opt-in test/diagnostic/test_cs_adjoint_tape_bitwise_full.jl. test/core/test_cs_tape_compaction.jl checks which records share a slot, that the counting recorder and cs_tape_byte_estimate count the recorded tape exactly, and the bytes per step.
Inversion scaffold
src/Adjoints/Inversion/ ships:
| Module | Surface |
|---|---|
Covariance.jl | DiagonalCSCovariance, IsotropicGaussianCSCovariance, apply_B_half!, apply_B_half_adjoint! |
Preconditioning.jl | apply_preconditioner!, LinearOptimType, LogNormalOptimType |
Optimizer.jl | AbstractCSOptimizer, CSGradientDescent, CSLBFGS (via multiple-dispatch surfaces) and their shared stop rules |
Jacobian.jl | Footprint-Jacobian assembly for batched observation operators |
CostGradient.jl | 4D-Var cost / gradient evaluator with preconditioning |
Observations.jl, ObservationColumns.jl, ObservationBinding.jl, ObservationsIO.jl | Typed observation surface (time sampling, placed point objectives, column meteorology, stencils) + on-disk schema v2 |
DeparturesIO.jl | Departures-file IO |
These are all on CI. Full inversion tests: test_cs_4dvar_single_sweep.jl, test_cs_4dvar_placed_observations.jl, test_cs_gradient_checks.jl, test_cs_lbfgs.jl, test_cs_optimizer_stop_rules.jl, test_cs_inversion_driver.jl, test_cs_inversion_truth_recovery.jl, test_cs_iteration_log.jl, test_cs_observations_io.jl, test_cs_observation_binding.jl, test_cs_departures_io.jl, test_cs_covariance.jl, test_cs_preconditioning.jl, test_cs_optimizer_dispatch.jl.
Single-sweep 4D-Var gradient
cs_surface_flux_4dvar computes the observation term of the cost and its gradient with one forward run and one reverse pass, whatever the number of observations, as TM5-4DVAR does: the forward run that samples the observations also records the tape the reverse pass walks.
Observations as linear functionals. An observation
with weights from the replayed air mass at each CSLayerMeanObjective and for the layer a CSPlacedPointObjective reads at that step (CSColumnMeanObjective, and CSRetrievalColumnObjective) has
One reverse sweep. Write
run from the last assimilated step _CSStepEndRecord, after the convection record); the reverse walk adds
The forcing entries are grouped by step, panel and cell; the injection kernel gives each cell one work item, which adds the cell's entries in input order, so the injection is deterministic without atomics.
One forward run. The forcing needs every assimilate = true (co-samples after it run the forward but are not taped): the whole tape with FullCheckpoint, the state at every StrideCheckpoint(K). After the forcing is assembled, the reverse pass starts from zero at the last assimilated step FullCheckpoint one evaluation therefore costs one forward run and one reverse pass (previously a forward run for StrideCheckpoint adds the re-recording of its head windows, as for a footprint. CFL-driven schedules and Lin–Rood add one cached sizing replay per runtime; binary split-sweep schedules use their closed-form size, including for mmap storage. The gradients, the cost and the simulated values are bit for bit those of the two-run evaluation (test/core/test_cs_adjoint_tape_bitwise.jl). evaluation = CSCostOnly() runs the forward run alone, without a tape, for callers that need the cost or the simulated values but not the gradient. Steps after the last assimilated observation do not affect the cost and get a zero gradient. tape chooses how the tape is stored. test/core/test_cs_4dvar_single_sweep.jl checks the gradient against one footprint per observation (the previous algorithm, rebuilt in the test) for upwind, unlimited slopes and PPM, monotone PPM and Lin–Rood with diffusion of both surface-flux couplings, TM5 and CMFMC convection and the Full and Stride checkpoint schedules, and for CW84-limited PPM and Lin–Rood with the FV3 vertical sweep (
cs_surface_flux_jacobian likewise records its tape (with StrideCheckpoint each window) once and walks it once per objective; each walk is the one a separate cs_surface_emission_footprint call makes.
Observation operators: point samples in the column and time windows
Observation files use schema v2 (schemas/cs_observations_v2.toml): Float64 coordinates, a kind ("point" for an in-situ sample, "column" for a column average), the vertical fields elevation_m, intake_height_m, altitude_m and pressure_pa (NaN when a record does not give them), a time_window_s, a quality flag and a model_sigma. bind_to_mesh turns each record into a CSObservation; its sigma is
Cell. The record binds to the cell that contains its point (the grid-box stencil), found with the forward observation sampler's locator, so a record is sampled and inverted in the same cell. Float32 coordinates (schema v1) could put a point within rounding of a cell edge into the neighbouring cell; v1 files are rejected.
Vertical placement. A point record becomes a CSPlacedPointObjective, placed once by the forward sampler's rule (Observations.resolve_placement) with the vertical_coordinates of the placement settings, in preference order (default height above ground, then pressure):
by its height above the true ground
: intake_height_m, elsealtitude_m − elevation_m, elsealtitude_mminus a DEM elevation at the point.is measured up from the model surface, whatever the model surface height: the model ground lies above or below the true ground, and a mountain station belongs in the model's lowest layers, not at its absolute altitude. Absolute altitudes are an explicit option ( absolute_altitude_above_agl_m);by its pressure
(a total pressure).
A point record that gives none of the coordinates in use is unplaced: an error, or dropped and counted with unplaced_records = "skip". A column record without a retrieval block becomes a CSColumnMeanObjective; one with a block becomes an averaging-kernel column.
The layer is chosen at every sampled state CSObservationColumnMet: model-top pressure Observations.sample_column_layer!. With the cell area
with the virtual temperature VIRTUAL_TEMPERATURE_FACTOR, 0.61) (pressure_basis = "total", the default). With pressure_basis = "dry", for meteorology without humidity, both are built from the dry interfaces
Time sampling. Step
steps fully inside the window weigh out_of_range_policy); ClampOutOfRange keeps a record outside the run: the part of its window inside the run, truncated and renormalised, or the first or last step when it has no window or the window misses the run (departure rows mark such records clamped). Window records need the run length (nsteps), which bounds their steps.
This time sampling differs from the forward observation sampler's: the sampler takes its samples at met-window ends (a linear blend of the two ends around the record time, or the nearest end), while the inversion takes the state at the end of the model step containing the record time (up to one step
CS4DVarResult.stencils returns, per observation, the cell, the sampled steps and weights, the level read at each step, the placement code and the height or pressure that placed it; build_departure_set joins them to the records (by id) in schema-v2 departure files (schemas/cs_departures_v2.toml).
Relation to TM5-4DVAR. Matched: the sample is taken right after a fixed operator (here the end of the step, after convection) and its forcing enters just before that operator's transpose, in one reverse sweep; windows are Δt/ΣΔt means with weights fixed at binding; the horizontal stencil is fixed per observation (TM5 also offers slopes and trilinear stencils; ours is the grid box, a type that can gain a trilinear form for both the sampler and the inversion); the vertical stencil is chosen from the same meteorology forward and in reverse. Different: points are placed by their height above the true ground measured from the model surface (TM5 compares sea-level altitudes with heights on the model orography and never samples layer 1); pressure placement is in the adjoint too (TM5's adjoint uses the altitude only, so its gradient of pressure-coordinate points is wrong); a step partly inside a window counts its overlap (TM5 counts the half steps fully inside); the basis is dry; and records carry their flag, elevation, intake height and pressure.
test/core/test_cs_4dvar_placed_observations.jl checks parity with the forward sampler on one state (same layer and value through build_observation_sampler in nearest-window mode, records sampled at the window end that closes their model step, and through bind_to_mesh + cs_surface_flux_4dvar), a 10 m intake against a 5 km aircraft sample, total against dry pressure placement, layers that follow the replayed air mass step by step, a window observation's value and gradient against the Δt-weighted sum of its single-step observations (
Averaging-kernel columns
A retrieved column-averaged dry mole fraction (OCO-2, GOSAT, TROPOMI, TCCON) is not the column mean of the true profile: the retrieval weights the atmosphere with its averaging kernel and fills in its prior where it has little sensitivity. A column record that carries a retrieval block (schema v2, schemas/cs_observations_v2.toml) is compared with the model through that retrieval's own vertical description, with the operator of TM5-4DVAR (deps/tm5-cy3-4dvar/base/f2py/src/averaging_kernels.F90, the OCO-2 routine applyaveragingkernel and the rebin inv_rebin). A block describes either layer means (retrieval_mapping = "layer_rebin", this section) or values on levels with the profile linear between them ("hat_levels", the OCO-2/OCO-3 retrievals; see level retrievals). A layer block gives the retrieval's
interfaces
(Pa, total pressure), with the retrieval surface pressure and its top; pressure weights
with (checked to : a deficit would bias the column by ); the column averaging kernel
, normalized, so that on the retrieval layers; the prior profile
(dry mole fraction, mol mol⁻¹; files state the unit, ppm and ppb are converted). The operator adds it to the model's dry mole fractions, so the record value and errors and the transported tracer are in mol mol⁻¹ too: such a file states a mole-fraction unit on value,value_sigmaandmodel_sigma(converted to mol mol⁻¹), and a record must be an absolute column average, a value in (0, 1] with errors not above it;optionally
retrieval_profile_sigma, an uncertaintyof the model profile on the retrieval layers (mol mol⁻¹), for the model-error term below.
bind_to_mesh turns such a record into a CSRetrievalColumnObjective. At every sampled state the model's interface pressures pressure_basis = "total", the default; retrieval pressures are total pressures), or the dry interfaces ("dry"). Model surface and top are Observations.retrieval_column_weights!):
- Stretch. The model interfaces are mapped linearly onto the retrieval's pressure range, the model surface onto the retrieval surface and the model top onto the retrieval top:
- Rebin. Each retrieval layer takes the pressure-weighted mean of the stretched model layers it overlaps:
with the outermost retrieval interfaces taken from the stretched model column (TM5's choice; they equal
- Column.
on the model's dry mixing ratios
The pressures depend on the meteorology only, so _linear_functional is the exact derivative of the evaluation; a window record takes the
What the stretch does physically. The stretch keeps every model layer's share of the column,
Surface-pressure mismatch policy. max_surface_pressure_mismatch_pa (bind_to_mesh keyword; [observations.placement] key of the inversion driver; default no limit) bounds "dry", unplaced_records = "error" (default) the 4D-Var stops and names the records; with "skip" the record is reported (simulated value, residual, its stencil with assimilated = false) but adds nothing to the cost or the gradient, and the number of such records is logged. The model surface pressure is known only at the sampled states, so the check runs in the 4D-Var's forward replay; it depends on the meteorology only, so the same records are left out in every iteration.
Model-error term. When the record gives a model-profile uncertainty retrieval_profile_sigma), the observation error is Observations.retrieval_model_error_variance): the operator's weights on the retrieval layers, squared, times the profile variance, the layers taken independent. It depends on the record only, not on the state or the meteorology, so it is fixed when the record is bound and the cost stays quadratic in every iteration (TM5 freezes its averaging_kernels.F90, line 669) evaluates
Diagnostics. The stencil of an averaging-kernel column (CSObservationStencil, placement code RETRIEVAL_COLUMN_PLACEMENT_CODE = −3, level 0) carries assimilated; departure files add them with the profile model sigma (schemas/cs_departures_v2.toml).
Relation to TM5-4DVAR. Matched: the stretch (including its averaging of the two offsets), the overlap matrix of inv_rebin with its outer interfaces, the column and its per-layer forcing; the test reproduces values computed with TM5's Fortran on fixed columns to matmul summation order). Different:
the operator is in the model, a linear functional of the tracer mass at each sampled step (a window record averages the operator over its steps), where TM5 writes the Δt-averaged profile and surface pressure to a track file and applies the kernel once in Python;
dry basis:
is the dry mixing ratio and the interfaces are total pressures rebuilt from the dry air mass and the humidity; TM5 uses moist and of its moist surface pressure; the pressure weights come from the record and must sum to 1; TM5's OCO-2 routine computes
, which leaves out the column above a retrieval top above 0 Pa; an explicit mismatch policy, where TM5's OCO-2 path has none and its CH4 TROPOMI path sets a huge σ above a tolerance (the same effect as
"skip");a rebin that fails TM5's checks (possible only for a retrieval layer thinner than the stretch's rounding) is an error, not a silent zero departure;
the model-profile uncertainty is given on the retrieval layers by the record; TM5's CH4 TROPOMI path uses the spread of the modelled profile on model layers from its track file.
test/core/test_cs_4dvar_retrieval_columns.jl checks agreement with TM5's Fortran (reference values computed with averaging_kernels.F90 itself, with the model surface below and above the retrieval's and the retrieval top above and below the model top) and with a line-by-line transcription on random columns, conservation by the rebin, the pressure-weighted and air-mass-weighted column means for
Level retrievals (OCO-2, OCO-3): the hat projection
The OCO-2 and OCO-3 retrievals (Lite files and the v11 MIP 10-second files) give their prior and column averaging kernel on 20 levels, retrieval_mapping = "hat_levels" (Observations.HatLevelProjection) stores the 20 level pressures, weights
Projection. The model interfaces are stretched as for layer retrievals, the model surface onto the bottom level and the model top onto the top level (
each stretched layer's dry air
with xco2_apriori, carried by the converter and the forward sampler's reader (retrieval_prior_column in observation files); a record without one uses
Why the projection. The basis contains the constants (the hats sum to 1 over the stretched column), so the projection preserves the column integral: the rows of
The top level. The top level sits at
- The stretch maps the whole model column, from its top (about 1 Pa for
GEOS, 0 for ERA5) to its surface, onto
TM5-4DVAR's 19 layers. Observations.tm5_layer_column builds TM5-4DVAR's layer form of the same record (proj/tracer/CO2/py/Observations.py, 7016–7052; Satellite.py, 707–717): the 20 levels as the interfaces of 19 layers, the kernel and prior interpolated to the layer midpoints, the weights mapping = Observations.LayerRebin() or --mapping tm5, forward sampler averaging_kernel_mapping = "tm5"). For a +10 ppm boundary layer below
The MIP point formula. The MIP protocol writes the column as
Tests. test/core/test_retrieval_hat_projection.jl: the projection matrix against an independent construction (exact integration of the hats and their products), rows summing to 1, column conservation with the hat integrals, a piecewise-linear profile reproduced at every level, ends and kinks included, within test/core/test_cs_4dvar_oco2_mip.jl: the single sweep against a seeded footprint per observation and step for level columns, windows and TM5-mode records (
OCO-2 MIP records: converter, co-sampling, cell averages
Converter. read_oco2_mip_observations(path; ...) reads an OCO-2 or OCO-3 v11 MIP 10-second file (OCO2_b11.2_10sec_GOOD_r2/r3.nc4, OCO3_b11_10sec_GOOD_r2.nc4) into schema-v2 column records with a level block, and convert_oco2_mip_observations(path, output; partition = :day) writes one file per day ({YYYYMMDD}) or month ({YYYYMM}):
julia --project=. scripts/preprocessing/oco2_mip_to_observations.jl \
OCO2_b11.2_10sec_GOOD_r2.nc4 'obs/oco2_mip_{YYYYMMDD}.nc' \
--start 2019-01-01 --stop 2019-02-01 --data-types LN,LG,OG --assimilate-flags 1sounding_id → id; date[1:6] → date_components (truncated to the second, as TM5 reads it); latitude, longitude; kind = "column"; altitude → elevation_m; time_window_s = 0; xco2_2019_scale, xco2_uncertainty and model_error (or a constant, --model-sigma) → value, value_sigma, model_sigma (ppm → mol/mol); the levels (xco2_apriori. Every record of the time range is written: flag = 0 when its assimilate_flag is in the experiment's set (--assimilate-flags, 1 by default) and its data type too (--data-types: LN, LG, OG by default; SAM names OCO-3's snapshot area maps, data_type = 0), else flag = 1 + assimilate_flag (1 evaluation-only scenes, 2 assimilable but outside the data types, 3 withheld). instrument_type is <instrument>_<data type> (OCO2_OG); the files record the source file, the options and the mapping as root attributes. OCO-2 and OCO-3 sounding ids can coincide, so keep the instruments in separate sets.
Forward-only co-sampling. The MIP needs co-samples of every record, withheld and evaluation-only ones included. bind_to_mesh(...; flagged_records = "cosample") (CosampleFlaggedRecords; the inversion driver's [observations].flagged_records) binds records with a nonzero flag as co-samples, CSObservation(...; assimilate = false): the forward replay simulates them, CS4DVarResult reports their simulated values, residuals and stencils (assimilated = false), but they add nothing to the cost or the gradient, are not screened by the surface-pressure limit, and do not extend the taped run: the cost is bit for bit that without them, and the reverse pass receives bit-identical forcing and tape length (the gradient is bit for bit that without them single-threaded; with several threads the adjoint kernels are not bit-reproducible from one call to the next, at about flag (build_departure_set), so one file holds the co-samples of all records. The default ("drop") is unchanged.
Cell averages. About 59 % of the assimilated OCO-2 10-s records share a C90 cell with another record of the same orbit (1.43 per orbit and cell, about 9 s apart). cell_averaging = CellAverage(; time_tolerance_s = 60, correlation = 0) ([observations.cell_averaging], mode = "average") averages the assimilated column records of one tracer, cell and step sampling that lie within time_tolerance_s of the earliest record of their group. With value_sigma):
correlation between distinct spans (0: the within-span correlation is already in model_sigma and the profile term) is added once, not reduced. CSCellAverageObjective, exact for the linear operators: its gradient is the cell_average_id, and the average is a row of its own, the term of the cost (placement code −4, cell_average_id its number 1, 2, …, a row id above every record id of the observation set, value_sigma, the model error in model_sigma, cell_average_correlation): over the assimilated rows, normalized_departure² max_surface_pressure_mismatch_pa = Inf (a CSCellAverageObjective built by hand is checked the same way). The alternative, inflate_cell_model_error(set, mesh, t_start, dt; ...) (mode = "inflate_model_error"), keeps the records and multiplies each record's model_sigma² by the number
Forward sampler. An oco2_lite source of [output.observations] with averaging_kernel_tracers = ["co2"] (opt-in) also reads each sounding's retrieval (Observations.read_oco2_retrieval_columns) and writes co2_ak_column, the same operator (averaging_kernel_mapping = "hat" or "tm5") on the sampled profile and the interface pressures of pressure_basis. Without the key the output is unchanged. The test checks that, in nearest-window mode, the sampler's value equals the 4D-Var's simulated value of the same record converted to schema v2 (
What is not yet shipped
| Item | Notes |
|---|---|
| Logarithmic-memory checkpointing | Only FullCheckpoint, StrideCheckpoint(K) and MetWindowCheckpoint() ship; the bisection Revolve was removed. An optimal binomial (Griewank–Walther) schedule will be added when a case needs log-memory snapshots (met streaming). |
| Optimized/clamped convection adjoints | CMFMC clamp = true and TM5/CMFMC-matrix collaborative, truncated, or merged solves are rejected by the footprint API until their exact branches are taped and transposed. |
| TM5-4DVAR cross-validation | Synthetic truth-recovery via test_cs_inversion_truth_recovery.jl is on CI; a side-by-side parity run against TM5-4DVAR on real data has not been published. |
| Inversion driver on transport binaries | scripts/inversions/cs_4dvar.jl binds observation files only on its synthetic meteorology (synthetic_hydrostatic); a 4D-Var on transport-binary meteorology is assembled with the Julia API (bind_to_mesh, CSObservationColumnMet, cs_surface_flux_4dvar). |
| Tangent-linear model | Forward TL is not exposed as a separate driver. If you need it, use the reverse pass plus identity seeding. |
Adjoint-readiness in the forward design
Three concrete forward-design choices that pay off in the adjoint:
Vertical diffusion — generic Kz kernels expose the tridiagonal coefficients
(a, b, c)and transpose the backward-Euler solve with its mass/VMR scaling. The precomputed Dkg mass path exposes the retention fractions of two conservative bidiagonal solves. Its reverse applies those passes' transposes in reverse order, preserving a constant total-mass gradient exactly for positive carrier masses.Convection (CMFMC + TM5) —
apply!takes aConvectionForcingcarrier explicitly so the operator does not callcurrent_timeinternally; this keeps the operator pure-functional in the time variable. The TM5 reverse pass rebuilds the same per-column matrix and solves with the transposed LU factors.Advection — the adjoint composes each operator's transpose in reverse order. The palindrome helps organize that reversal, but forward transport is not its own inverse. Stored states supply the limiter branches and reconstructed-face sensitivities needed by the reverse pass.
How to use the adjoint today
The maintained command-line path is the inversion driver:
julia --project=. scripts/inversions/cs_4dvar.jl \
config/inversions/example_synthetic.tomlThat synthetic-only configuration owns observations, controls, covariance and optimizer choices, and an [advection] table that is parsed like a forward run's (limiter = "none", the unlimited PPM, is accepted only here). Unknown tables and keys are errors. [observations] takes inline entries or a schema-v2 observation file, whose point records [observations.placement] places in the column of the synthetic_hydrostatic meteorology (the keys of [output.observations] placement, parsed by the same code), and [adjoint.tape] defaults to automatic selection (AutoTape); storage and checkpointing accept "auto", or constrain storage to "device", "pinned_host", "mmap" and checkpointing to "full", "stride". stride and resident_tail accept "auto" or an integer; snapshots is "device" or "pinned_host". budget_gb overrides the measured device tape/snapshot budget and its safety margin. scratch_dir enables mmap with automatic storage and is required for explicit mmap storage. content = "state" | "air_mass" selects the content axis. The resolved pools and snapshots are reserved before recording. The binary-window size uses the per-window step schedule, while CFL and Lin–Rood counts are cached once per runtime. See Tape and checkpointing for candidate order, memory headroom, typed reservation errors and logging. It does not expose diffusion, convection or real-binary settings. For the lower-level Julia API, start with the footprint tutorial, then test/core/test_cs_inversion_truth_recovery.jl for a larger inversion assembly. Pass tape = AdjointTape(; checkpoint = StrideCheckpoint(K)) to fix a K-step re-recording schedule. resident_tail = n retains the final n steps recorded by the forward run; snapshots = PinnedHostCSTapeStorage() moves the head's tracer/air-mass checkpoints to host memory. MetWindowCheckpoint() re-records one met window at a time (split_steps = k bounds a segment to k steps). Lin–Rood tapes currently require DeviceCSTapeStorage(); split-sweep schemes also support PinnedHostCSTapeStorage() and MmapCSTapeStorage(dir).
Where to read next
Validation status — what the forward model has been validated against.
Conservation budgets — the explicit verification tests the forward operators pass.
Adjoints on top of the binary — TM5-4DVAR / GIGC-adjoint user perspective on how the pipeline maps to those workflows.