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] Propogate global autotvm state to PopenPool workers #8913

Merged
merged 3 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/tvm/auto_scheduler/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from tvm.driver import build_module
from tvm.ir import transform
from tvm.autotvm.measure.measure_methods import set_cuda_target_arch
from tvm.autotvm.env import AutotvmGlobalScope, reset_global_scope
from tvm.contrib import tar, ndk
from tvm.contrib.popen_pool import PopenWorker, PopenPoolExecutor, StatusKind
from tvm.target import Target
Expand Down Expand Up @@ -692,7 +693,9 @@ def local_builder_build(inputs, timeout, n_parallel, build_func="default", verbo
res : List[BuildResult]
The build results of these MeasureInputs.
"""
executor = PopenPoolExecutor(n_parallel, timeout)
executor = PopenPoolExecutor(
n_parallel, timeout, reset_global_scope, (AutotvmGlobalScope.current,)
)
tuple_res = executor.map_with_error_catching(
local_build_worker,
[
Expand Down
7 changes: 7 additions & 0 deletions python/tvm/autotvm/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ def __init__(self):


GLOBAL_SCOPE = AutotvmGlobalScope()


def reset_global_scope(global_scope):
"""Reset global autotvm state. This is needed to initialize PopenPool workers."""
global GLOBAL_SCOPE
GLOBAL_SCOPE = global_scope
AutotvmGlobalScope.current = global_scope