pytorch/feature: Record if parallel compile is enabled (#141074)

This gets a bit messy, but this appears to be the best spot to make a
true / false decision.

Note that since we're looking at whether or not it's used, if the pool
doesn't warm up within the time it takes for a compile, we will mark the
feature use as false.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/141074
Approved by: https://github.com/masnesral
ghstack dependencies: #141059
This commit is contained in:
Colin L. Rice 2024-11-22 16:28:57 -07:00 committed by PyTorch MergeBot
parent 00134d68af
commit 0989871ac9

View file

@ -14,7 +14,7 @@ from typing import Any, Callable, Dict, List, Optional, Set, TYPE_CHECKING
import torch
from torch._dynamo.device_interface import get_registered_device_interfaces
from torch._dynamo.utils import dynamo_timed
from torch._dynamo.utils import dynamo_timed, set_feature_use
from torch._inductor import config
from torch._inductor.codecache import (
CodeCacheFuture,
@ -219,6 +219,9 @@ class AsyncCompile:
kernel = TritonCodeCache.load(kernel_name, source_code)
if self._use_process_pool():
set_feature_use(
"pytorch/inductor:enable_parallel_compile_version (post_warmup)", True
)
# We want to support changing these env vars after (and while) the
# process pool is running, so pass them to the subprocess to reset.
env_vars = ["TORCHINDUCTOR_CACHE_DIR", "TRITON_CACHE_DIR"]
@ -232,6 +235,9 @@ class AsyncCompile:
),
)
else:
set_feature_use(
"pytorch/inductor:enable_parallel_compile_version (post_warmup)", False
)
kernel.precompile()
return kernel