Skip to content

Commit bcf46c7

Browse files
authored
Warn when using persistent cache with debug env vars (#7175)
1 parent 94fa999 commit bcf46c7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

torch_xla/csrc/runtime/env_hash.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ torch::lazy::hash_t HashXlaEnvVars() {
9393
// Both XLA_FLAGS and LIBTPU_INIT_ARGS contain XLA flags which impact
9494
// the compilation result.
9595
static std::vector<std::string> flag_vars = {"XLA_FLAGS", "LIBTPU_INIT_ARGS"};
96-
static std::vector<std::string> raw_vars = {"TPU_MEGACORE"};
96+
static std::vector<std::string> raw_vars = {"TPU_MEGACORE", "XLA_HLO_DEBUG",
97+
"XLA_IR_DEBUG"};
9798
return hash_xla_env_vars(flag_vars, raw_vars);
9899
}
99100

torch_xla/csrc/xla_graph_executor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ XLAGraphExecutor::ComputationCache* CreateComputationCache() {
100100
return std::make_shared<XLAGraphExecutor::CachedComputation>(
101101
computation, /*is_sharded=*/UseVirtualDevice());
102102
};
103+
if (runtime::sys_util::GetEnvBool("XLA_HLO_DEBUG", false) ||
104+
runtime::sys_util::GetEnvBool("XLA_IR_DEBUG", false)) {
105+
TF_LOG(WARNING)
106+
<< "Using persistent compilation cache with XLA_HLO_DEBUG=1 "
107+
"or XLA_IR_DEBUG=1 is not recommended. Changes to the HLO "
108+
"metadata will not be reflected in loaded executables.";
109+
}
103110
return new XLAGraphExecutor::PersistentCache(
104111
kMaxCacheSize, persistentCacheDir, readonlyPersistentCache,
105112
serialize_fn, deserialize_fn);

0 commit comments

Comments
 (0)