Skip to content

fix[next-dace]: Handle duplicate outer AccessNodes for same data in MoveDataflowIntoIfBody#2613

Open
edopao wants to merge 1 commit into
GridTools:mainfrom
edopao:fix/move-dataflow-duplicate-outer-access
Open

fix[next-dace]: Handle duplicate outer AccessNodes for same data in MoveDataflowIntoIfBody#2613
edopao wants to merge 1 commit into
GridTools:mainfrom
edopao:fix/move-dataflow-duplicate-outer-access

Conversation

@edopao
Copy link
Copy Markdown
Contributor

@edopao edopao commented May 29, 2026

Summary

  • Fixes an AssertionError in _replicate_dataflow_into_branch triggered when two distinct AccessNode objects carrying the same outer array name both feed input connectors of a relocatable Tasklet. The first node correctly establishes rename_map[(outer_data, branch_state)]; the second hit the assert … not in rename_map guard even though the mapping was already valid.
  • The fix skips updating rename_map when the entry already exists (first mapping wins) while still recording the new outer_node in node_map so edge-creation logic can find it.
  • Adds test_if_mover_two_accessnodes_same_outer_data that constructs an SDFG where array "a" is fed into a Map through two separate AccessNode objects and verifies the transformation applies without crashing.

Test plan

  • Run pytest tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_move_dataflow_into_if_body.py -k test_if_mover_two_accessnodes_same_outer_data
  • Run the full test_move_dataflow_into_if_body.py test file to check for regressions

🤖 Generated with Claude Code

…oveDataflowIntoIfBody

When a relocated Tasklet is fed by two distinct AccessNode objects that both
carry the same outer array name (e.g. a stencil-like read where the same
non-transient field is accessed via two separate Map connectors), the second
incoming edge enters the `elif outer_data in fully_mapped_in_data` branch of
`_replicate_dataflow_into_branch` and hits:

    assert (outer_data, branch_state) not in rename_map

The first edge already stored the mapping; the second outer node is a
different Python object so the `if (outer_node, branch_state) in node_map`
guard does not catch it, but `rename_map` was already written.

Fix: replace the assertion with a conditional so that only the first
AccessNode establishes the rename_map entry while every subsequent one still
registers itself in `node_map` (allowing the edge-creation code below to look
it up).  The resulting inner SDFG is correct: multiple inner edges from the
same inner AccessNode to the Tasklet's different input connectors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an AssertionError in MoveDataflowIntoIfBody._replicate_dataflow_into_branch when two distinct outer AccessNode objects refer to the same data and both feed input connectors of a relocatable Tasklet. The fix makes rename_map updates idempotent (first mapping wins) while still recording each distinct outer node in node_map, and adds a regression test.

Changes:

  • Replace unconditional assert/assign to rename_map with a conditional update in the already-fully-mapped branch.
  • Add test_if_mover_two_accessnodes_same_outer_data reproducing and verifying the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/gt4py/next/program_processors/runners/dace/transformations/move_dataflow_into_if_body.py Skip overwriting existing rename_map entry; always record new outer_node in node_map.
tests/.../test_move_dataflow_into_if_body.py New regression test with two distinct outer AccessNode("a") objects feeding a relocatable tasklet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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