Skip to content

fix[next-dace]: return no successors for terminal blocks in find_successor_state - #2813

Open
edopao wants to merge 2 commits into
GridTools:mainfrom
edopao:dace-find-successor-terminal-state
Open

fix[next-dace]: return no successors for terminal blocks in find_successor_state#2813
edopao wants to merge 2 commits into
GridTools:mainfrom
edopao:dace-find-successor-terminal-state

Conversation

@edopao

@edopao edopao commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Problem

find_successor_state (in gt4py.next.program_processors.runners.dace.transformations.utils) walks the outgoing region edges of a control-flow state, ascending into parent regions when a block has no successors locally. If the queried block and all its enclosing regions are terminal, the walk reached the SDFG root region and then recursed with the root region itself as state, so graph = state.parent_graph was None and the subsequent graph.nodes() call raised AttributeError: 'NoneType' object has no attribute 'nodes'.

This was hit via MultiStateGlobalSelfCopyElimination, which calls find_successor_state on transient-defining states (e.g. from OIR programs whose defining state is a terminal top-level block or inside a terminal LoopRegion).

Fix

Treat the root region as the termination point of the walk: the no-successors early-return condition in the inner _impl of find_successor_state now also triggers when graph.parent_graph is None (i.e. graph is the SDFG root region), returning an empty successor list instead of recursing into None.

Tests

New file tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_utils.py with two regression tests:

  • test_find_successor_state: a terminal top-level state returns [] (previously crashed with AttributeError), a non-terminal state returns its successor.
  • test_find_successor_state_terminal_loop_region: the last state of a LoopRegion body, where the loop itself is terminal at the top level, returns [] instead of crashing.

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.

1 participant