Skip to content

Add a benchmark script of the operational cases (synthetic data) - #16

Merged
matschaer merged 3 commits into
mainfrom
perf/benchmark-script
Nov 23, 2026
Merged

matschaer merged 3 commits into
mainfrom
perf/benchmark-script

Conversation

@matschaer

@matschaer matschaer commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Adds benchmarks/operational_cases.py, a benchmark of the operational uses of grid-process on synthetic data of operational size, to compare a branch with main before merging changes that can affect runtime, memory or results.

  • Cases (39), with the operational settings of the applications:

    • data4web pipelines, interp2poi(try_reg=False) to 5 622 POIs: idw, nearest_alt, nearest, temp, snowlim, upscaled;
    • seamless weather provider, slice_coarsen then interp2grid(try_reg=False) to the Swiss 2 km grid: nearest_alt, idw, temp_fixgrad;
    • static fields: horizon (int8, 25 m, dask) to the POIs with nearest, topographic descriptors to the POIs with linear, and the 50 m DEM to the 2 km grid with linear.

    Sources: IFS-ENS, ICON-CH1/CH2-EPS (including the snow limit with NaN and the lake-masked temperature to the POIs), ICON-CH2-EPS in LV95, INCA.

  • Native ICON (the applications may switch to it, e.g. a Swiss cut-out from polytope):

    • counterparts of the ICON cases on the native points within the area of the grid database grids: about 113 000 points for ICON-CH1, 28 200 for ICON-CH2, with the same members, steps, settings and NaN patterns;
    • one whole-domain case each for ICON-CH1 and ICON-CH2, as upper bounds (not operational uses).
  • Measurements, each case in fresh processes:

    • runtime of the first call (cold caches, as in the cron jobs) and of the repeated calls (warm caches);
    • peak memory (resident, and tracemalloc in a separate process);
    • the load average;
    • checksums of the outputs.
  • Synthetic data: same structure, CRS attributes, sizes, dtypes, chunking and NaN patterns as the operational files:

    • snow limit: 30 % NaN values, 24 % of the points NaN for all members and steps;
    • lakes: 2 % of the points;
    • grid database radiation: NaN at the first step.

    A single orography function gives the altitude of all grids and POIs.

  • Commands:

    • list;
    • run, with --case (shell patterns), --repeat, --grid-process (benchmark a worktree of main), --save-outputs, and --data-dir (real files instead of the synthetic data);
    • compare A B: runtime and memory ratios per case, and outputs identical or the size of their differences;
    • fetch-native --out DIR: downloads a run of native ICON-CH1/CH2-EPS from the open data of MeteoSwiss once (all members and lead times; needs poetry install --with example), as real data for run --data-dir.

    run never downloads, so both sides of a comparison use the same data. A native case on a real file with fewer members or lead times than operational is noted.

  • Checked against the real data:

    • The grid database cases are within about 20 % in runtime and 5 % in peak memory.
    • The native cases on an open data run are within about 5 % in peak memory, and up to 35 % faster than synthetic.
    • The static cases are dominated by reading zarr, which the synthetic dask arrays do not reproduce: the real horizon takes 64 s cold vs 6.8 s synthetic. They still compare grid-process versions (slicing, indexing, dask graph); use --data-dir for absolute times.
  • A full run takes about 12 minutes.

  • test/test_benchmarks.py smoke-tests every case at a small scale, the NaN patterns (grid database and native), the conversion of the open data and the lake masking (without network), and run + compare end to end (about 30 s in CI).

  • AGENTS.md:

    • the benchmark protocol now points to the script, with fetch-native;
    • it describes the native cases, and the whole-domain cases as upper bounds;
    • the example notebooks are examples, not the operational cases;
    • only interp2poi drops the points that are NaN in all fields, on purpose: POIs are on the ground, while lakes stay in the destination grid of interp2grid.

No change to the library.


Related issue

None


Checklist

  • Code is well documented and follows project conventions (linted, formatted)
  • CHANGELOG updated (if applicable): not applicable, development tooling only
  • License header is added to all new files
  • For a new contributors, their name has been added to the AUTHORS file: not applicable
  • No sensitive data or secrets are exposed: the internal data paths stay in the untracked CLAUDE.local.md
  • Unit tests added covering the new code

🤖 Generated with Claude Code

Mathieu Schaer and others added 3 commits November 19, 2026 17:50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o the benchmark

The applications may switch from the grid database ICON fields to native ICON (e.g. a Swiss cut-out from polytope):
native counterparts of the grid database ICON cases on the native points within the grid database area, and one
whole-domain ICON-CH1 and ICON-CH2 case as upper bounds. The lake-masked grid cases are removed (only data4web masks,
and interp2grid keeps all-NaN points). AGENTS.md: native cases, example notebooks, NaN masking in interp2poi only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
run stays offline: fetch-native downloads a run of native ICON-CH1/CH2-EPS (all members and lead times, by blocks
of lead times into one float32 array: 3.8 GB peak) once and writes the --data-dir files, with HSURF and the land
fraction (lake mask of data4web). A real native file with fewer members or lead times is noted in the results.
Synthetic native radiation has no NaN, as the open data. AGENTS.md: the intended NaN difference between
interp2poi (POIs on the ground) and interp2grid (lakes kept in the destination grid), and fetch-native.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matschaer
matschaer merged commit e271cda into main Nov 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant