Dynamic Resize of IterDomains#258
Merged
jacobhinkle merged 66 commits intoNVIDIA:mainfrom May 16, 2023
Merged
Conversation
Collaborator
Author
|
Adding tests and need to iterate, but I think this is a start @naoyam |
jacobhinkle
commented
Apr 28, 2023
naoyam
reviewed
Apr 28, 2023
naoyam
reviewed
Apr 28, 2023
Collaborator
|
Looks good overall. Added some comments |
This should probably be refactored and reused in the original op in case the inputs are all constant at definition.
Resized IterDomains are now replaced, but I am hitting a scheduling error: ``` exception with description "!replay_has_rfactor_inp INTERNAL ASSERT FAILED at "/opt/pytorch/nvfuser/csrc/transform_iter.cpp":519, please report a bug to PyTorch. Error during replay, a transformation was called that conflicts with an rfactor call. Exception raised from BestEffortReplay at /opt/pytorch/nvfuser/csrc/transform_iter.cpp:519 (most recent call first): ```
jacobhinkle
commented
May 1, 2023
test/test_dynamic_transform.cpp
Outdated
Comment on lines
+940
to
+941
| // TODO: The following fails with a SIGFPE in innerReductionHeuristic | ||
| //{{3, 5}, {-3, -2}, false}, // output is zero-dimensional |
i.e. if total_reduction_numel OR total_iteration_numel is zero. In these cases we just return the default ReductionParams, which will launch a single block.
This also checks that we do not parallelize in this case.
This fixes a subtle bug where all C++ tests were passing, but for example `test_cat` in `test_python_frontend.py` failed. The exact same test would fail in Python that succeeded in C++. The reason is that in the Python frontend, a `FusionExecutorCache` is initialized _before_ defining the fusion, i.e. with an empty `Fusion`. Doing the check for dynamic transforms in the constructor then for `FusionExecutorCache` lead to always finding a static (empty) transform. Instead, this commit adds the `isDynamic()` method which will cache its results. It should only be used somewhere inside `runFusionWithInputs` which indicates that the definition of the `Fusion` is complete.
Collaborator
Author
|
!build |
naoyam
reviewed
May 15, 2023
test/test_dynamic_transform.cpp
Outdated
| // Test full negative shifts, so output doesn't overlap input | ||
| {{3, 5}, | ||
| {-5, 2}, | ||
| false}, // TODO: why doesn't this miss due to concretize to broadcast? |
Collaborator
There was a problem hiding this comment.
What is expected in this case?
This change replaces uses of IterDomainBuilder which previously required registerMutation. This is because replacing an IterDomain in a TensorDomain requires creation of an entire new TensorDomain and swapping it out in the enclosing TensorView. This change simplifies that by introducing a protected method IterDomain::setIterType, and making DynamicTransformConcretizer a friend of IterDomain. Then we can simply change the iter_type and not require any changes to the TensorDomain or TensorView. This also means we do not need to modify the resize() command since we will not call it in order to create the concretized IterDomain for resize().
jacobhinkle
commented
May 16, 2023
This reverts commit 15f0cd8.
This was a hold-over from when I was doing more complicated replacements. Since we now just change the IterType to Broadcast or Iteration during concretization, there is not additional complexity to consider, so this function is not needed.
Previously it did not compare resize_transforms_, leading to erroneous cache hits!
jacobhinkle
added a commit
that referenced
this pull request
May 16, 2023
This reverts commit 04b7e7f.
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.
Fixes #256.
This extends the concretization/dynamic Fusion machinery introduced in #24 to include
Resizeexpressions, which is how ops likepad,cat, andsliceare represented.