ThrudPrimrose / dace

DaCe - Data Centric Parallel Programming
http://dace.is/fast
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Multi SDFG Auto Optimize Problems #3

Open ThrudPrimrose opened 2 weeks ago

ThrudPrimrose commented 2 weeks ago

I tried merging my auto-profile, auto-apply utility functions and transformations to the multi_sdfg branch. Currently auto_optimize fails in the simplify pass. (Before, it was not failing with an exception and only resulting in an invalid SDFG).

To reproduce:

import dace
from dace.transformation.auto_tile import auto_tile_util, auto_profile
from dace.sdfg import SDFG
from dace.transformation.auto import auto_optimize as aopt

sdfg = SDFG.from_file("velocity_tendencies_simplified_f.sdfgz")
#sdfg.simplify()
#sdfg.apply_gpu_transformations(validate=False, validate_all=False)
sdfg2 = aopt.auto_optimize(sdfg, dace.DeviceType.GPU, validate=False, validate_all=False)
inputs = dict()
profile_results = auto_profile.auto_profile(
    sdfg=sdfg2,
    defined_symbols=inputs,
    verbose=True,
    re_profile=True,
    save_individual_kernels=True,
)

Input file is the velocity tendencies.

Error is:

_4047_p_int_38, 0:__f2dace_SA_geofac_rot_d_1_s_4048_p_int_38, 0:__f2dace_SA_geofac_rot_d_2_s_4049_p_int_38, src_shape: (1,)
  warnings.warn(f'validate_subsets failed: {ex}')
Traceback (most recent call last):
  File "/home/primrose/Work/IconGrounds/auto_profile.py", line 9, in <module>
    sdfg2 = aopt.auto_optimize(sdfg, dace.DeviceType.GPU, validate=False, validate_all=False)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/auto/auto_optimize.py", line 575, in auto_optimize
    sdfg.simplify(validate=False, validate_all=validate_all)
  File "/home/primrose/Work/forkdace/dace/sdfg/sdfg.py", line 2456, in simplify
    return SimplifyPass(validate=validate, validate_all=validate_all, verbose=verbose).apply_pass(self, {})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/passes/simplify.py", line 130, in apply_pass
    result = super().apply_pass(sdfg, pipeline_results)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/pass_pipeline.py", line 574, in apply_pass
    newret = super().apply_pass(sdfg, state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/pass_pipeline.py", line 529, in apply_pass
    r = self.apply_subpass(sdfg, p, state)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/passes/simplify.py", line 107, in apply_subpass
    ret = p.apply_pass(sdfg, state)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/passes/fusion_inline.py", line 83, in apply_pass
    inlined = inline_sdfgs(sdfg, self.permissive, self.progress, self.multistate)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/sdfg/utils.py", line 1345, in inline_sdfgs
    inliner.apply(parent_state, parent_sdfg)
  File "/home/primrose/Work/forkdace/dace/transformation/transformation.py", line 1073, in blocksafe_wrapper
    return vanilla_method(tgt, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/interstate/sdfg_nesting.py", line 517, in apply
    modified_edges |= self._modify_memlet_path(new_incoming_edges, nstate, state, sink_to_outer, True,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/interstate/sdfg_nesting.py", line 802, in _modify_memlet_path
    traverse(child, state, nstate)
  File "/home/primrose/Work/forkdace/dace/transformation/interstate/sdfg_nesting.py", line 793, in traverse
    mtree_node.edge._data = helpers.unsqueeze_memlet(mtree_node.edge.data,
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/transformation/helpers.py", line 823, in unsqueeze_memlet
    internal_subset = internal_subset.offset_new(internal_offset, False)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/primrose/Work/forkdace/dace/subsets.py", line 429, in offset_new
    return Range([(self.ranges[i][0] + mult * off[i], self.ranges[i][1] + mult * off[i], self.ranges[i][2])
                                              ~~~^^^
IndexError: list index out of range
ThrudPrimrose commented 2 weeks ago

Phil I decided to create issues here than constantly write messages that can get lost

ThrudPrimrose commented 2 weeks ago

My first big task is to fix simplify and auto optimize bugs for velocity tendencies. I want to try to be a bit general such that we can apply everything to ECRAD without too much re-writing.