Skip to content

fix[next-dace]: Attempt to achieve deterministic dace auto optimize - #2635

Merged
edopao merged 18 commits into
GridTools:mainfrom
edopao:dev-toolchain_deterministic
Jun 26, 2026
Merged

fix[next-dace]: Attempt to achieve deterministic dace auto optimize#2635
edopao merged 18 commits into
GridTools:mainfrom
edopao:dev-toolchain_deterministic

Conversation

@edopao

@edopao edopao commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This PR uses ordered data structures and unique node IDs to ensure deterministic lowering to SDFG.

This change was originally implemented by @tehrengruber in #2568.

Comment thread pyproject.toml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make DaCe auto_optimize / lowering in the GT4Py “next” backend deterministic by eliminating order-dependence (e.g., set iteration) and replacing unstable name generation with a shared, deterministic ID generator.

Changes:

  • Switch several order-sensitive collections from set to OrderedSet to stabilize traversal/processing order.
  • Introduce and thread a shared gtx_utils.IDGeneratorPool through key DaCe transformations to generate deterministic, unique names.
  • Pin DaCe to a git branch (dev-sorted_sets) and add ordered-set as a runtime dependency to support deterministic ordered data structures.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
uv.lock Pins dace to a specific git commit/branch and adds ordered-set to the resolved environment.
pyproject.toml Adds runtime dependency on ordered-set and configures dace as a git source.
tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_move_tasklet_into_map.py Updates tests to pass a shared UID pool into the transformation.
tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_fuse_horizontal_conditionblocks.py Updates tests to pass a shared UID pool into the transformation.
src/gt4py/next/program_processors/runners/dace/transformations/utils.py Uses OrderedSet for deterministic upstream traversal results.
src/gt4py/next/program_processors/runners/dace/transformations/splitting_tools.py Replaces unordered edge assignment sets with OrderedSet for deterministic splitting.
src/gt4py/next/program_processors/runners/dace/transformations/split_access_nodes.py Uses OrderedSet for deterministic edge reassignment collection.
src/gt4py/next/program_processors/runners/dace/transformations/simplify.py Replaces UUID-based naming with deterministic UID pool; orders dependencies deterministically.
src/gt4py/next/program_processors/runners/dace/transformations/multi_state_global_self_copy_elimination.py Makes pass dependencies ordered (list instead of set).
src/gt4py/next/program_processors/runners/dace/transformations/move_dataflow_into_if_body.py Updates dataflow classification typing to use OrderedSet.
src/gt4py/next/program_processors/runners/dace/transformations/map_fusion_utils.py Makes connector collections and map parameter handling more deterministic.
src/gt4py/next/program_processors/runners/dace/transformations/inline_fuser.py Updates inlining logic to use OrderedSet for deterministic node ordering.
src/gt4py/next/program_processors/runners/dace/transformations/fuse_horizontal_conditionblocks.py Uses the shared UID pool for deterministic renaming during fusion.
src/gt4py/next/program_processors/runners/dace/transformations/auto_optimize.py Creates a UID pool per optimization run and threads it through key transformations.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg.py Stabilizes nested SDFG connector ordering via sorted connector names.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_dataflow.py Stabilizes nested SDFG connector ordering (and adjusts connector representation).

Comment thread pyproject.toml

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Comment thread pyproject.toml
@edopao edopao changed the title fix[next-dace]: Deterministic dace auto optimize fix[next-dace]: Ise SortedSet for deterministic dace auto optimize Jun 8, 2026
@edopao edopao changed the title fix[next-dace]: Ise SortedSet for deterministic dace auto optimize fix[next-dace]: Use SortedSet to achieve deterministic dace auto optimize Jun 8, 2026
@edopao
edopao marked this pull request as ready for review June 9, 2026 07:43
@edopao
edopao requested a review from Copilot June 9, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Comment thread pyproject.toml
Comment thread pyproject.toml
@edopao edopao changed the title fix[next-dace]: Use SortedSet to achieve deterministic dace auto optimize fix[next-dace]: Use OrderedSet to achieve deterministic dace auto optimize Jun 9, 2026
@edopao edopao changed the title fix[next-dace]: Use OrderedSet to achieve deterministic dace auto optimize fix[next-dace]: Attempt to achieve deterministic dace auto optimize Jun 10, 2026

@philip-paul-mueller philip-paul-mueller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I have some smallish comments.

Comment thread src/gt4py/next/program_processors/runners/dace/transformations/simplify.py Outdated
@edopao

edopao commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

cscs-ci run dace-determinism

@edopao

edopao commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

cscs-ci run dace-determinism

@edopao
edopao merged commit dc50e2a into GridTools:main Jun 26, 2026
32 checks passed
@edopao
edopao deleted the dev-toolchain_deterministic branch June 26, 2026 07:08
FlorianDeconinck pushed a commit that referenced this pull request Jul 28, 2026
#2710)

## Description

PR #2635 bumped the DaCe version
from alpha3 to alpha4. This brought a new simplify pass: `LiftTrivialIf`
which aims at inspecting the conditions of if statements and inlines
code under trivially true/false conditions, see
spcl/dace#2138.

The new pass increases the runtime of simplify such that it is unusable
for large-scale / real-world SDFGs, e.g. parsing the acoustics loop of
fv3 in NDSL with dace orchestration will take >90min with the new pass
compared to 10-15min without. In total, the runtime of the acoustics
translate test blows up from ~30min to nearly 5h with that pass.

Preliminary, crude analysis shows that the bulk of the additional time
is spent in the simplify step of sympy when the condition is evluated.
This puts the slowdown at the heart of the pass, making an easy fix
unlikely.

This PR suggests to just skip the new pass until the runtime drops to
usable levels.

## Requirements

- [ ] All fixes and/or new features come with corresponding tests.
  N/A. Covered by existing test cases.
- [ ] Important design decisions have been documented in the appropriate
ADR inside the [docs/development/ADRs/](docs/development/ADRs/README.md)
folder.
  N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants