Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoScheduler] Fix task extraction with TE compiler #8560

Merged
merged 4 commits into from
Jul 29, 2021

Conversation

comaniac
Copy link
Contributor

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:

  1. Change the type of wkl_key_to_weight from Dict[str, int] to Dict[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.
  2. Add func_name_to_wkl_key, mapping from the unique function name to its workload key. When TE compiler is used and te_compiler_update_weights is invoked, it obtains the workload key of the given function and aggregate the weights.
  3. Refactor unit tests to be pytest parameterized. Also improve the control flow test to have 2 identical Conv2Ds. Without this PR, this test will fail because it falls back to use VM compiler due to the control flow and extracts 2 identical tasks.

cc @masahi @csullivan @jroesch @merrymercy

@comaniac comaniac changed the title Ansor fix task ext [AutoScheduler] Fix task extraction with TE compiler Jul 26, 2021
Copy link
Contributor

@jcf94 jcf94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @comaniac

@jcf94 jcf94 merged commit 74715f4 into apache:main Jul 29, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Sep 29, 2021
* [AutoScheduler] Fix task extraction with TE compiler

* fix

* test

* Update python/tvm/auto_scheduler/relay_integration.py
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* [AutoScheduler] Fix task extraction with TE compiler

* fix

* test

* Update python/tvm/auto_scheduler/relay_integration.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants