[MetaSchedule] Allow skipping exact NDArray rewrite in RemoveWeightLayoutRewriteBlock #13052
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.
I found that, using MS evo search +
RewriteLayout+link-params=True, where the latter combination is supported by #12991 and #12949, is currently broken for the following reasons:IndexMap::MapNDArrayis slowIndexMap::MapNDArrayis called more than thousands of times during evo search per iteration, by the following call sequence:AssembleCandidatestvm/src/meta_schedule/search_strategy/evolutionary_search.cc
Lines 206 to 209 in 6780c9f
->
ArgInfo::FromEntryFuntvm/src/meta_schedule/arg_info.cc
Lines 104 to 107 in 111169c
->
RemoveWeightLayoutRewriteBlocktvm/src/tir/transforms/remove_weight_layout_rewrite_block.cc
Lines 163 to 167 in 189338c
->
MapNDArraySo what happens right now is that evo search +
link-params=Truewould make tuning appear hanged, while it is busy doing thousands ofMapNDArrayinAssembleCandidates.My proposed workaround for this problem is based on the observation that, when
RemoveWeightLayoutRewriteBlockis called byFromEntryFunduring evo search, the actual content of NDArray before and after rewrite does not matter. So we don't have to useMapNDArrayduring tuning.To enable skipping such "exact" NDArray rewrite, I'm introducing a flag to
RemoveWeightLayoutRewriteBlock. The exact rewrite byMapNDArrayis only required when the pass is called from TECompiler during the final compilation.