From 2b9635a2713be3ea3d38e6ced0bec852b1b02295 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Tue, 9 Apr 2024 10:37:58 +0200 Subject: [PATCH 1/6] set limited_area correctly for experiments --- .../icon4py/model/common/grid/grid_manager.py | 17 +++++++++++------ .../model/common/test_utils/grid_utils.py | 8 ++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/model/common/src/icon4py/model/common/grid/grid_manager.py b/model/common/src/icon4py/model/common/grid/grid_manager.py index 3a50186a64..79e567b8c0 100644 --- a/model/common/src/icon4py/model/common/grid/grid_manager.py +++ b/model/common/src/icon4py/model/common/grid/grid_manager.py @@ -240,9 +240,9 @@ def __init__( self._grid: Optional[IconGrid] = None self._file_name = grid_file - def __call__(self, on_gpu: bool = False): + def __call__(self, on_gpu: bool = False, limited_area=True): dataset = self._read_gridfile(self._file_name) - _, grid = self._constuct_grid(dataset, on_gpu=on_gpu) + _, grid = self._constuct_grid(dataset, on_gpu=on_gpu, limited_area=limited_area) self._grid = grid def _read_gridfile(self, fname: str) -> Dataset: @@ -326,9 +326,11 @@ def _get_index(self, dim: Dimension, start_marker: int, index_dict): self._log.error(msg) raise IconGridError(msg) from err - def _constuct_grid(self, dataset: Dataset, on_gpu: bool) -> tuple[UUID, IconGrid]: + def _constuct_grid( + self, dataset: Dataset, on_gpu: bool, limited_area: bool + ) -> tuple[UUID, IconGrid]: grid_id = UUID(dataset.getncattr(GridFile.PropertyName.GRID_ID)) - return grid_id, self._from_grid_dataset(dataset, on_gpu=on_gpu) + return grid_id, self._from_grid_dataset(dataset, on_gpu=on_gpu, limited_area=limited_area) def get_size(self, dim: Dimension): if dim == VertexDim: @@ -354,7 +356,7 @@ def _get_index_field( field = field + self._transformation.get_offset_for_index_field(field) return field - def _from_grid_dataset(self, dataset: Dataset, on_gpu: bool) -> IconGrid: + def _from_grid_dataset(self, dataset: Dataset, on_gpu: bool, limited_area=True) -> IconGrid: reader = GridFile(dataset) num_cells = reader.dimension(GridFile.DimensionName.CELL_NAME) num_edges = reader.dimension(GridFile.DimensionName.EDGE_NAME) @@ -386,7 +388,10 @@ def _from_grid_dataset(self, dataset: Dataset, on_gpu: bool) -> IconGrid: ) = self._read_grid_refinement_information(dataset) config = GridConfig( - horizontal_config=grid_size, vertical_config=self._config, on_gpu=on_gpu + horizontal_config=grid_size, + vertical_config=self._config, + on_gpu=on_gpu, + limited_area=limited_area, ) icon_grid = ( IconGrid() diff --git a/model/common/src/icon4py/model/common/test_utils/grid_utils.py b/model/common/src/icon4py/model/common/test_utils/grid_utils.py index f0e5f4b6c7..b3ff01df84 100644 --- a/model/common/src/icon4py/model/common/test_utils/grid_utils.py +++ b/model/common/src/icon4py/model/common/test_utils/grid_utils.py @@ -39,6 +39,7 @@ def get_icon_grid_from_gridfile(experiment: str, on_gpu: bool = False) -> IconGr "icon_grid_0013_R02B04_R.nc", num_levels=GLOBAL_NUM_LEVELS, on_gpu=on_gpu, + limited_area=False, ) elif experiment == REGIONAL_EXPERIMENT: return _load_from_gridfile( @@ -46,12 +47,15 @@ def get_icon_grid_from_gridfile(experiment: str, on_gpu: bool = False) -> IconGr "grid.nc", num_levels=MCH_CH_R04B09_LEVELS, on_gpu=on_gpu, + limited_area=True, ) else: raise ValueError(f"Unknown experiment: {experiment}") -def _load_from_gridfile(file_path: str, filename: str, num_levels: int, on_gpu: bool) -> IconGrid: +def _load_from_gridfile( + file_path: str, filename: str, num_levels: int, on_gpu: bool, limited_area: bool +) -> IconGrid: grid_file = GRIDS_PATH.joinpath(file_path, filename) if not grid_file.exists(): from icon4py.model.common.test_utils.data_handling import download_and_extract @@ -66,7 +70,7 @@ def _load_from_gridfile(file_path: str, filename: str, num_levels: int, on_gpu: str(grid_file), VerticalGridSize(num_levels), ) - gm(on_gpu=on_gpu) + gm(on_gpu=on_gpu, limited_area=limited_area) return gm.get_grid() From 9677b923bd4d1301b47d58f1847af0a7dcdaa9ab Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Tue, 9 Apr 2024 11:30:12 +0200 Subject: [PATCH 2/6] Force benchmark execution on xfail tests --- ci/benchmark.yml | 3 ++- ci/dace.yml | 3 ++- .../test_fused_velocity_advection_stencil_1_to_7.py | 2 +- .../test_fused_velocity_advection_stencil_8_to_13.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ci/benchmark.yml b/ci/benchmark.yml index b3bfff0744..b1932a91ab 100644 --- a/ci/benchmark.yml +++ b/ci/benchmark.yml @@ -8,7 +8,8 @@ benchmark_model_stencils: extends: .test_template stage: benchmark script: - - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose + # force execution of tests where validation is expected to fail, because the reason for failure is wrong numpy reference + - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --run_xfail --verbose parallel: matrix: - BACKEND: [gtfn_cpu, gtfn_gpu] diff --git a/ci/dace.yml b/ci/dace.yml index 4c73b29eef..5336dbd346 100644 --- a/ci/dace.yml +++ b/ci/dace.yml @@ -27,7 +27,8 @@ benchmark_model_stencils: # TODO(edopao): wait for next dace release to fix the inline_sdfgs simplify step # - pip install dace==$DACE_VERSION - pip install git+https://github.com/spcl/dace.git@$DACE_VERSION - - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose + # force execution of tests where validation is expected to fail, because the reason for failure is wrong numpy reference + - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --run_xfail --verbose parallel: matrix: - BACKEND: [dace_cpu, dace_gpu] diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py index a3883c57a5..e8e1ec07c3 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py @@ -205,7 +205,7 @@ def reference( @pytest.fixture def input_data(self, grid): - pytest.skip( + pytest.xfail( "Verification of z_v_grad_w currently not working, because numpy version incorrect." ) if isinstance(grid, IconGrid) and grid.limited_area: diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_13.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_13.py index f19f496e04..a17f28d304 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_13.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_13.py @@ -103,7 +103,7 @@ def reference( @pytest.fixture def input_data(self, grid): - pytest.skip( + pytest.xfail( "Verification of w_concorr_c currently not working, because numpy version is incorrect." ) z_kin_hor_e = random_field(grid, EdgeDim, KDim) From 88ea4188ddf1019c97b30dbb7bffd285e9caf455 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Tue, 9 Apr 2024 11:53:42 +0200 Subject: [PATCH 3/6] Fix pytest argument --runxfail --- ci/benchmark.yml | 2 +- ci/dace.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/benchmark.yml b/ci/benchmark.yml index b1932a91ab..e56e4e06aa 100644 --- a/ci/benchmark.yml +++ b/ci/benchmark.yml @@ -9,7 +9,7 @@ benchmark_model_stencils: stage: benchmark script: # force execution of tests where validation is expected to fail, because the reason for failure is wrong numpy reference - - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --run_xfail --verbose + - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --runxfail --verbose parallel: matrix: - BACKEND: [gtfn_cpu, gtfn_gpu] diff --git a/ci/dace.yml b/ci/dace.yml index 5336dbd346..b0c2e6b9d6 100644 --- a/ci/dace.yml +++ b/ci/dace.yml @@ -28,7 +28,7 @@ benchmark_model_stencils: # - pip install dace==$DACE_VERSION - pip install git+https://github.com/spcl/dace.git@$DACE_VERSION # force execution of tests where validation is expected to fail, because the reason for failure is wrong numpy reference - - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --run_xfail --verbose + - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --runxfail --verbose parallel: matrix: - BACKEND: [dace_cpu, dace_gpu] From e9e1b5b1d6d6bee31084347610ed0fecbdf075f8 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Tue, 9 Apr 2024 14:37:05 +0200 Subject: [PATCH 4/6] revert workaround for backend --- tools/src/icon4pytools/icon4pygen/metadata.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/tools/src/icon4pytools/icon4pygen/metadata.py b/tools/src/icon4pytools/icon4pygen/metadata.py index 0d7670f210..d1af2cef50 100644 --- a/tools/src/icon4pytools/icon4pygen/metadata.py +++ b/tools/src/icon4pytools/icon4pygen/metadata.py @@ -219,13 +219,8 @@ def scan_for_offsets(fvprog: Program) -> list[eve.concepts.SymbolRef]: all_dims = set(i for j in all_field_types for i in j.dims) - if fvprog.backend: - fendef = fvprog.itir.program # type: ignore - else: - fendef = fvprog.itir - all_offset_labels = ( - fendef.pre_walk_values() + fvprog.itir.pre_walk_values() .if_isinstance(itir.OffsetLiteral) .getattr("value") .if_isinstance(str) @@ -245,16 +240,10 @@ def get_stencil_info( """Generate StencilInfo dataclass from a fencil definition.""" fvprog = get_fvprog(fencil_def) offsets = scan_for_offsets(fvprog) - - if fvprog.backend: - fendef = fvprog.itir.program # type: ignore - else: - fendef = fvprog.itir - fields = _get_field_infos(fvprog) offset_provider = {} for offset in offsets: offset_provider[offset] = provide_offset(offset, is_global) connectivity_chains = [offset for offset in offsets if offset != Koff.value] - return StencilInfo(fendef, fields, connectivity_chains, offset_provider) + return StencilInfo(fvprog.itir, fields, connectivity_chains, offset_provider) From fd01a7e73ad620288e388c8de5b1ca262566476d Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Tue, 9 Apr 2024 15:56:36 +0200 Subject: [PATCH 5/6] Revert "revert workaround for backend" This reverts commit e9e1b5b1d6d6bee31084347610ed0fecbdf075f8. --- tools/src/icon4pytools/icon4pygen/metadata.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/src/icon4pytools/icon4pygen/metadata.py b/tools/src/icon4pytools/icon4pygen/metadata.py index d1af2cef50..0d7670f210 100644 --- a/tools/src/icon4pytools/icon4pygen/metadata.py +++ b/tools/src/icon4pytools/icon4pygen/metadata.py @@ -219,8 +219,13 @@ def scan_for_offsets(fvprog: Program) -> list[eve.concepts.SymbolRef]: all_dims = set(i for j in all_field_types for i in j.dims) + if fvprog.backend: + fendef = fvprog.itir.program # type: ignore + else: + fendef = fvprog.itir + all_offset_labels = ( - fvprog.itir.pre_walk_values() + fendef.pre_walk_values() .if_isinstance(itir.OffsetLiteral) .getattr("value") .if_isinstance(str) @@ -240,10 +245,16 @@ def get_stencil_info( """Generate StencilInfo dataclass from a fencil definition.""" fvprog = get_fvprog(fencil_def) offsets = scan_for_offsets(fvprog) + + if fvprog.backend: + fendef = fvprog.itir.program # type: ignore + else: + fendef = fvprog.itir + fields = _get_field_infos(fvprog) offset_provider = {} for offset in offsets: offset_provider[offset] = provide_offset(offset, is_global) connectivity_chains = [offset for offset in offsets if offset != Koff.value] - return StencilInfo(fvprog.itir, fields, connectivity_chains, offset_provider) + return StencilInfo(fendef, fields, connectivity_chains, offset_provider) From a363f56ec170b14908a334b44157fbb1f00c2993 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Tue, 9 Apr 2024 15:58:37 +0200 Subject: [PATCH 6/6] Update gt4py stable version --- spack/gt4py-stable/spack.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spack/gt4py-stable/spack.yaml b/spack/gt4py-stable/spack.yaml index 488733396f..ff97704e25 100644 --- a/spack/gt4py-stable/spack.yaml +++ b/spack/gt4py-stable/spack.yaml @@ -1,10 +1,10 @@ spack: specs: - - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.5%gcc@9.3.0 + - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.6%gcc@9.3.0 view: false concretizer: unify: true develop: py-icon4py: - spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.5%gcc@9.3.0 + spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.6%gcc@9.3.0 path: ../../