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 the conflict of thread pool in measurement #7166

Merged
merged 1 commit into from
Dec 25, 2020

Conversation

merrymercy
Copy link
Member

@merrymercy merrymercy commented Dec 25, 2020

Currently, due to the conflict between python' multiprocessing and tvm's thread pool, we cannot run auto-scheduler search after running any tvm-generated functions.

I found this conflict can be avoided if we run the measurement function in LocalRunner within a new threading.Thread.
This PR just added such a new wrapper in auto_scheduler.local_runner.run. With this PR, we can freely run auto-scheduler search after executing any tvm-generated functions or relay's FoldConstant.

@merrymercy merrymercy force-pushed the pr-fix-measure branch 2 times, most recently from 2070e6b to ad639bb Compare December 25, 2020 05:48
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.

LGTM.

"""Call a function with timeout"""
que = multiprocessing.Queue(2)
process = multiprocessing.Process(target=_func_wrapper, args=(que, func, args, kwargs))
process = multiprocessing.Process(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking about whether the bug was introduced by the multiprocessing? Maybe directly use thread here can solve the problem.... I'm not sure, just a guess.

Copy link
Member Author

@merrymercy merrymercy Dec 25, 2020

Choose a reason for hiding this comment

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

We can only use Process here. threading.Thread does not support timeout when calling a c++ function.

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM

@comaniac comaniac merged commit 3d8fd2a into apache:main Dec 25, 2020
@comaniac
Copy link
Contributor

Thanks @merrymercy @jcf94

@merrymercy merrymercy deleted the pr-fix-measure branch December 25, 2020 09:14
tkonolige pushed a commit to tkonolige/incubator-tvm that referenced this pull request Jan 11, 2021
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants