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

Add python bindings for xla_gpu_experimental_autotune_cache_mode #18450

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions xla/python/xla_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3378,6 +3378,8 @@ def testCompileOptionsSerialization(self):
deb_opt.xla_gpu_kernel_cache_file = "/foo/bar"
deb_opt.xla_gpu_enable_llvm_module_compilation_parallelism = True
deb_opt.xla_gpu_per_fusion_autotune_cache_dir = "/bar/foo/"
deb_opt.xla_gpu_experimental_autotune_cache_mode = AutotuneCacheMode.READ


b = options.SerializeAsString()
restored = xla_client.CompileOptions.ParseFromString(b)
Expand All @@ -3398,6 +3400,7 @@ def testCompileOptionsSerialization(self):
"xla_gpu_kernel_cache_file",
"xla_gpu_enable_llvm_module_compilation_parallelism",
"xla_gpu_per_fusion_autotune_cache_dir",
"xla_gpu_experimental_autotune_cache_mode",
):
self.assertEqual(
getattr(options.executable_build_options.debug_options, name),
Expand Down
10 changes: 9 additions & 1 deletion xla/python/xla_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,11 @@ void BuildXlaCompilerSubmodule(nb::module_& m) {
},
nb::arg("platform"));

nb::enum_<DebugOptions::AutotuneCacheMode>(m, "AutotuneCacheMode")
.value("UNSPECIFIED", DebugOptions::AUTOTUNE_CACHE_MODE_UNSPECIFIED)
.value("UPDATE", DebugOptions::AUTOTUNE_CACHE_MODE_UPDATE)
.value("READ", DebugOptions::AUTOTUNE_CACHE_MODE_READ);

nb::class_<DebugOptions>(m, "DebugOptions")
.def("__repr__", &DebugOptions::DebugString)
.def_prop_rw("xla_backend_optimization_level",
Expand Down Expand Up @@ -1239,7 +1244,10 @@ void BuildXlaCompilerSubmodule(nb::module_& m) {
&DebugOptions::xla_gpu_per_fusion_autotune_cache_dir,
[](DebugOptions* self, std::string value) {
self->set_xla_gpu_per_fusion_autotune_cache_dir(value);
});
})
.def_prop_rw("xla_gpu_experimental_autotune_cache_mode",
&DebugOptions::xla_gpu_experimental_autotune_cache_mode,
&DebugOptions::set_xla_gpu_experimental_autotune_cache_mode);

nb::class_<ExecutableBuildOptions>(m, "ExecutableBuildOptions")
.def(nb::init<>())
Expand Down
6 changes: 6 additions & 0 deletions xla/python/xla_extension/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ def register_custom_call_partitioner(
) -> None: ...
def encode_inspect_sharding_callback(handler: Any) -> bytes: ...

class AutotuneCacheMode(enum.IntEnum):
UNSPECIFIED: AutotuneCacheMode
UPDATE: AutotuneCacheMode
READ: AutotuneCacheMode

class DebugOptions:
def __repr__(self) -> str: ...
xla_cpu_enable_fast_math: bool
Expand Down Expand Up @@ -322,6 +327,7 @@ class DebugOptions:
xla_gpu_kernel_cache_file: str
xla_gpu_enable_llvm_module_compilation_parallelism: bool
xla_gpu_per_fusion_autotune_cache_dir: str
xla_gpu_experimental_autotune_cache_mode: AutotuneCacheMode

class CompiledMemoryStats:
generated_code_size_in_bytes: int
Expand Down
Loading