[AutoScheduler] Fix task extraction with TE compiler #8560
Merged
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.
Per discussion in https://discuss.tvm.apache.org/t/te-compiler-device-type-error-in-updatemainworkspacesize/10536/5, the updated TE compiler has a different behavior as the old compile engine in terms of visiting each Relay function for compilation. Specifically, TE compiler now makes sure the function name is unique when it appears multiple times in a model. This breaks the current task extraction mechanism, which uses function name and TE compute hash as the key to de-duplicate tasks. As a result, the same task will be extracted multiple times, and all tasks have the weight 1.
This PR makes the following changes to resolve this issue:
wkl_key_to_weight
fromDict[str, int]
toDict[str, Tuple[int, Set[Str]]]
, mapping from a workload key to the weight as well as associated function names. In this way, we guarantee that functions with the same TE compute will be extracted once.func_name_to_wkl_key
, mapping from the unique function name to its workload key. When TE compiler is used andte_compiler_update_weights
is invoked, it obtains the workload key of the given function and aggregate the weights.cc @masahi @csullivan @jroesch @merrymercy