fix[next-dace]: reject state fusion when a transient is written in both states - #2811
Open
edopao wants to merge 2 commits into
Open
fix[next-dace]: reject state fusion when a transient is written in both states#2811edopao wants to merge 2 commits into
edopao wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The stree lowering of
concat_whereemits a transient array that is partially written in two consecutive SDFG states: each state writes a disjoint subset of the transient, with symbolicMax/Minbounds, and the second state also reads it. DaCe's ownSimplifyPasscannot reason about those subsets, so it does not rewrite anything.GT4PyStateFusionthen merged the two states anyway.After the merge, the consumer rewiring in
apply()only reconnects source nodes of the second state, so the first state's write to the transient was left disconnected from the second state's read.DeadDataflowEliminationsubsequently deleted the dangling write, leaving the output partially uninitialized at runtime.Per ADR-018, a transient must be written within a single state, so such a configuration is invalid input for fusion.
Fix
GT4PyStateFusion._check_for_wcr_conflictsnow checks thecommon_write_data(the arrays written by both states) and reports a conflict — refusing the merge — when any commonly-written array is transient, in line with ADR-018's "a transient must be written in a single state" rule. The two states are left separate, preserving the dataflow edge from the first write to the second state's read.Tests
test_transient_in_both_states_write(with factory_make_transient_both_states_write) reproducing theconcat_wherepattern: two states writing disjoint slices of a transientt, the second state also reading it. It asserts thatapply_transformations_repeated(GT4PyStateFusion)applies 0 times and that both states survive intact.transformation_tests/test_state_fusion.pysuite passes (15 passed).