From 383b5c238e20fa2f721bdffab34bff087f138b72 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Thu, 19 Mar 2026 11:42:55 +0100 Subject: [PATCH 01/14] All warnings in the optimizer are now conditioned on the debug state. --- .../dace/transformations/auto_optimize.py | 10 ++++---- .../transformations/concat_where_mapper.py | 19 +++++++-------- .../runners/dace/transformations/gpu_utils.py | 9 ++++--- .../dace/transformations/inline_fuser.py | 3 +-- .../dace/transformations/map_promoter.py | 5 ++-- .../remove_access_node_copies.py | 11 +++++---- .../runners/dace/transformations/simplify.py | 3 +-- .../transformations/split_access_nodes.py | 5 ++-- .../dace/transformations/split_memlet.py | 3 +-- .../dace/transformations/state_fusion.py | 5 ++-- .../runners/dace/transformations/utils.py | 24 ++++++++++++++++++- 11 files changed, 56 insertions(+), 41 deletions(-) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py b/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py index 799e8ad228..332bea896c 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py @@ -9,7 +9,6 @@ """Fast access to the auto optimization on DaCe.""" import enum -import warnings from typing import Any, Callable, Optional, Sequence, TypeAlias, Union import dace @@ -275,7 +274,7 @@ def gt_auto_optimize( if demote_fields is not None: for field_to_demote in demote_fields: if field_to_demote not in sdfg.arrays: - warnings.warn( + gtx_transformations.utils.warn( f"Requested the demotion of field '{field_to_demote}' but the field is unknown.", stacklevel=0, ) @@ -283,7 +282,7 @@ def gt_auto_optimize( field_desc = sdfg.arrays[field_to_demote] if field_desc.transient: - warnings.warn( + gtx_transformations.utils.warn( f"Requested the demotion of field '{field_to_demote}' but the field is a transient.", stacklevel=0, ) @@ -364,7 +363,7 @@ def gt_auto_optimize( sdfg.arrays[demoted_field].transient = False else: - warnings.warn( + gtx_transformations.utils.warn( f"Could not restore the demoted field '{demoted_field}' back to a global.", stacklevel=0, ) @@ -871,7 +870,8 @@ def _gt_auto_configure_maps_and_strides( if gpu: if unit_strides_kind != gtx_common.DimensionKind.HORIZONTAL: - warnings.warn( + # TODO(reviewer): I am not sure if we should always print it. + gtx_transformations.utils.warn( "The GT4Py DaCe GPU backend assumes that the leading dimension, i.e." " where stride is 1, is of kind 'HORIZONTAL', however it was" f" '{unit_strides_kind}'. Furthermore, it should be the last dimension." diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py b/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py index 8052426f33..084f1f32d1 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py @@ -9,7 +9,6 @@ import copy import dataclasses import functools -import warnings from typing import Any, Collection, Literal, Mapping, Optional, Sequence, TypeAlias, Union, overload import dace @@ -1353,18 +1352,16 @@ def _handle_special_case_of_gt4py_scan_point( if _handle_special_case_of_gt4py_scan_point_impl( state, descending_point, concat_node, consumed_subset ): - if __debug__: - warnings.warn( - f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}`.", - stacklevel=1, - ) + gtx_transformations.utils.warn( + f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}`.", + stacklevel=1, + ) return True else: - if __debug__: - warnings.warn( - f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}` was rejected.", - stacklevel=1, - ) + gtx_transformations.utils.warn( + f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}` was rejected.", + stacklevel=1, + ) return False diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py b/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py index aa34736c8a..674bbe22b5 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py @@ -11,7 +11,6 @@ from __future__ import annotations import copy -import warnings from typing import Any, Callable, Final, Optional, Sequence, Union import dace @@ -622,14 +621,14 @@ def __init__( if block_size_1d is not None: self.block_size_1d = block_size_1d if self.block_size_1d[1] != 1 or self.block_size_1d[2] != 1: - warnings.warn( + gtx_transformations.utils.warn( f"1D map block size specified with more than one dimension larger than 1. Configured 1D block size: {self.block_size_1d}.", stacklevel=0, ) if block_size_2d is not None: self.block_size_2d = block_size_2d if self.block_size_2d[2] != 1: - warnings.warn( + gtx_transformations.utils.warn( f"2D map block size specified with more than twi dimensions larger than 1. Configured 2D block size: {self.block_size_2d}.", stacklevel=0, ) @@ -707,7 +706,7 @@ def apply( if is_degenerated_1d_map: num_map_params = 1 - warnings.warn( + gtx_transformations.utils.warn( f"Map '{gpu_map}', size '{map_size}', is a degenerated 1d Map. Handle it as a 1d Map.", stacklevel=0, ) @@ -728,7 +727,7 @@ def apply( ) block_size[block_size_1D_index] = self.block_size_1d[0] if block_size_1D_index != 0: - warnings.warn( + gtx_transformations.utils.warn( f"Blocksize of 1d Map '{gpu_map}' was set to {block_size}, but the iteration index is not the x dimension.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py b/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py index dd8fc12487..6d5a600286 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py @@ -7,7 +7,6 @@ # SPDX-License-Identifier: BSD-3-Clause import copy -import warnings from typing import Final, Iterable, Optional, Sequence, TypeAlias import dace @@ -564,7 +563,7 @@ def _populate_nested_sdfg( "Connections to a non replicated node are only allowed if the source node is an AccessNode" ) - warnings.warn( + gtx_transformations.utils.warn( "Detected computation of data that might not be needed in inline fuser.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py b/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py index 4aff635c23..e9c9051dbc 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py @@ -7,7 +7,6 @@ # SPDX-License-Identifier: BSD-3-Clause import copy -import warnings from typing import Any, Callable, Mapping, Optional, TypeAlias, Union import dace @@ -211,7 +210,7 @@ def __init__( self._bypass_fusion_test = False if not self.fuse_after_promotion: - warnings.warn( + gtx_transformations.utils.warn( "Created a `MapPromoter` that does not fuse immediately, which might lead to borderline invalid SDFGs.", stacklevel=1, ) @@ -286,7 +285,7 @@ def can_be_applied( if (second_map_iterations > 0) != True: # noqa: E712 [true-false-comparison] # SymPy fuzzy bools. return False else: - warnings.warn( + gtx_transformations.utils.warn( "Was unable to determine if the second Map ({second_map_entry}) is executed.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py b/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py index 97e9a18a4e..54d3b35af4 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py @@ -14,7 +14,6 @@ # be removed because the same data are copied from the first all the way to fourth node. # The split should be done using SplitAccessNode transformation. -import warnings from typing import Any, Optional import dace @@ -26,6 +25,7 @@ from dace.sdfg import nodes as dace_nodes from dace.transformation.passes import analysis as dace_analysis +from gt4py.next.program_processors.runners.dace import transformations as gtx_transformations from gt4py.next.program_processors.runners.dace.transformations import ( splitting_tools as gtx_dace_split, strides as gtx_transformations_strides, @@ -152,14 +152,15 @@ def can_be_applied( first_node_writes_subset = gtx_dace_split.subset_merger(ranges_written_to_first_node) if len(first_node_writes_subset) != 1: - warnings.warn( + # TODO(reviewer): I am actually not sure, if we should keep these warnings active all the times? + gtx_transformations.utils.warn( "[RemoveAccessNodeCopies] The range of writes to the first node is not a single range.", stacklevel=0, ) return False fourth_node_writes_subset = gtx_dace_split.subset_merger(ranges_written_to_fourth_node) if len(fourth_node_writes_subset) != 1: - warnings.warn( + gtx_transformations.utils.warn( "[RemoveAccessNodeCopies] The range of writes to the fourth node is not a single range.", stacklevel=0, ) @@ -170,13 +171,13 @@ def can_be_applied( [union_written_to_first_node_data, union_written_to_fourth_node_data] ) if len(union_written_to_common_data) != 1: - warnings.warn( + gtx_transformations.utils.warn( "[RemoveAccessNodeCopies] The union of the ranges written to the first and fourth nodes is not a single range.", stacklevel=0, ) return False if union_written_to_common_data != first_node_range: - warnings.warn( + gtx_transformations.utils.warn( "[RemoveAccessNodeCopies] The whole range of the first node is not written.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py b/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py index 8c08f3459a..d223c8e2ce 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py @@ -11,7 +11,6 @@ import collections import copy import uuid -import warnings from typing import Any, Iterable, Optional, TypeAlias import dace @@ -371,7 +370,7 @@ def gt_inline_nested_sdfg( nb_inlines_total += 1 if nsdfg_node.label.startswith("scan_"): # See `gtir_to_sdfg_scan.py::translate_scan()` for more information. - warnings.warn( + gtx_transformations.utils.warn( f"Inlined '{nsdfg_node.label}' which might be a scan, this might leads to errors during simplification.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py b/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py index 177897ed83..63790d4173 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py @@ -6,7 +6,6 @@ # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause -import warnings from typing import Any, Iterable, Optional import dace @@ -361,7 +360,7 @@ def _find_edge_reassignment( if unused_producers: # This situation is generated by MapFusion, if the intermediate # AccessNode has to be kept alive. - warnings.warn( + gtx_transformations.utils.warn( "'SplitAccessNode': found producers " + ", ".join((str(p) for p in unused_producers)) + " that generates data but that is never read.", @@ -413,7 +412,7 @@ def _find_producer( # one Tasklet writes `T[__i, 0]` the other `T[__i, 10]`, where `__i` # is the iteration index. Then Memlet propagation will set the subset # to something like `T[:, 0:10]`. So it is not an error in that case. - warnings.warn( + gtx_transformations.utils.warn( f"Found transient '{self.access_node.data}' that has multiple overlapping" " incoming edges. Might indicate an error.", stacklevel=0, diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py b/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py index 761bcd5e40..78240a89d5 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py @@ -6,7 +6,6 @@ # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause -import warnings from typing import Any, Optional import dace @@ -94,7 +93,7 @@ def can_be_applied( # TODO(phimuell): For optimal result we should fuse these edges first. src_to_dest_edges = list(graph.edges_between(src_node, dst_node)) if len(src_to_dest_edges) != 1: - warnings.warn( + gtx_transformations.utils.warn( f"Found multiple edges between '{src_node.data}' and '{dst_node.data}'", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py b/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py index 65980745f9..40506bf2fa 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py @@ -6,13 +6,14 @@ # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause -import warnings from typing import Any import dace from dace import transformation as dace_transformation from dace.sdfg import nodes as dace_nodes, utils as dace_sdutils +from gt4py.next.program_processors.runners.dace import transformations as gtx_transformations + # Conditional import because `gt4py.cartesian` uses an older DaCe version without # `explicit_cf_compatible`. @@ -222,7 +223,7 @@ def _check_for_read_write_dependencies( # AccessNode to the same data. In case it is global this is most likely # valid. However, I think that simply allow it, is not okay, because # it might break some assumption in the fuse code. - warnings.warn( + gtx_transformations.utils.warn( f"Detected that '{first_state}' writes to the data" f" `{', '.join(all_data_producers.intersection(data_producers[-1]))}`" " in multiple concurrent subgraphs. This might indicate an error.", diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/utils.py b/src/gt4py/next/program_processors/runners/dace/transformations/utils.py index 68a7c33201..8dd155aa8d 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/utils.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/utils.py @@ -8,8 +8,10 @@ """Common functionality for the transformations/optimization pipeline.""" +import functools import uuid -from typing import Optional, Sequence, TypeVar, Union +import warnings +from typing import Any, Optional, Sequence, TypeVar, Union import dace from dace import data as dace_data, libraries as dace_lib, subsets as dace_sbs, symbolic as dace_sym @@ -21,6 +23,26 @@ _PassT = TypeVar("_PassT", bound=dace_ppl.Pass) +@functools.wraps(warnings.warn) +def warn( + message: str, + category: type[Warning] | None = None, + stacklevel: int = 1, + source: Any | None = None, + *, + skip_file_prefixes: tuple[Any, ...] = (), +) -> None: + """Wrapper around `warnings.warn()` function that is only enabled in debug mode.""" + if __debug__: + warnings.warn( # type: ignore[call-overload] # For some reason MyPy complains about the last argument. + message=message, + category=category, + stacklevel=(stacklevel + 1), + source=source, + skip_file_prefixes=skip_file_prefixes, + ) + + def unique_name(name: str) -> str: """Adds a unique string to `name`. From ea1610dd0a5c153b3b8f754074e7647f72284736 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Thu, 19 Mar 2026 13:13:57 +0100 Subject: [PATCH 02/14] Fixed a compatibility issue. --- .../runners/dace/transformations/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/utils.py b/src/gt4py/next/program_processors/runners/dace/transformations/utils.py index 8dd155aa8d..178bd09f6d 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/utils.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/utils.py @@ -29,17 +29,16 @@ def warn( category: type[Warning] | None = None, stacklevel: int = 1, source: Any | None = None, - *, - skip_file_prefixes: tuple[Any, ...] = (), ) -> None: """Wrapper around `warnings.warn()` function that is only enabled in debug mode.""" if __debug__: - warnings.warn( # type: ignore[call-overload] # For some reason MyPy complains about the last argument. + # NOTE: The `skip_file_prefixes` argument was introduced in Python 3.12 and is + # ignored. + warnings.warn( message=message, category=category, stacklevel=(stacklevel + 1), source=source, - skip_file_prefixes=skip_file_prefixes, ) From 22902dc5e06cdd9b5c4412d4a9888901d9248f96 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Thu, 19 Mar 2026 13:32:05 +0100 Subject: [PATCH 03/14] Removed some comments. --- .../runners/dace/transformations/auto_optimize.py | 1 - .../runners/dace/transformations/remove_access_node_copies.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py b/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py index 4c5da4b4bf..d304f31c93 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py @@ -875,7 +875,6 @@ def _gt_auto_configure_maps_and_strides( if gpu: if unit_strides_kind != gtx_common.DimensionKind.HORIZONTAL: - # TODO(reviewer): I am not sure if we should always print it. gtx_transformations.utils.warn( "The GT4Py DaCe GPU backend assumes that the leading dimension, i.e." " where stride is 1, is of kind 'HORIZONTAL', however it was" diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py b/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py index 54d3b35af4..b001a12f4e 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py @@ -152,7 +152,6 @@ def can_be_applied( first_node_writes_subset = gtx_dace_split.subset_merger(ranges_written_to_first_node) if len(first_node_writes_subset) != 1: - # TODO(reviewer): I am actually not sure, if we should keep these warnings active all the times? gtx_transformations.utils.warn( "[RemoveAccessNodeCopies] The range of writes to the first node is not a single range.", stacklevel=0, From bbe84ded0bfb35ea118fca91d10a709168abe47a Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Thu, 19 Mar 2026 13:35:56 +0100 Subject: [PATCH 04/14] Added a small test. --- .../transformation_tests/test_strides.py | 2 -- .../transformation_tests/test_warnings.py | 22 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_strides.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_strides.py index f1c8da0143..2258a0931c 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_strides.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_strides.py @@ -20,8 +20,6 @@ from . import util -import dace - def _make_strides_propagation_level3_sdfg() -> dace.SDFG: """Generates the level 3 SDFG (nested-nested) SDFG for `test_strides_propagation()`.""" diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py new file mode 100644 index 0000000000..ccff865b34 --- /dev/null +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -0,0 +1,22 @@ +# GT4Py - GridTools Framework +# +# Copyright (c) 2014-2024, ETH Zurich +# All rights reserved. +# +# Please, refer to the LICENSE file in the root directory. +# SPDX-License-Identifier: BSD-3-Clause + +import pytest +import numpy as np +import copy + +from gt4py.next.program_processors.runners.dace import ( + transformations as gtx_transformations, +) + + +def test_if_warning_is_raised(): + warn_msg = "This is a warning." + + with pytest.warns(UserWarning, match=warn_msg): + gtx_transformations.utils.warn(warn_msg, UserWarning) From 4b2292e5196ffb1d6be16667d4e6cf41acc0062b Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 07:45:08 +0100 Subject: [PATCH 05/14] Let's hope that this helps. Apperently it want's to run a DaCe test. --- .../runners_tests/dace_tests/transformation_tests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py index a576665ee3..5d748e0586 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py @@ -10,4 +10,4 @@ #: Attribute defining package-level marks used by a custom pytest hook. -package_pytestmarks = [pytest.mark.usefixtures("common_dace_config")] +package_pytestmarks = [pytest.mark.requires_dace, pytest.mark.usefixtures("common_dace_config")] From cbb18fefd82af8c435e92312a0a10e3fe5801e2d Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 08:20:44 +0100 Subject: [PATCH 06/14] Setting the marker in `__init__.py` does not seem enough. --- .../dace_tests/transformation_tests/test_warnings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index ccff865b34..d84bb5653b 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -10,6 +10,10 @@ import numpy as np import copy +# Without this the test fails if DaCe is not installed, even when the `requires_dace` +# marker is configured in `__init__.py`. +dace = pytest.importorskip("dace") + from gt4py.next.program_processors.runners.dace import ( transformations as gtx_transformations, ) From 751c22629c4ab49e447ba6973dfebf99da4a202d Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 09:14:33 +0100 Subject: [PATCH 07/14] Small experiment. --- .../dace_tests/transformation_tests/__init__.py | 3 ++- .../transformation_tests/test_warnings.py | 13 +++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py index 5d748e0586..b67cc8d21c 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py @@ -10,4 +10,5 @@ #: Attribute defining package-level marks used by a custom pytest hook. -package_pytestmarks = [pytest.mark.requires_dace, pytest.mark.usefixtures("common_dace_config")] +# package_pytestmarks = [pytest.mark.requires_dace, pytest.mark.usefixtures("common_dace_config")] +package_pytestmarks = [pytest.mark.usefixtures("common_dace_config")] diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index d84bb5653b..371dfbd455 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -10,16 +10,13 @@ import numpy as np import copy -# Without this the test fails if DaCe is not installed, even when the `requires_dace` -# marker is configured in `__init__.py`. -dace = pytest.importorskip("dace") - -from gt4py.next.program_processors.runners.dace import ( - transformations as gtx_transformations, -) - def test_if_warning_is_raised(): + # Avoid importing DaCe as a side effect during test discovery if DaCe is not installed. + from gt4py.next.program_processors.runners.dace import ( + transformations as gtx_transformations, + ) + warn_msg = "This is a warning." with pytest.warns(UserWarning, match=warn_msg): From b1870f695469e8be9470c319453f75392c8dce86 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 10:11:08 +0100 Subject: [PATCH 08/14] Revert "Small experiment." The experiment was successfull. This reverts commit 751c22629c4ab49e447ba6973dfebf99da4a202d. --- .../dace_tests/transformation_tests/__init__.py | 3 +-- .../transformation_tests/test_warnings.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py index b67cc8d21c..5d748e0586 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/__init__.py @@ -10,5 +10,4 @@ #: Attribute defining package-level marks used by a custom pytest hook. -# package_pytestmarks = [pytest.mark.requires_dace, pytest.mark.usefixtures("common_dace_config")] -package_pytestmarks = [pytest.mark.usefixtures("common_dace_config")] +package_pytestmarks = [pytest.mark.requires_dace, pytest.mark.usefixtures("common_dace_config")] diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index 371dfbd455..d84bb5653b 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -10,13 +10,16 @@ import numpy as np import copy +# Without this the test fails if DaCe is not installed, even when the `requires_dace` +# marker is configured in `__init__.py`. +dace = pytest.importorskip("dace") + +from gt4py.next.program_processors.runners.dace import ( + transformations as gtx_transformations, +) -def test_if_warning_is_raised(): - # Avoid importing DaCe as a side effect during test discovery if DaCe is not installed. - from gt4py.next.program_processors.runners.dace import ( - transformations as gtx_transformations, - ) +def test_if_warning_is_raised(): warn_msg = "This is a warning." with pytest.warns(UserWarning, match=warn_msg): From 6ed3788b4ef28bc66c75a5143d0539aaccf35f34 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 13:16:22 +0100 Subject: [PATCH 09/14] Started implementing Enrique's idea. --- .../dace/transformations/auto_optimize.py | 9 ++++---- .../transformations/concat_where_mapper.py | 5 ++-- .../runners/dace/transformations/gpu_utils.py | 9 ++++---- .../dace/transformations/inline_fuser.py | 3 ++- .../dace/transformations/map_promoter.py | 5 ++-- .../remove_access_node_copies.py | 10 ++++---- .../runners/dace/transformations/simplify.py | 3 ++- .../transformations/split_access_nodes.py | 5 ++-- .../dace/transformations/split_memlet.py | 3 ++- .../dace/transformations/state_fusion.py | 5 ++-- .../runners/dace/transformations/utils.py | 23 +------------------ 11 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py b/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py index d304f31c93..b8dc0ab5bc 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py @@ -9,6 +9,7 @@ """Fast access to the auto optimization on DaCe.""" import enum +import warnings from typing import Any, Callable, Optional, Sequence, TypeAlias, Union import dace @@ -279,7 +280,7 @@ def gt_auto_optimize( if demote_fields is not None: for field_to_demote in demote_fields: if field_to_demote not in sdfg.arrays: - gtx_transformations.utils.warn( + warnings.warn( f"Requested the demotion of field '{field_to_demote}' but the field is unknown.", stacklevel=0, ) @@ -287,7 +288,7 @@ def gt_auto_optimize( field_desc = sdfg.arrays[field_to_demote] if field_desc.transient: - gtx_transformations.utils.warn( + warnings.warn( f"Requested the demotion of field '{field_to_demote}' but the field is a transient.", stacklevel=0, ) @@ -368,7 +369,7 @@ def gt_auto_optimize( sdfg.arrays[demoted_field].transient = False else: - gtx_transformations.utils.warn( + warnings.warn( f"Could not restore the demoted field '{demoted_field}' back to a global.", stacklevel=0, ) @@ -875,7 +876,7 @@ def _gt_auto_configure_maps_and_strides( if gpu: if unit_strides_kind != gtx_common.DimensionKind.HORIZONTAL: - gtx_transformations.utils.warn( + warnings.warn( "The GT4Py DaCe GPU backend assumes that the leading dimension, i.e." " where stride is 1, is of kind 'HORIZONTAL', however it was" f" '{unit_strides_kind}'. Furthermore, it should be the last dimension." diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py b/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py index 084f1f32d1..535c9cb2eb 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/concat_where_mapper.py @@ -9,6 +9,7 @@ import copy import dataclasses import functools +import warnings from typing import Any, Collection, Literal, Mapping, Optional, Sequence, TypeAlias, Union, overload import dace @@ -1352,13 +1353,13 @@ def _handle_special_case_of_gt4py_scan_point( if _handle_special_case_of_gt4py_scan_point_impl( state, descending_point, concat_node, consumed_subset ): - gtx_transformations.utils.warn( + warnings.warn( f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}`.", stacklevel=1, ) return True else: - gtx_transformations.utils.warn( + warnings.warn( f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}` was rejected.", stacklevel=1, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py b/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py index 674bbe22b5..aa34736c8a 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/gpu_utils.py @@ -11,6 +11,7 @@ from __future__ import annotations import copy +import warnings from typing import Any, Callable, Final, Optional, Sequence, Union import dace @@ -621,14 +622,14 @@ def __init__( if block_size_1d is not None: self.block_size_1d = block_size_1d if self.block_size_1d[1] != 1 or self.block_size_1d[2] != 1: - gtx_transformations.utils.warn( + warnings.warn( f"1D map block size specified with more than one dimension larger than 1. Configured 1D block size: {self.block_size_1d}.", stacklevel=0, ) if block_size_2d is not None: self.block_size_2d = block_size_2d if self.block_size_2d[2] != 1: - gtx_transformations.utils.warn( + warnings.warn( f"2D map block size specified with more than twi dimensions larger than 1. Configured 2D block size: {self.block_size_2d}.", stacklevel=0, ) @@ -706,7 +707,7 @@ def apply( if is_degenerated_1d_map: num_map_params = 1 - gtx_transformations.utils.warn( + warnings.warn( f"Map '{gpu_map}', size '{map_size}', is a degenerated 1d Map. Handle it as a 1d Map.", stacklevel=0, ) @@ -727,7 +728,7 @@ def apply( ) block_size[block_size_1D_index] = self.block_size_1d[0] if block_size_1D_index != 0: - gtx_transformations.utils.warn( + warnings.warn( f"Blocksize of 1d Map '{gpu_map}' was set to {block_size}, but the iteration index is not the x dimension.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py b/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py index 6d5a600286..dd8fc12487 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py @@ -7,6 +7,7 @@ # SPDX-License-Identifier: BSD-3-Clause import copy +import warnings from typing import Final, Iterable, Optional, Sequence, TypeAlias import dace @@ -563,7 +564,7 @@ def _populate_nested_sdfg( "Connections to a non replicated node are only allowed if the source node is an AccessNode" ) - gtx_transformations.utils.warn( + warnings.warn( "Detected computation of data that might not be needed in inline fuser.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py b/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py index e9c9051dbc..4aff635c23 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/map_promoter.py @@ -7,6 +7,7 @@ # SPDX-License-Identifier: BSD-3-Clause import copy +import warnings from typing import Any, Callable, Mapping, Optional, TypeAlias, Union import dace @@ -210,7 +211,7 @@ def __init__( self._bypass_fusion_test = False if not self.fuse_after_promotion: - gtx_transformations.utils.warn( + warnings.warn( "Created a `MapPromoter` that does not fuse immediately, which might lead to borderline invalid SDFGs.", stacklevel=1, ) @@ -285,7 +286,7 @@ def can_be_applied( if (second_map_iterations > 0) != True: # noqa: E712 [true-false-comparison] # SymPy fuzzy bools. return False else: - gtx_transformations.utils.warn( + warnings.warn( "Was unable to determine if the second Map ({second_map_entry}) is executed.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py b/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py index b001a12f4e..97e9a18a4e 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/remove_access_node_copies.py @@ -14,6 +14,7 @@ # be removed because the same data are copied from the first all the way to fourth node. # The split should be done using SplitAccessNode transformation. +import warnings from typing import Any, Optional import dace @@ -25,7 +26,6 @@ from dace.sdfg import nodes as dace_nodes from dace.transformation.passes import analysis as dace_analysis -from gt4py.next.program_processors.runners.dace import transformations as gtx_transformations from gt4py.next.program_processors.runners.dace.transformations import ( splitting_tools as gtx_dace_split, strides as gtx_transformations_strides, @@ -152,14 +152,14 @@ def can_be_applied( first_node_writes_subset = gtx_dace_split.subset_merger(ranges_written_to_first_node) if len(first_node_writes_subset) != 1: - gtx_transformations.utils.warn( + warnings.warn( "[RemoveAccessNodeCopies] The range of writes to the first node is not a single range.", stacklevel=0, ) return False fourth_node_writes_subset = gtx_dace_split.subset_merger(ranges_written_to_fourth_node) if len(fourth_node_writes_subset) != 1: - gtx_transformations.utils.warn( + warnings.warn( "[RemoveAccessNodeCopies] The range of writes to the fourth node is not a single range.", stacklevel=0, ) @@ -170,13 +170,13 @@ def can_be_applied( [union_written_to_first_node_data, union_written_to_fourth_node_data] ) if len(union_written_to_common_data) != 1: - gtx_transformations.utils.warn( + warnings.warn( "[RemoveAccessNodeCopies] The union of the ranges written to the first and fourth nodes is not a single range.", stacklevel=0, ) return False if union_written_to_common_data != first_node_range: - gtx_transformations.utils.warn( + warnings.warn( "[RemoveAccessNodeCopies] The whole range of the first node is not written.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py b/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py index d223c8e2ce..8c08f3459a 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/simplify.py @@ -11,6 +11,7 @@ import collections import copy import uuid +import warnings from typing import Any, Iterable, Optional, TypeAlias import dace @@ -370,7 +371,7 @@ def gt_inline_nested_sdfg( nb_inlines_total += 1 if nsdfg_node.label.startswith("scan_"): # See `gtir_to_sdfg_scan.py::translate_scan()` for more information. - gtx_transformations.utils.warn( + warnings.warn( f"Inlined '{nsdfg_node.label}' which might be a scan, this might leads to errors during simplification.", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py b/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py index 63790d4173..177897ed83 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py @@ -6,6 +6,7 @@ # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause +import warnings from typing import Any, Iterable, Optional import dace @@ -360,7 +361,7 @@ def _find_edge_reassignment( if unused_producers: # This situation is generated by MapFusion, if the intermediate # AccessNode has to be kept alive. - gtx_transformations.utils.warn( + warnings.warn( "'SplitAccessNode': found producers " + ", ".join((str(p) for p in unused_producers)) + " that generates data but that is never read.", @@ -412,7 +413,7 @@ def _find_producer( # one Tasklet writes `T[__i, 0]` the other `T[__i, 10]`, where `__i` # is the iteration index. Then Memlet propagation will set the subset # to something like `T[:, 0:10]`. So it is not an error in that case. - gtx_transformations.utils.warn( + warnings.warn( f"Found transient '{self.access_node.data}' that has multiple overlapping" " incoming edges. Might indicate an error.", stacklevel=0, diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py b/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py index 78240a89d5..761bcd5e40 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/split_memlet.py @@ -6,6 +6,7 @@ # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause +import warnings from typing import Any, Optional import dace @@ -93,7 +94,7 @@ def can_be_applied( # TODO(phimuell): For optimal result we should fuse these edges first. src_to_dest_edges = list(graph.edges_between(src_node, dst_node)) if len(src_to_dest_edges) != 1: - gtx_transformations.utils.warn( + warnings.warn( f"Found multiple edges between '{src_node.data}' and '{dst_node.data}'", stacklevel=0, ) diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py b/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py index 40506bf2fa..65980745f9 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/state_fusion.py @@ -6,14 +6,13 @@ # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause +import warnings from typing import Any import dace from dace import transformation as dace_transformation from dace.sdfg import nodes as dace_nodes, utils as dace_sdutils -from gt4py.next.program_processors.runners.dace import transformations as gtx_transformations - # Conditional import because `gt4py.cartesian` uses an older DaCe version without # `explicit_cf_compatible`. @@ -223,7 +222,7 @@ def _check_for_read_write_dependencies( # AccessNode to the same data. In case it is global this is most likely # valid. However, I think that simply allow it, is not okay, because # it might break some assumption in the fuse code. - gtx_transformations.utils.warn( + warnings.warn( f"Detected that '{first_state}' writes to the data" f" `{', '.join(all_data_producers.intersection(data_producers[-1]))}`" " in multiple concurrent subgraphs. This might indicate an error.", diff --git a/src/gt4py/next/program_processors/runners/dace/transformations/utils.py b/src/gt4py/next/program_processors/runners/dace/transformations/utils.py index 178bd09f6d..68a7c33201 100644 --- a/src/gt4py/next/program_processors/runners/dace/transformations/utils.py +++ b/src/gt4py/next/program_processors/runners/dace/transformations/utils.py @@ -8,10 +8,8 @@ """Common functionality for the transformations/optimization pipeline.""" -import functools import uuid -import warnings -from typing import Any, Optional, Sequence, TypeVar, Union +from typing import Optional, Sequence, TypeVar, Union import dace from dace import data as dace_data, libraries as dace_lib, subsets as dace_sbs, symbolic as dace_sym @@ -23,25 +21,6 @@ _PassT = TypeVar("_PassT", bound=dace_ppl.Pass) -@functools.wraps(warnings.warn) -def warn( - message: str, - category: type[Warning] | None = None, - stacklevel: int = 1, - source: Any | None = None, -) -> None: - """Wrapper around `warnings.warn()` function that is only enabled in debug mode.""" - if __debug__: - # NOTE: The `skip_file_prefixes` argument was introduced in Python 3.12 and is - # ignored. - warnings.warn( - message=message, - category=category, - stacklevel=(stacklevel + 1), - source=source, - ) - - def unique_name(name: str) -> str: """Adds a unique string to `name`. From c50576dcbfe22127a19cdc41d49b41917be963cf Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 13:17:48 +0100 Subject: [PATCH 10/14] Modified the test. --- .../dace_tests/transformation_tests/test_warnings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index d84bb5653b..361f5591b0 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -8,7 +8,7 @@ import pytest import numpy as np -import copy +import warnings # Without this the test fails if DaCe is not installed, even when the `requires_dace` # marker is configured in `__init__.py`. @@ -23,4 +23,4 @@ def test_if_warning_is_raised(): warn_msg = "This is a warning." with pytest.warns(UserWarning, match=warn_msg): - gtx_transformations.utils.warn(warn_msg, UserWarning) + warnings.warn(warn_msg, UserWarning) From 092ac767bd964a2a371645f4ba909a89d0956dc5 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Fri, 20 Mar 2026 13:42:25 +0100 Subject: [PATCH 11/14] Blocked warnings from DaCe. --- src/gt4py/next/config.py | 16 ++++++++++++++++ .../transformation_tests/test_warnings.py | 12 +++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gt4py/next/config.py b/src/gt4py/next/config.py index 0e6bf4ff5d..259b68cc33 100644 --- a/src/gt4py/next/config.py +++ b/src/gt4py/next/config.py @@ -12,6 +12,7 @@ import enum import os import pathlib +import warnings from typing import Final @@ -124,6 +125,21 @@ def env_flag_to_int(name: str, default: int) -> int: DUMP_METRICS_AT_EXIT: str | None = None +#: Filter out DaCe related warnings. If not set warnings will be suppressed if the +#: code runs in no debug mode. +SKIP_WARNINGS: bool = env_flag_to_bool("GT4PY_SKIP_WARNINGS", default=not __debug__) + + +if SKIP_WARNINGS: + # NOTE: Ideally we would suppress the warnings using context managers directly in + # the backend. However, because this is not thread safe in Python versions before + # 3.14, we have to do it here. + warnings.filterwarnings(action="ignore", module="^dace(\..+)?") + warnings.filterwarnings( + action="ignore", module="^gt4py.next.program_processors.runners.dace(\..+)?" + ) + + def _init_dump_metrics_filename() -> str: return f"gt4py_metrics_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.json" diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index 361f5591b0..d9665de12d 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -7,20 +7,14 @@ # SPDX-License-Identifier: BSD-3-Clause import pytest -import numpy as np import warnings -# Without this the test fails if DaCe is not installed, even when the `requires_dace` -# marker is configured in `__init__.py`. -dace = pytest.importorskip("dace") - -from gt4py.next.program_processors.runners.dace import ( - transformations as gtx_transformations, -) +from gt4py.next import config as gtx_config def test_if_warning_is_raised(): - warn_msg = "This is a warning." + assert not gtx_config.SKIP_WARNINGS, "Tests do not run in debug mode." + warn_msg = "This is a warning." with pytest.warns(UserWarning, match=warn_msg): warnings.warn(warn_msg, UserWarning) From 2fa7960989b5f9155c7ec68cd4660e271fbed984 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Mon, 23 Mar 2026 09:54:26 +0100 Subject: [PATCH 12/14] Addressed review comments. --- .../dace_tests/transformation_tests/test_warnings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index d9665de12d..f1b1b62fd9 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -13,7 +13,7 @@ def test_if_warning_is_raised(): - assert not gtx_config.SKIP_WARNINGS, "Tests do not run in debug mode." + assert not gtx_config.SKIP_WARNINGS or not __debug__, "Tests do not run in debug mode." warn_msg = "This is a warning." with pytest.warns(UserWarning, match=warn_msg): From 2a75655751d05658b55da5f6b45b8d50e0280d07 Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Mon, 23 Mar 2026 09:55:04 +0100 Subject: [PATCH 13/14] Renamed `SKIP_WARNINGS` to `SKIP_DACE_WARNINGS`. The new name reflects the actuall effect of the variable, which is also described in the doc string. --- src/gt4py/next/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gt4py/next/config.py b/src/gt4py/next/config.py index 259b68cc33..d42ef2cc73 100644 --- a/src/gt4py/next/config.py +++ b/src/gt4py/next/config.py @@ -127,10 +127,10 @@ def env_flag_to_int(name: str, default: int) -> int: #: Filter out DaCe related warnings. If not set warnings will be suppressed if the #: code runs in no debug mode. -SKIP_WARNINGS: bool = env_flag_to_bool("GT4PY_SKIP_WARNINGS", default=not __debug__) +SKIP_DACE_WARNINGS: bool = env_flag_to_bool("GT4PY_SKIP_DACE_WARNINGS", default=not __debug__) -if SKIP_WARNINGS: +if SKIP_DACE_WARNINGS: # NOTE: Ideally we would suppress the warnings using context managers directly in # the backend. However, because this is not thread safe in Python versions before # 3.14, we have to do it here. From eff17073a41a948d38dda7c1ccc6414bf407412f Mon Sep 17 00:00:00 2001 From: "Philip Mueller, CSCS" Date: Mon, 23 Mar 2026 10:21:15 +0100 Subject: [PATCH 14/14] Forgot to change something. --- .../dace_tests/transformation_tests/test_warnings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py index f1b1b62fd9..bdf665db4d 100644 --- a/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py +++ b/tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_warnings.py @@ -13,7 +13,7 @@ def test_if_warning_is_raised(): - assert not gtx_config.SKIP_WARNINGS or not __debug__, "Tests do not run in debug mode." + assert not gtx_config.SKIP_DACE_WARNINGS or not __debug__, "Tests do not run in debug mode." warn_msg = "This is a warning." with pytest.warns(UserWarning, match=warn_msg):