Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/initial integration tests #151

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8207585
test: test training training cycle
theissenhelen Jan 24, 2025
ce716ec
WIP: model parametrized training cycle
theissenhelen Feb 10, 2025
0624a97
WIP
theissenhelen Feb 11, 2025
218f871
fix: test working with hydra
theissenhelen Feb 12, 2025
6a94e63
WIP parametrize fixtures
VeraChristina Feb 12, 2025
e7e70b3
ci: first draft for integration tests
theissenhelen Feb 12, 2025
0cd9389
clean up
VeraChristina Feb 14, 2025
e5bcbce
WIP add stretched grid test
VeraChristina Feb 19, 2025
e06c6a9
WIP stretched grid fix paths
VeraChristina Feb 19, 2025
c605d77
WIP stretched grid exclude missing params
VeraChristina Feb 19, 2025
d636e78
WIP stretched grid debugging
VeraChristina Feb 20, 2025
5d1a3dc
Merge branch 'main' into test/initial-integration-tests
VeraChristina Feb 20, 2025
b32eca5
ci: self-hosted
theissenhelen Feb 21, 2025
51cdb96
WIP stretchec config dbugging
VeraChristina Feb 21, 2025
924b1fa
Merge branch 'test/initial-integration-tests' of github.com:ecmwf/ane…
VeraChristina Feb 21, 2025
c0b206b
WIP dont use flash attention
VeraChristina Feb 21, 2025
bdd0f49
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 21, 2025
c636990
WIP: action
theissenhelen Feb 21, 2025
030f829
WIP: action
theissenhelen Feb 21, 2025
fcbfff3
WIP
theissenhelen Feb 21, 2025
fd56333
WIP
theissenhelen Feb 21, 2025
b731bc4
WIP
theissenhelen Feb 21, 2025
c29157a
WIP
theissenhelen Feb 21, 2025
b555d1e
WIP
theissenhelen Feb 21, 2025
14c6f53
WIP
theissenhelen Feb 21, 2025
8fdf6eb
WIP
theissenhelen Feb 21, 2025
36b0176
WIP
theissenhelen Feb 21, 2025
a54a0a5
WIP
theissenhelen Feb 21, 2025
52b6a95
WIP
theissenhelen Feb 21, 2025
8450f4d
WIP
theissenhelen Feb 21, 2025
4c9969f
WIP
theissenhelen Feb 21, 2025
daca096
WIP
theissenhelen Feb 21, 2025
4b83003
WIP
theissenhelen Feb 21, 2025
474467c
feat: change to reusable workflow
theissenhelen Feb 21, 2025
6f5a1ab
WIP
theissenhelen Feb 21, 2025
ed65990
chore: move to integration folder
theissenhelen Feb 21, 2025
5c49a52
WIP pydantic fixes basic_config
VeraChristina Feb 21, 2025
d35cb58
WIP pydantic fixes stretched_config
VeraChristina Feb 21, 2025
bc3a9f9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 21, 2025
41a0cdd
WIP fix pydantic for basic config
VeraChristina Feb 24, 2025
9d7dfbb
WIP stretched grid debugging
VeraChristina Feb 24, 2025
b4893e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 24, 2025
36e788d
WIP debug stretched grid
VeraChristina Feb 25, 2025
ff22e1f
Merge branch 'test/initial-integration-tests' of github.com:ecmwf/ane…
VeraChristina Feb 25, 2025
62c5339
use less workers in stretched grid test
VeraChristina Feb 28, 2025
f316312
Merge branch 'main' into test/initial-integration-tests
VeraChristina Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: nightly-ci-integration-tests

on:
schedule:
- cron: "0 23 * * *" # every day at 22pm on default branch
workflow_dispatch:
push:
branches:
- main
- test/initial-integration-tests

jobs:
integration_tests:
uses: ecmwf-actions/reusable-workflows/.github/workflows/integration-tests.yml@add-integration-test-anemoi
with:
python-version: '3.10'
install-package: "-e ./training[all,tests] -e ./graphs[all,tests] -e ./models[all,tests]"
45 changes: 45 additions & 0 deletions tests/integration/basic_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
defaults:
- data: zarr
- dataloader: native_grid
- diagnostics: evaluation
- hardware: example
- graph: multi_scale
- model: gnn
- training: default
- _self_

no_validation: False
# diagnostics:
# plot:
# callbacks: []
hardware:
files:
dataset: aifs-ea-an-oper-0001-mars-o48-1979-19-6h-v6-testset.zarr
graph: test_graph.pt
paths:
data: https://object-store.os-api.cci1.ecmwf.int/ml-tests/test-data/samples/anemoi-integration-tests
output: ${oc.env:PWD}/tmp_output/

# number of GPUs per node and number of nodes (for DDP)
accelerator: auto
num_gpus_per_node: 1
num_nodes: 1
num_gpus_per_model: 1


model:
num_channels: 16
# processor:
# attention_implementation: scaled_dot_product_attention

dataloader:
limit_batches:
training: 100
validation: 100
training:
end: 1979-01-08 18:00:00
validation:
start: 1979-01-08 12:00:00

training:
max_epochs: 2
31 changes: 31 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest
from hydra import compose
from hydra import initialize
from omegaconf import OmegaConf


@pytest.fixture(
params=[
["model=gnn"],
["model=graphtransformer"],
[
"model=transformer",
"graph=encoder_decoder_only",
"model.processor.attention_implementation=scaled_dot_product_attention",
],
]
)
def architecture_config(request) -> None:
overrides = request.param
with initialize(version_base=None, config_path="", job_name="test_training"):
cfg = compose(config_name="basic_config", overrides=overrides)
OmegaConf.resolve(cfg)
return cfg


@pytest.fixture()
def stretched_config() -> None:
with initialize(version_base=None, config_path="", job_name="test_stretched"):
cfg = compose(config_name="stretched_config")
OmegaConf.resolve(cfg)
return cfg
141 changes: 141 additions & 0 deletions tests/integration/stretched_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
defaults:
- data: zarr
- dataloader: native_grid
- diagnostics: evaluation
- hardware: example
- graph: stretched_grid
- model: graphtransformer
- training: default
- _self_

no_validation: True

diagnostics:
plot:
callbacks: []

dataloader:
dataset:
cutout:
- dataset: ${hardware.files.dataset}
thinning: 25
- dataset: ${hardware.files.forcing_dataset}
adjust: all
min_distance_km: 0
num_workers:
training: 2
validation: 2
batch_size:
training: 2
validation: 2
limit_batches:
training: 2
validation: 2
training:
start: "2017-02-01"
end: "2017-02-07"
validation:
start: "2018-01-01"
end: "2018-01-04"

data:
forcing:
- "cos_latitude"
- "cos_longitude"
- "sin_latitude"
- "sin_longitude"
- "cos_julian_day"
- "cos_local_time"
- "sin_julian_day"
- "sin_local_time"
- "lsm"
# features that are only part of the forecast state
# but are not used as the input to the model
diagnostic:
- tp
remapped:
normalizer:
default: "mean-std"
std:
- "tp"
min-max:
max:
none:
- "cos_latitude"
- "cos_longitude"
- "sin_latitude"
- "sin_longitude"
- "cos_julian_day"
- "cos_local_time"
- "sin_julian_day"
- "sin_local_time"
- "lsm"

training:
loss_scaling:
spatial:
_target_: anemoi.training.data.scaling.ReweightedGraphAttribute
target_nodes: ${graph.data}
scaled_attribute: area_weight # it must be a node attribute of the output nodes
cutout_weight_frac_of_global: 2
max_epochs: 2

hardware:
files:
dataset: cerra-rr-an-oper-0001-mars-5p5km-1984-2020-6h-v2-hmsi
forcing_dataset: aifs-od-an-oper-0001-mars-o96-2016-2023-6h-v6
graph: test_stretched_graph.pt
paths:
output: ${oc.env:PWD}/tmp_output/

# number of GPUs per node and number of nodes (for DDP)
accelerator: auto
num_gpus_per_node: 1
num_nodes: 1
num_gpus_per_model: 1

graph:
overwrite: True
nodes:
data:
node_builder:
_target_: anemoi.graphs.nodes.ZarrDatasetNodes
dataset: ${dataloader.dataset}
attributes:
weights:
_target_: anemoi.graphs.nodes.attributes.SphericalAreaWeights
fill_value: 0
norm: unit-max
cutout_mask:
_target_: anemoi.graphs.nodes.attributes.CutOutMask
hidden:
node_builder:
_target_: anemoi.graphs.nodes.StretchedTriNodes
lam_resolution: 5
global_resolution: 3
reference_node_name: data
mask_attr_name: cutout_mask

edges:
- source_name: data
target_name: hidden
edge_builders:
- _target_: anemoi.graphs.edges.KNNEdges
num_nearest_neighbours: 12
attributes: ${graph.attributes.edges}
- source_name: hidden
target_name: hidden
edge_builders:
- _target_: anemoi.graphs.edges.MultiScaleEdges
x_hops: 1
attributes: ${graph.attributes.edges}
- source_name: hidden
target_name: data
edge_builders:
- _target_: anemoi.graphs.edges.KNNEdges
num_nearest_neighbours: 3
attributes: ${graph.attributes.edges}

# model:
# attributes:
# edges: []
File renamed without changes.
41 changes: 41 additions & 0 deletions tests/integration/test_training_cycle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# (C) Copyright 2024 Anemoi contributors.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

import logging
import shutil

import pytest
import torch

from anemoi.training.train.train import AnemoiTrainer

LOGGER = logging.getLogger(__name__)


@pytest.mark.skipif(not torch.cuda.is_available(), reason="No GPU available")
def test_training_cycle_architecture_configs(architecture_config) -> None:
AnemoiTrainer(architecture_config).train()
shutil.rmtree(architecture_config.hardware.paths.output)


@pytest.mark.skipif(not torch.cuda.is_available(), reason="No GPU available")
def test_training_cycle_grid_configs(stretched_config) -> None:
AnemoiTrainer(stretched_config).train()
shutil.rmtree(stretched_config.hardware.paths.output)


if __name__ == "__main__":
from hydra import compose
from hydra import initialize
from omegaconf import OmegaConf

with initialize(version_base=None, config_path="", job_name="test_training"):
cfg = compose(config_name="stretched_config", overrides=[])
OmegaConf.resolve(cfg)
test_training_cycle_architecture_configs(cfg)
Loading