From 874b8d2e5dca269909622ba5f87b4a1e0a90e4a0 Mon Sep 17 00:00:00 2001 From: mloubout Date: Mon, 4 Aug 2025 09:43:11 -0400 Subject: [PATCH 1/2] mpi: prevent crashes with single rank --- devito/builtins/arithmetic.py | 36 ++++++++--------------------------- devito/data/data.py | 2 +- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/devito/builtins/arithmetic.py b/devito/builtins/arithmetic.py index 5e807219f5..a4d6d0c687 100644 --- a/devito/builtins/arithmetic.py +++ b/devito/builtins/arithmetic.py @@ -180,33 +180,13 @@ def inner(f, g): return f.dtype(n.data[0]) -@dv.switchconfig(log_level='ERROR') -@check_builtins_args -def mmin(f): - """ - Retrieve the minimum. - - Parameters - ---------- - f : array_like or Function - Input operand. - """ - if isinstance(f, dv.Constant): - return f.data - elif isinstance(f, dv.types.dense.DiscreteFunction): - v = np.min(f.data_ro_domain) - if f.grid is None or not dv.configuration['mpi']: - return v.item() - else: - comm = f.grid.distributor.comm - return comm.allreduce(v, dv.mpi.MPI.MIN).item() - else: - raise ValueError("Expected Function, got `%s`" % type(f)) +mmin = lambda f: _reduce_func(f, np.min, dv.mpi.MPI.MIN) +mmax = lambda f: _reduce_func(f, np.max, dv.mpi.MPI.MAX) @dv.switchconfig(log_level='ERROR') @check_builtins_args -def mmax(f): +def _reduce_func(f, func, mfunc): """ Retrieve the maximum. @@ -218,11 +198,11 @@ def mmax(f): if isinstance(f, dv.Constant): return f.data elif isinstance(f, dv.types.dense.DiscreteFunction): - v = np.max(f.data_ro_domain) - if f.grid is None or not dv.configuration['mpi']: - return v.item() - else: + v = func(f.data_ro_domain) + if f.data._is_decomposed: comm = f.grid.distributor.comm - return comm.allreduce(v, dv.mpi.MPI.MAX).item() + return comm.allreduce(v, mfunc).item() + else: + return v.item() else: raise ValueError("Expected Function, got `%s`" % type(f)) diff --git a/devito/data/data.py b/devito/data/data.py index 90d2570c47..c09fb79a9f 100644 --- a/devito/data/data.py +++ b/devito/data/data.py @@ -197,7 +197,7 @@ def wrapper(data, *args, **kwargs): @property def _is_decomposed(self): return self._is_distributed and configuration['mpi'] and \ - self._distributor.comm.size > 1 + self._distributor.is_parallel def __repr__(self): return super(Data, self._local).__repr__() From 442e4d258c374689e5431c522af340bd89e5538e Mon Sep 17 00:00:00 2001 From: mloubout Date: Mon, 4 Aug 2025 10:34:44 -0400 Subject: [PATCH 2/2] CI: make sure docker use branch name to avoid conflicts --- .github/workflows/pytest-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest-gpu.yml b/.github/workflows/pytest-gpu.yml index 49719994b1..0ace06a2e2 100644 --- a/.github/workflows/pytest-gpu.yml +++ b/.github/workflows/pytest-gpu.yml @@ -77,7 +77,7 @@ jobs: - name: Set per-runner tags run: | echo "DOCKER_IMAGE=${{ matrix.name }}-${RUNNER_NAME// /_}" >> $GITHUB_ENV - echo "CONTAINER_BASENAME=testrun-${{ matrix.name }}-${RUNNER_NAME// /_}" >> $GITHUB_ENV + echo "CONTAINER_BASENAME=testrun-${{ matrix.name }}-${RUNNER_NAME// /_}-${{ github.sha }}" >> $GITHUB_ENV - name: Ensure buildx builder run: |