Skip to content

refactor[next-dace]: change dispatching of visitors for builtin functions#2690

Draft
edopao wants to merge 5 commits into
GridTools:mainfrom
edopao:dace_refactor_lowering
Draft

refactor[next-dace]: change dispatching of visitors for builtin functions#2690
edopao wants to merge 5 commits into
GridTools:mainfrom
edopao:dace_refactor_lowering

Conversation

@edopao

@edopao edopao commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The refactoring includes the following changes:

  • rename gtir_to_sdfg to gtir_to_sdfg_fieldview
  • rename gtir_dataflow to gtir_to_sdfg_iterator
  • rename build_sdfg_from_gtir to lower_program_to_sdfg
  • refactor the dispatch of visitors for builtin function, in both gtir_to_sdfg_fieldview and gtir_to_sdfg_iterator

@edopao edopao changed the title Dace refactor lowering refactor[next-dace]: change dispatching of visitors for builtin functions Jul 3, 2026
@edopao
edopao force-pushed the dace_refactor_lowering branch from 6f99a07 to 057605c Compare July 3, 2026 12:29
@edopao
edopao requested a review from Copilot July 3, 2026 12:32
@edopao
edopao force-pushed the dace_refactor_lowering branch from 057605c to 90d9ce6 Compare July 3, 2026 12:34

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 refactors the DaCe lowering pipeline for gt4py.next by renaming key lowering entry points and restructuring how builtin-function visitors are dispatched in both the fieldview and iterator lowering paths.

Changes:

  • Renames/reshapes lowering entry points (e.g., build_sdfg_from_gtirlower_program_to_sdfg) and adjusts imports/types accordingly.
  • Refactors builtin dispatch in GTIRToSDFG (fieldview) and LambdaToDataflow (iterator) via centralized handler maps.
  • Updates scan/primitives/type helpers to use the split fieldview/iterator lowering modules.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_types.py Updates local-view helpers to return iterator-based IteratorExpr/MemletExpr types.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_scan.py Switches scan lowering to the new fieldview/iterator module split and updated dataflow types.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_primitives.py Retypes primitives to the split builders and iterator dataflow edges; small typing-related adjustments.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py Refactors builtin dispatch in lambda-to-dataflow and retargets builder typing to fieldview interfaces.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_fieldview.py Refactors builtin dispatch in program lowering; introduces _visit_* helpers; renames program lowering entry point.
src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_concat_where.py Updates concat_where lowering to use the fieldview lowering module split.
src/gt4py/next/program_processors/runners/dace/lowering/init.py Updates lowering package exports to point at the refactored lowering entry points.
Comments suppressed due to low confidence (3)

src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py:58

  • gtir_to_sdfg_iterator.py imports gtir_to_sdfg_fieldview using the src.gt4py... package path, which will fail at runtime outside the repository checkout layout. Also, since this module uses from __future__ import annotations, this import is only needed for type checking and can be placed under TYPE_CHECKING to avoid creating an import cycle (fieldview -> primitives -> iterator -> fieldview).
    src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py:18
  • The new TYPE_CHECKING-guarded import for gtir_to_sdfg_fieldview (recommended below) requires TYPE_CHECKING to be imported from typing in this module.
    src/gt4py/next/program_processors/runners/dace/lowering/init.py:23
  • lowering/__init__.py re-exports build_sdfg_from_gtir from gtir_to_sdfg_fieldview, but that function was renamed to lower_program_to_sdfg (and build_sdfg_from_gtir no longer exists). This currently breaks imports like gtx_dace_lowering.build_sdfg_from_gtir(...) used elsewhere in the codebase.
from gt4py.next.program_processors.runners.dace.lowering.gtir_to_sdfg_fieldview import (
    build_sdfg_from_gtir,
)
from gt4py.next.program_processors.runners.dace.lowering.gtir_to_sdfg_utils import (
    flatten_tuple_fields,
    get_map_variable,
)


__all__ = [
    "build_sdfg_from_gtir",
    "flatten_tuple_fields",
    "get_map_variable",
]

@edopao
edopao force-pushed the dace_refactor_lowering branch from 90d9ce6 to 4d8ca3b Compare July 3, 2026 12:38
@edopao
edopao force-pushed the dace_refactor_lowering branch from 4d8ca3b to e92eade Compare July 3, 2026 12:44
@edopao
edopao requested a review from Copilot July 3, 2026 12:49

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 9 out of 9 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_fieldview.py:1231

  • This comment line has a stray "to." at the end (likely meant to be "symbols."), which makes the sentence ungrammatical.

Comment thread src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_scan.py Outdated
Comment thread src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_types.py Outdated
edopao and others added 2 commits July 3, 2026 16:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_iterator.py:52

  • gtir_to_sdfg_fieldview is imported here only to satisfy type annotations, but this creates an avoidable import edge (and contributes to circular imports: fieldview -> primitives -> iterator -> fieldview). Since this module uses from __future__ import annotations, you can move the import behind typing.TYPE_CHECKING (or otherwise defer it) to keep runtime imports acyclic.

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.

2 participants