Skip to content

next[dace]: track_view raises on a lowering produced View, and reconfigure_dataflow_after_rerouting asserts on an uninitialised Memlet #2775

Description

@havogt

Two traps in runners/dace/transformations/utils.py that a caller cannot reasonably anticipate. Neither is reachable from the pipeline today, so this is about robustness of shared helpers rather than a live defect.

1. track_view raises on a View produced by the lowering

A View created by gtir_dataflow.LambdaToDataflow._construct_local_view lives inside a Map scope, is fed through a MapEntry, and carries no views connector (dst_conn=None). dace.sdfg.utils.get_view_edge cannot then determine the direction:

RuntimeError: Failed to determine the direction of the view 'view_gtir_tmp_8' |
  map_5_fieldop[...]:OUT_gtir_tmp_8 -(gtir_tmp_8[...])-> view_gtir_tmp_8:None.

track_view is the natural helper for "is this data viewed", and this is the shape the lowering actually emits — so the first thing a caller tries fails on the case that matters. Worse, catching the exception and treating it as "not a view" gives a false negative rather than an error.

_gt_modify_strides_of_views_non_recursive (strides.py:650+) calls track_view unguarded. In gt_auto_optimize that code runs after RemovePointwiseViews, so it is not reachable there at present — but the non-transient skip at strides.py:685-690 can consequently only ever apply to properly connected views, which is worth knowing when reasoning about that function.

2. reconfigure_dataflow_after_rerouting asserts on an uninitialised Memlet

utils.py:542, assert subset_to_adjust is not None. reroute_edge and reconfigure_dataflow_after_rerouting read the raw src_subset/dst_subset properties, which return None when Memlet._is_data_src was never set. add_mapped_tasklet sets it to False, which is why every producer built the normal way works, and why this only shows up on a hand constructed edge.

Not a defect in the helpers' intended use, but an unhelpful failure mode for anyone assembling an SDFG programmatically — an assertion deep inside a helper rather than a message about the input. It is equally reachable from GT4PyMapBufferElimination.

Suggestion

For (1), either make track_view return a definite "cannot determine" result instead of raising, or document that it only accepts properly connected views and provide something that answers the "is this data viewed" question for the lowering's own shapes. For (2), a clearer error, or try_initialize in the helper.

Found while adding a view rejection to GT4PyWriteBackBufferElimination (#2763) — track_view was the obvious tool and could not be used, so the check resolves the name from the view edge instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gt4py.nextIssues concerning the new version with support for non-cartesian grids.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions