-
Notifications
You must be signed in to change notification settings - Fork 10
Domain decomposition and halo construction #540
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
Merged
Merged
Changes from 250 commits
Commits
Show all changes
375 commits
Select commit
Hold shift + click to select a range
271d70b
fix some typting in test_parallel_grid_manager.py
eca2a8f
make test run again
ab0f21e
Merge branch 'main' into halo_construction
3698b9a
fixes from merge
7a4170c
Merge branch 'main' into halo_construction
c9be1d0
fix merge: global grid params
0a2d126
fix typings
785f7d1
remove obsolete TODO
c5ad92b
fix parallel diffusion tests
8791be0
fix parallel non hydro test
ef3b494
delete files unrelated to this PR
c87800c
delete files unrelated to this PR
6a73bf0
Merge branch 'main' into halo_construction
e484e0c
Merge branch 'main' into halo_construction
ed51c58
Merge branch 'main' into halo_construction
935b113
get grid tests to run again
179d4b7
get parallel test to run again
45bbbf6
get parallel test to run again
bb190ec
start/end index for halos (I)
e89c5e5
fix parallel test for start_index/end_index
464302a
add tests WIP(1)
b0746c3
fix typing
12dbe47
pre-commit
88ae0ec
add tests (WIP)
3c35b61
simple fixes
def79a5
fix reading of additional edge fields
b418ac2
make all tests run
7f5973d
fixing some things
3a7d474
Merge branch 'main' into halo_construction
73e6a08
fix typings
378d269
use dummy props on test to make them simple unit tests
927e7d1
add test to check skip value configuration
3f64b2a
simple clean ups in PR
799ac8a
move function only used in test
e796b74
fix imports in parallel tests
7f0dedf
add doc strings for compute_domain bounds
0ca46f0
Merge branch 'main' into halo_construction
b50691e
pre-commit
09d4aaf
move serializable tests to unit_tests
5df9adc
doc string for IconLikeHaloConstructor
4c8adf3
fix test_local_connectivity to run on grid_manager
34c61c4
move global_to_local function
3bee001
Merge branch 'main' into halo_construction
0a79fdf
add pymetis to standard common dependencies, fix old gt4py version in…
1fb0c25
mypy
305d7a0
add missing datatest annotation
aa95ce8
rename test functions
d1234ed
fix halo construction: additional vertices for second level edges
3aaef7d
fix: add "corner" cell
e5692f1
remove duplicate test
cddc724
fix edge DecompositionFlag.THIRD
bb94545
add embedded markers
43c933d
Merge branch 'main' into halo_construction
d738ee9
add xfail for dace
52ddcea
fix ordering
f211473
cleanup of docstring including @msimberg 's review
jcanton 336db99
little cleanup
jcanton a983ed7
one more grid for testing
jcanton 3dba11f
fix filename
jcanton 9ec0045
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg d20f82e
Remove outdated xfails
msimberg be499fe
Remove another xfail
msimberg b1cea99
Remove old TODO
msimberg ff4e7db
Pass num cells to global grid params
msimberg dbbf829
Revert "refactor: testing infrastructure (#1002)"
msimberg eed64eb
Fix cupy/numpy issues
msimberg 5440d2b
Fix another cupy/numpy issue
msimberg dbde86b
More cupy/numpy
msimberg 05ba45f
TODO for distributed check in IconGrid constructor
msimberg 0ae367c
Formatting
msimberg 221d364
Add name to TODO
msimberg 6475ead
Linting
msimberg bee4bc2
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 460be4b
Unrevert data download changes
msimberg de480b5
Rename single_node to is_single_rank
msimberg 59fa8a3
Rename *single_node test to *single_rank
msimberg 44038d5
Minor formatting change
msimberg cc1839b
Remove unused variable
msimberg 4b26503
Remove another unused variable
msimberg 8c8876b
Add extra assert to test_props
msimberg 0c20e61
Rename MissingConnectivity to MissingConnectivityError
msimberg 39bcbfd
Update halo cut example
msimberg a69c3c7
Reformat halo construction docstring
msimberg df3bb06
Remove unnecessary numpy.unique from halo construction
msimberg 05e992c
Minor renamings in grid_manager.py
msimberg 0c6942a
Simplify some returns in halo.py
msimberg 34a8eb2
Simplify _find_neighbors
msimberg 5c11cb4
Remove some trivial helper functions in halo.py
msimberg 3a67b94
Clean up and fix typo in docstring in decomposition utils
msimberg 0fc37b8
Add fixture for global grids (not limited area grids)
msimberg f895bb3
Minor bugfix for LAM/distributed configuration
msimberg 412c554
Rename SimpleMetisDecomposer to MetisDecomposer
msimberg d33c0da
Minor reformatting and more torus tests in test_gridfile.py
msimberg 0d95056
Fix connectivity
msimberg 9ebc747
Remove debugging
msimberg aaaa514
Add simple test to check that metis decomposition is roughly balanced
msimberg 2ed874e
Expand test_local_connectivity parametrization
msimberg 19fc9d5
Add note about partitioning being deterministic
msimberg 294956b
Rename face to cell in halo.py
msimberg 95e5ef1
Move decomposer to a separate file
msimberg 3926eaa
Revert num_levels/vertical config change
msimberg 8068529
Remove helper next_halo_line
msimberg 5e7b984
Simplify owned_cells
msimberg 32fc3dc
Remove unnecessary xfail
msimberg cc642c7
Remove owned_cells helper
msimberg d275bf8
Add check to disallow limited area grids with distributed runs
msimberg 0706f6e
Revert "Remove helper next_halo_line"
msimberg d2919af
Simplify, but don't remove, next_halo_line helper
msimberg d284330
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 4637105
Refactor test_parallel_grid_manager.py
msimberg dcf72b5
Minor cleanup and todo in test_parallel_halo.py
msimberg f7eb9be
Cleanup and todo
msimberg 48e9a21
Clean up todos
msimberg f29e554
Remove global_grid_descriptor fixture, try to add metrics test
msimberg e1d05f5
Fix decomposer import
msimberg f52a883
Update comments in halo.py
msimberg 774900c
Small renaming
msimberg 571d0f6
Copy owner mask
msimberg bcedac6
Remove UNDEFINED flag from DecompositionFlag
msimberg 8cc732b
Small renaming
msimberg 3877652
Add assertion
msimberg c7f5ef8
Small update to docstring
msimberg 57c5d06
Check singlenodedecomposer num_partitions
msimberg 204a5ab
Remove test_geometry_stencils.py
msimberg 67cd219
Revert changes in test_geometry.py
msimberg 9f298c9
Small refactoring
msimberg 6ff1bd2
Revert "Minor bugfix for LAM/distributed configuration"
msimberg aecfb5f
xfail lam grid
msimberg 777a396
Assert there are no invalid indices in adjacency matrix for metis
msimberg 5609570
Small refactoring of test_local_connectivity
msimberg d55a20d
Fix test_local_connectivity
msimberg b814c9f
More tests for test_parallel_icon.py
msimberg 60a0c8e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 079f3ac
Clean up todo
msimberg 3fd4d31
Add todos
msimberg a94be5a
Update icon grid skip values again
msimberg 0274189
Revert "Remove UNDEFINED flag from DecompositionFlag"
msimberg e97b1c4
Revert "Remove owned_cells helper"
msimberg 0e24b76
Fix decomposer import
msimberg 356695a
Use low enough index in test for all tested grids
msimberg ee8ce4a
Add rbf fields to test_parallel_grid_manager.py
msimberg 395553f
Remove todo
msimberg cd74e0c
xfail some distributed geometry tests with embedded backend
msimberg f0baaa3
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 672cd93
Remove duplicated test
msimberg a9b24fc
Remove unused imports
msimberg fe38371
Fix pytest.mark.xfail to pytest.xfail
msimberg f7f3724
Clean up docstring for Zone
msimberg c7d8a74
Don't use get on dict to ensure exception on missing entries
msimberg c8bfbc6
Fix import for ToZeroBasedIndexTransformation
msimberg 86da004
Remove unused import
msimberg 814814f
Rename single/multi-node to single/multi-rank
msimberg f7dae6e
Add missing word
msimberg 7abfc3d
Remove todos
msimberg 3973bfb
Remove todo
msimberg 85b091d
Remove unused logger
msimberg 8e85390
Small refactor in halo.py
msimberg 9e3f0fc
Revert horizontal_size/horizontal_config rename
msimberg 2bd04a7
Fix typo
msimberg 2bf0d2a
Small renaming related to index offset/transformation
msimberg e72803b
Small simplification
msimberg aa54fea
Replace prints with logging in distributed tests
msimberg 1c1247a
Update model/common/tests/common/grid/mpi_tests/test_parallel_grid_ma…
msimberg 5248993
Update model/common/tests/common/decomposition/unit_tests/test_halo.py
msimberg c6ef577
Update model/common/tests/common/grid/mpi_tests/test_parallel_grid_ma…
msimberg cea742c
Fix typo
msimberg e7428e6
Fix typo
msimberg 9d7e88a
Remove model/common/tests/common/grid/fixtures.py
msimberg fde16aa
Fix distributed metrics test
msimberg 0f06c6b
Revert horizontal_size/config rename
msimberg fcf7821
Fix some inconsistent renames
msimberg 6f8fcd4
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg 66abfe1
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg fec9a29
Clean up assignment
msimberg de988bc
Prefix private member functions with _
msimberg eae8bde
Remove MPI import for type checking
msimberg 1288824
Minor cleanup
msimberg 1fcee72
Use field_type_aliases in compute_cell_2_vertex_interpolation.py
msimberg 3d9f018
Simplify skipping mpi tests
msimberg d41ea85
Remove is not None
msimberg cccbe97
Simplify return
msimberg 2b6be6d
Revert "Remove is not None"
msimberg b5115c2
Minor consistency renaming
msimberg 1370754
Small cleanup in grid refinement
msimberg 822549e
Add distributed property to GridConfig
msimberg cf19a0f
Small reordering of fields
msimberg 54ba6b5
Add more fields to be tested in test_parallel_grid_manager.py
msimberg bac1faf
Change computational domain for some geometry fields
msimberg 789a7ff
Sort geometry fields
msimberg b40ff92
Add more interpolation fields to parallel grid manager test
msimberg 67e054b
Test more metrics fields
msimberg f864ec6
Remove unused fixture
msimberg 0fbfb62
Fix figure reference
msimberg 2bc143e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 4fb0936
Remove deleted field from test
msimberg 7290b81
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg 135172d
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg 171d23f
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg 7fa119a
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg 18ebc10
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg f47e5f3
Work on failing test_parallel_grid_geometry.py fields
msimberg 20e4a8b
Comment one more field out for now
msimberg 02a9650
Add assertions for halo construction consistency
msimberg 63a2520
Change implementation of array_ns_from_array
msimberg 23d7c83
Fix inverse dual edge length and c_lin_e fields
msimberg ad485d0
"Fix" more parallel tests
msimberg abcc29c
grid description fixture and tiny grid
jcanton 8c83811
Add tests to check consistency of owner masks and domain bounds
msimberg 895b5b4
Fix vertex/edge decomposition ownership masks
msimberg 88b83ba
Update compute bounds in factories now that ownership bug is fixed
msimberg 44e3708
Add tests to check that halo levels are sorted
msimberg 82466c1
Clean up test_halo.py and fix a few parameters
msimberg 38be5e5
Add missing is_sorted helper function
msimberg 7cac885
Remove todo
msimberg eda26ef
Clean up and enable more tests in test_parallel_grid_manager.py
msimberg a397e0a
Add specialized mask_prog_halo_c test
msimberg d0acad4
Merge remote-tracking branch 'origin/halo_construction' into halo_con…
msimberg d949e44
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg d2d8faf
Update array_ns_from_array after merge
msimberg 95a676f
Update tested fields in test_parallel_grid_manager.py after merge
msimberg 214fbe9
Simplify test_halo.py
msimberg 0d33ee4
Remove empty pytest file
msimberg 1f632ab
Disable r01b01 grid for testing for now
msimberg a62e6e3
Fix formatting
msimberg c367428
Ignore commented out code
msimberg 1975443
Small cleanup refactoring in halo construction
msimberg 19abd25
Update decomposition info with_dimension call to set_dimension
msimberg 0d10792
Explicitly convert np.bool_ to bool
msimberg f6fd95f
Remove unnecessary test
msimberg c343334
Constrain xfail a bit more
msimberg da60b19
Add domain sizes
msimberg fd0c7f0
Remove rbf interpolation todo
msimberg b8fa94e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 80f1fa9
Fix second halo level cell computation
msimberg e9fc3fd
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg 182a843
Increase distributed CI pipeline timelimits
msimberg 79d65f2
Allow None for halo_levels
msimberg 5a6cc8e
Add more tests for test_compute_domain_bounds_for_global_grid
msimberg 8efe35c
Enable grid data download in distributed pipeline
msimberg 56f9cef
Add xfails for wrong halo, interior, local indices with torus grid
msimberg c6cf66b
Check INTERIOR indices with icon4py domain decomposition
msimberg 301c041
Update ci/distributed.yml
msimberg d77f5d9
Less verbose xfail
msimberg 37b196b
Download r01b01 grid in ci
msimberg 39703b3
Enable download again
msimberg 6df6af6
Disable download again
msimberg 115aec8
Explicitly set ICON4PY_TEST_DATA_PATH in github workflows
msimberg f204644
More explicit path
msimberg dc339dc
Enable grid download for grid download step
msimberg fc0a445
Remove todos
msimberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
model/common/src/icon4py/model/common/decomposition/decomposer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # ICON4Py - ICON inspired code in Python and GT4Py | ||
| # | ||
| # Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss | ||
| # All rights reserved. | ||
| # | ||
| # Please, refer to the LICENSE file in the root directory. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| from typing import Protocol, runtime_checkable | ||
|
|
||
| import gt4py.next as gtx | ||
|
|
||
| from icon4py.model.common.utils import data_allocation as data_alloc | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class Decomposer(Protocol): | ||
| def __call__( | ||
| self, adjacency_matrix: data_alloc.NDArray, num_partitions: int | ||
| ) -> data_alloc.NDArray: | ||
| """ | ||
| Call the decomposition. | ||
|
|
||
| Args: | ||
| adjacency_matrix: cell-to-cell connectivity matrix on the global (undecomposed) grid. In the Icon4py context this C2E2C | ||
| n_part: number of nodes | ||
| """ | ||
| ... | ||
|
|
||
|
|
||
| class MetisDecomposer(Decomposer): | ||
| """ | ||
| A simple decomposer using METIS for partitioning a grid topology. | ||
|
|
||
| We use the simple pythonic interface to pymetis: just passing the adjacency matrix, which for ICON is | ||
| the full grid C2E2C neigbhor table. | ||
| if more control is needed (for example by using weights we need to switch to the C like interface) | ||
| https://documen.tician.de/pymetis/functionality.html | ||
| """ | ||
|
|
||
| def __call__( | ||
| self, adjacency_matrix: data_alloc.NDArray, num_partitions: int | ||
| ) -> data_alloc.NDArray: | ||
| """ | ||
| Generate partition labels for this grid topology using METIS: | ||
| https://github.com/KarypisLab/METIS | ||
|
|
||
| This method utilizes the pymetis Python bindings: | ||
| https://github.com/inducer/pymetis | ||
|
|
||
| Args: | ||
| n_part: int, number of partitions to create | ||
| adjacency_matrix: nd array: neighbor table describing of the main dimension object to be distributed: for example cell -> cell neighbors | ||
| Returns: data_alloc.NDArray: array with partition label (int, rank number) for each cell | ||
| """ | ||
|
|
||
| import pymetis # type: ignore [import-untyped] | ||
|
|
||
| # Invalid indices are not allowed here. Metis will segfault or fail | ||
| # there are any invalid indices in the adjacency matrix. | ||
| assert (adjacency_matrix >= 0).all() | ||
|
|
||
| # The partitioning is done on all ranks, and this assumes that the | ||
| # partitioning is deterministic. | ||
| _, partition_index = pymetis.part_graph(nparts=num_partitions, adjacency=adjacency_matrix) | ||
| return data_alloc.array_ns_from_array(adjacency_matrix).array(partition_index) | ||
|
|
||
|
|
||
| class SingleNodeDecomposer(Decomposer): | ||
| def __call__( | ||
| self, adjacency_matrix: data_alloc.NDArray, num_partitions: int | ||
| ) -> data_alloc.NDArray: | ||
| """Dummy decomposer for single node: assigns all cells to rank = 0""" | ||
| if num_partitions != 1: | ||
| raise ValueError( | ||
| f"SingleNodeDecomposer can only be used for num_partitions=1, but got {num_partitions}" | ||
| ) | ||
|
|
||
| return data_alloc.array_ns_from_array(adjacency_matrix).zeros( | ||
| adjacency_matrix.shape[0], | ||
| dtype=gtx.int32, # type: ignore [attr-defined] | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.