Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
15ae2c7
Translate tests readme update (#132)
romanc Apr 17, 2025
42590e7
Translate tests: no threshold analysis by default (#134)
romanc Apr 17, 2025
c77058b
Automatic GT4Py import through NDSL - Remove Independent GT4Py Import…
CharlesKrop May 1, 2025
069907b
Ochestration with ConstantPropagation (#139)
romanc May 9, 2025
4cda272
Features to support surface physics (#135)
oelbert May 13, 2025
1d2446a
Quantity.field has true array accessor to the compute domain on a Qua…
FlorianDeconinck May 13, 2025
287c674
Adding sw_dynamics to NamelistDefaults (#136)
jjuyeonkim May 13, 2025
c38e64f
Remove `floating_point_precision()` (#140)
romanc May 14, 2025
615fdfe
Simple test for gt4py wrapper (#142)
romanc May 15, 2025
beb7cc7
Expose stencil from gt4py (#144)
romanc May 16, 2025
7e152ce
Features used in the shallow convection and the PBL schemes (#130)
oelbert May 16, 2025
f287122
Field Bundle: Functional code for 4D array (#143)
FlorianDeconinck May 16, 2025
44690bc
Grid metrics terms: mixed precision & GPU readiness (#147)
FlorianDeconinck May 20, 2025
2a6150c
[Experimental] Debugger (#137)
FlorianDeconinck May 20, 2025
357c67d
Change gt4py imports in examples and tests (#148)
romanc May 27, 2025
28dd8b8
build: update gt4py 1ba0a972..45324c88 (#150)
romanc May 27, 2025
65acd24
Fix warning in tests (#151)
romanc May 28, 2025
dd320b6
Fix deprecation warning about `use_cftime` (#153)
romanc May 28, 2025
b5f6e5a
ci: Don't exit early on failure (#155)
romanc May 28, 2025
5f204b3
Changing setup.py for release candidate 2025.05.00 (#152)
fmalatino May 30, 2025
1926468
No boost dependency anymore (#158)
romanc May 30, 2025
24ca703
Optional and non-optional dependencies (#154)
romanc May 30, 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
7 changes: 3 additions & 4 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ jobs:
run: pip3 install .[test]

- name: prepare input eta files
run: |
python tests/grid/generate_eta_files.py
run: python tests/grid/generate_eta_files.py

- name: Run serial-cpu tests
run: coverage run --rcfile=setup.cfg -m pytest -x tests
run: coverage run --rcfile=setup.cfg -m pytest tests

- name: Run parallel-cpu tests
run: mpiexec -np 6 --oversubscribe coverage run --rcfile=setup.cfg -m mpi4py -m pytest -x tests/mpi
run: mpiexec -np 6 --oversubscribe coverage run --rcfile=setup.cfg -m mpi4py -m pytest tests/mpi

- name: Output code coverage
run: |
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NDSL submodules `gt4py` and `dace` to point to vetted versions, use `git clone -
NDSL is __NOT__ available on `pypi`. Installation of the package has to be local, via `pip install ./NDSL` (`-e` supported). The packages has a few options:

- `ndsl[test]`: installs the test packages (based on `pytest`)
- `ndsl[demos]`: installs extra requirements to run [NDSL exmpales](./examples/NDSL/)
- `ndsl[demos]`: installs extra requirements to run [NDSL examples](./examples/NDSL/)
- `ndsl[docs]`: installs extra requirements to build the docs
- `ndsl[develop]`: installs tools for development, docs, and tests.

Expand All @@ -34,8 +34,6 @@ For CPU backends:
- 3.11.x >= Python < 3.12.x
- Compilers:
- GNU 11.2+
- Libraries:
- Boost headers 1.76+ (no lib installed, just headers)

For GPU backends (the above plus):

Expand Down
14 changes: 0 additions & 14 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ For CPU backends:
- 3.11.x >= Python < 3.12.x
- Compilers:
- GNU 11.2+
- Libraries:
- Boost headers 1.76+ (no lib installed, just headers)

For GPU backends (the above plus):

Expand Down Expand Up @@ -88,18 +86,6 @@ git submodule update --init --recursive
```

- Pace requires GCC > 9.2, MPI, and Python 3.8 on your system, and CUDA is required to run with a GPU backend.
You will also need the headers of the boost libraries in your `$PATH` (boost itself does not need to be installed).
If installed outside the standard header locations, gt4py requires that `$BOOST_ROOT` be set:

```bash
cd BOOST/ROOT
wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz
tar -xzf boost_1_79_0.tar.gz
mkdir -p boost_1_79_0/include
mv boost_1_79_0/boost boost_1_79_0/include/
export BOOST_ROOT=BOOST/ROOT/boost_1_79_0
```

- We recommend creating a python `venv` or conda environment specifically for Pace.

```bash
Expand Down
12 changes: 6 additions & 6 deletions examples/NDSL/01_gt4py_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gt4py.cartesian.gtscript import PARALLEL, computation, interval, stencil\n",
"from ndsl.dsl.gt4py import PARALLEL, computation, interval, stencil\n",
"from ndsl.dsl.typing import FloatField\n",
"from ndsl.quantity import Quantity\n",
"import numpy as np"
Expand Down Expand Up @@ -109,14 +109,14 @@
"\n",
"We see that this stencil does not contain any explicit loops. As mentioned above in the notebook, GT4Py has a particular computation policy that implicitly executes in parallel within an `IJ` plane and is user defined in the `K` interval. This execution policy in the `K` interval is dictated by the `computation` and `interval` keywords. \n",
"\n",
"- `with computation(PARALLEL)` means that there's no order preference to executing the `K` interval. This also means that the `K` interval can be computed in parallel to potentially gain performace if computational resources are available.\n",
"- `with computation(PARALLEL)` means that there's no order preference to executing the `K` interval. This also means that the `K` interval can be computed in parallel to potentially gain performance if computational resources are available.\n",
"\n",
"- `interval(...)` means that the entire `K` interval is executed. Instead of `(...)`, more specific intervals can be specified using a tuple of two integers. For example... \n",
"\n",
" - `interval(0,2)` : The interval `K` = 0 to 1 is executed.\n",
" - `interval(0,-1)` : The interval `K` = 0 to N-2 (where N is the size of `K`) is executed.\n",
"\n",
"The decorator `@stencil(backend=backend)` (Note: `stencil` comes from the package `gt4py.cartesian.gtscript`) converts `copy_stencil` to use the specified `backend` to \"compile\" the stencil. `stencil` can also be a function call to create a stencil object."
"The decorator `@stencil(backend=backend)` (Note: `stencil` comes from the package `ndsl.dsl.gt4py`) converts `copy_stencil` to use the specified `backend` to \"compile\" the stencil. `stencil` can also be a function call to create a stencil object."
]
},
{
Expand Down Expand Up @@ -269,7 +269,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gt4py.cartesian.gtscript import FORWARD, BACKWARD\n",
"from ndsl.dsl.gt4py import FORWARD, BACKWARD\n",
"\n",
"nx = 5\n",
"ny = 5\n",
Expand Down Expand Up @@ -470,7 +470,7 @@
"\n",
"GT4Py also has the capability to create functions in order to better organize code. The main difference between a GT4Py function call and a GT4Py stencil is that a function does not (and cannot) contain the keywords `computation` and `interval`. However, array index referencing within a GT4py function is the same as in a GT4Py stencil.\n",
"\n",
"GT4Py functions can be created by using the decorator `function` (Note: `function` originates from the package `gt4py.cartesian.gtscript`)."
"GT4Py functions can be created by using the decorator `function` (Note: `function` originates from the package `ndsl.dsl.gt4py`)."
]
},
{
Expand All @@ -479,7 +479,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gt4py.cartesian.gtscript import function\n",
"from ndsl.dsl.gt4py import function\n",
"\n",
"@function\n",
"def plus_one(field: FloatField):\n",
Expand Down
25 changes: 11 additions & 14 deletions examples/NDSL/02_NDSL_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"outputs": [],
"source": [
"from ndsl import StencilFactory\n",
"from ndsl.boilerplate import get_factories_single_tile_numpy\n",
"from ndsl.boilerplate import get_factories_single_tile\n",
"\n",
"nx = 6\n",
"ny = 6\n",
"nz = 1\n",
"nhalo = 1\n",
"\n",
"stencil_factory, _ = get_factories_single_tile_numpy(nx, ny, nz, nhalo)"
"stencil_factory, _ = get_factories_single_tile(nx, ny, nz, nhalo)"
]
},
{
Expand All @@ -59,8 +59,8 @@
"metadata": {},
"outputs": [],
"source": [
"from ndsl.dsl.gt4py import PARALLEL, computation, interval\n",
"from ndsl.dsl.typing import FloatField\n",
"from gt4py.cartesian.gtscript import PARALLEL, computation, interval\n",
"\n",
"def copy_field_stencil(field_in: FloatField, field_out: FloatField):\n",
" with computation(PARALLEL), interval(...):\n",
Expand Down Expand Up @@ -150,7 +150,7 @@
"print(\"Plotting qty_in at K = 0\")\n",
"qty_in.plot_k_level(0)\n",
"print(\"Plotting qty_out at K = 0\")\n",
"qty_out.plot_k_level(0)\n"
"qty_out.plot_k_level(0)"
]
},
{
Expand Down Expand Up @@ -189,7 +189,7 @@
"\n",
"The next example will create a stencil that takes a `Quantity` as an input, shift the input by 1 in the `-J` direction, and write it to an output `Quantity`. This stencil is defined in `copy_field_offset_stencil`.\n",
"\n",
"Note that in `copy_field_offset_stencil`, the shift in the J dimension is performed by referencing the `J` object from `gt4py.cartesian.gtscript` for simplicity. This reference will apply the shift in J to the entire input domain. Another way to perform the shift without referencing the `J` object is to write `[0,-1,0]` (assuming that the variable being modified is 3-dimensional) instead of `[J-1]`.\n",
"Note that in `copy_field_offset_stencil`, the shift in the `J` dimension is performed by referencing the `J` object from `ndsl.dsl.gt4py` for simplicity. This reference will apply the shift in `J` to the entire input domain. Another way to perform the shift without referencing the `J` object is to write `[0,-1,0]` (assuming that the variable being modified is 3-dimensional) instead of `[J-1]`.\n",
"\n",
"With the stencil in place, a class `CopyFieldOffset` is defined using the `StencilFactory` object and `copy_field_offset_stencil`. The class is instantiated and demonstrated to shift `qty_in` by 1 in the J-dimension and write to `qty_out`."
]
Expand All @@ -200,7 +200,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gt4py.cartesian.gtscript import J\n",
"from ndsl.dsl.gt4py import J\n",
"\n",
"def copy_field_offset_stencil(field_in: FloatField, field_out: FloatField):\n",
" with computation(PARALLEL), interval(...):\n",
Expand Down Expand Up @@ -230,7 +230,7 @@
" gt4py_backend=backend\n",
" )\n",
"\n",
"print(\"Initialize qty_out to zeros\")\n"
"print(\"Initialize qty_out to zeros\")"
]
},
{
Expand All @@ -251,7 +251,7 @@
"source": [
"### **Limits to offset : Cannot set offset outside of usable domain**\n",
"\n",
"Note that when the copy offset by -1 in the j-direction is performed, the 'halo' region at J = 8 is copied over due to the `J` shift. This means that there are limits to the shift amount since choosing a large shift amount may result in accessing a data region that does not exist. The following example shows this by trying to perform a shift by -2 in the j-direction."
"Note that when the copy offset by `-1` in the `j`-direction is performed, the 'halo' region at `J = 8` is copied over due to the `J` shift. This means that there are limits to the shift amount since choosing a large shift amount may result in accessing a data region that does not exist. The following example shows this by trying to perform a shift by `-2` in the `j`-direction."
]
},
{
Expand Down Expand Up @@ -282,7 +282,7 @@
" \n",
"copy_field_offset = CopyFieldOffset(stencil_factory)\n",
"\n",
"copy_field_offset(qty_in, qty_out)\n"
"copy_field_offset(qty_in, qty_out)"
]
},
{
Expand All @@ -300,8 +300,6 @@
"metadata": {},
"outputs": [],
"source": [
"from gt4py.cartesian.gtscript import J\n",
"\n",
"def copy_field_offset_output_stencil(field_in: FloatField, field_out: FloatField):\n",
" with computation(PARALLEL), interval(...):\n",
" field_out[0,1,0] = field_in\n",
Expand All @@ -322,14 +320,13 @@
" ):\n",
" self._copy_field_offset_output(field_in, field_out)\n",
" \n",
"copy_field_offset_output = CopyFieldOffsetOutput(stencil_factory)\n",
" "
"copy_field_offset_output = CopyFieldOffsetOutput(stencil_factory)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "gt4py_jupyter",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/NDSL/03_orchestration_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"from gt4py.cartesian.gtscript import (\n",
"from ndsl.dsl.gt4py import (\n",
" PARALLEL,\n",
" computation,\n",
" interval,\n",
Expand Down
2 changes: 1 addition & 1 deletion external/gt4py
Submodule gt4py updated 282 files
2 changes: 2 additions & 0 deletions ndsl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import dsl # isort:skip
from .comm.communicator import CubedSphereCommunicator, TileCommunicator
from .comm.local_comm import LocalComm
from .comm.mpi import MPIComm
Expand Down Expand Up @@ -28,6 +29,7 @@
from .performance.profiler import NullProfiler, Profiler
from .performance.report import Experiment, Report, TimeReport
from .quantity import Quantity
from .quantity.field_bundle import FieldBundle, FieldBundleType # Break circular import
from .testing.dummy_comm import DummyComm
from .types import Allocator
from .utils import MetaEnumStr
13 changes: 2 additions & 11 deletions ndsl/checkpointer/snapshots.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import collections

import numpy as np
import xarray as xr

from ndsl.checkpointer.base import Checkpointer
from ndsl.optional_imports import cupy as cp
from ndsl.optional_imports import xarray as xr


def make_dims(savepoint_dim, label, data_list):
Expand Down Expand Up @@ -39,12 +39,7 @@ def dataset(self) -> "xr.Dataset":
data_vars[f"{variable_name}"] = make_dims(
savepoint_dim, variable_name, self._arrays[variable_name]
)
if xr is None:
raise ModuleNotFoundError(
"xarray must be installed to use Snapshots.dataset"
)
else:
return xr.Dataset(data_vars=data_vars)
return xr.Dataset(data_vars=data_vars)


class SnapshotCheckpointer(Checkpointer):
Expand All @@ -54,10 +49,6 @@ class SnapshotCheckpointer(Checkpointer):
"""

def __init__(self, rank: int):
if xr is None:
raise ModuleNotFoundError(
"xarray must be installed to use SnapshotCheckpointer"
)
self._rank = rank
self._snapshots = _Snapshots()

Expand Down
6 changes: 0 additions & 6 deletions ndsl/checkpointer/thresholds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
from ndsl.quantity import Quantity


try:
import cupy as cp
except ImportError:
cp = None


SavepointName = str
VariableName = str
ArrayLike = Union[Quantity, np.ndarray]
Expand Down
4 changes: 1 addition & 3 deletions ndsl/checkpointer/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import MutableMapping, Tuple

import numpy as np
import xarray as xr

from ndsl.checkpointer.base import Checkpointer
from ndsl.checkpointer.thresholds import (
Expand All @@ -12,7 +13,6 @@
SavepointThresholds,
cast_to_ndarray,
)
from ndsl.optional_imports import xarray as xr


def _clip_pace_array_to_target(
Expand Down Expand Up @@ -109,8 +109,6 @@ def __call__(self, savepoint_name: str, **kwargs: ArrayLike) -> None:
Raises:
AssertionError: if the thresholds on any variable are not met
"""
if xr is None:
raise ModuleNotFoundError("xarray is not installed")
nc_file = os.path.join(self._savepoint_data_path, savepoint_name + ".nc")
ds = xr.open_dataset(nc_file)

Expand Down
7 changes: 1 addition & 6 deletions ndsl/comm/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@
from ndsl.comm.comm_abc import ReductionOperator
from ndsl.comm.partitioner import CubedSpherePartitioner, Partitioner, TilePartitioner
from ndsl.halo.updater import HaloUpdater, HaloUpdateRequest, VectorInterfaceHaloUpdater
from ndsl.optional_imports import cupy
from ndsl.performance.timer import NullTimer, Timer
from ndsl.quantity import Quantity, QuantityHaloSpec, QuantityMetadata
from ndsl.types import NumpyModule


try:
import cupy
except ImportError:
cupy = None


def to_numpy(array, dtype=None) -> np.ndarray:
"""
Input array can be a numpy array or a cupy array. Returns numpy array.
Expand Down
Loading