diff --git a/third_party/xla/xla/backends/autotuner/autotuner.cc b/third_party/xla/xla/backends/autotuner/autotuner.cc index 554895ab1a1..2f950b590aa 100644 --- a/third_party/xla/xla/backends/autotuner/autotuner.cc +++ b/third_party/xla/xla/backends/autotuner/autotuner.cc @@ -499,6 +499,7 @@ absl::StatusOr> Autotuner::ProfileAll( std::optional reference_output; if (autotune_config_.check_buffers) { + VLOG(2) << "Checking buffers"; reference_output = GetReferenceOutput(candidates, *input_buffers); if (!reference_output.has_value()) { LOG(WARNING) << "No reference output found even though buffer checking " @@ -605,6 +606,8 @@ std::optional Autotuner::GetReferenceOutput( continue; } if (profile_result.value().output_buffer.has_value()) { + VLOG(2) << "Found reference output for config: " + << candidate.config.ToString(); return std::move(profile_result.value().output_buffer.value()); } } @@ -732,4 +735,28 @@ std::string Autotuner::Config::ToString() const { UnpackedAnyShortDebugString(*backend_config)); } +std::string AutotuneConfig::ToString() const { + return absl::StrFormat( + "{\n" + " \"check_buffers\": %s,\n" + " \"relative_tolerance\": %f,\n" + " \"crash_on_check_failure\": %s,\n" + " \"optimize_scratch_bytes\": %s,\n" + " \"scratch_bytes_window_size_us\": %d,\n" + " \"expect_all_instructions_in_cache\": %s,\n" + " \"dump_logs_to\": \"%s\",\n" + " \"exclude_cublas_config\": %s,\n" + " \"select_first_config\": %s,\n" + " \"use_default_config\": %s,\n" + " \"dump_hlos\": %s\n" + "}", + check_buffers ? "true" : "false", relative_tolerance, + crash_on_check_failure ? "true" : "false", + optimize_scratch_bytes ? "true" : "false", scratch_bytes_window_size_us, + expect_all_instructions_in_cache ? "true" : "false", dump_logs_to, + exclude_cublas_config ? "true" : "false", + select_first_config ? "true" : "false", + use_default_config ? "true" : "false", dump_hlos ? "true" : "false"); +} + } // namespace xla diff --git a/third_party/xla/xla/backends/autotuner/autotuner.h b/third_party/xla/xla/backends/autotuner/autotuner.h index eb15e516070..bec84c70609 100644 --- a/third_party/xla/xla/backends/autotuner/autotuner.h +++ b/third_party/xla/xla/backends/autotuner/autotuner.h @@ -87,6 +87,8 @@ struct AutotuneConfig { // If true, dump the autotuned instructions to the modules's xla_dump_to or // to stdout if not set. bool dump_hlos = false; + + std::string ToString() const; }; class Autotuner { diff --git a/third_party/xla/xla/backends/autotuner/autotuner_test.cc b/third_party/xla/xla/backends/autotuner/autotuner_test.cc index 449d837c233..1ea8b49cff2 100644 --- a/third_party/xla/xla/backends/autotuner/autotuner_test.cc +++ b/third_party/xla/xla/backends/autotuner/autotuner_test.cc @@ -986,5 +986,36 @@ TEST_F(AutotunerTest, DumpHlos) { MatchesRegex(".*\\.test_module\\.autotuner_1\\.add\\.before\\.txt"))); } +TEST(AutotuneConfigTest, ToString) { + AutotuneConfig config; + config.check_buffers = true; + config.relative_tolerance = 1e-4; + config.crash_on_check_failure = false; + config.optimize_scratch_bytes = true; + config.scratch_bytes_window_size_us = 10; + config.expect_all_instructions_in_cache = false; + config.dump_logs_to = "/tmp/log"; + config.exclude_cublas_config = true; + config.select_first_config = false; + config.use_default_config = true; + config.dump_hlos = false; + + std::string expected = + "{\n" + " \"check_buffers\": true,\n" + " \"relative_tolerance\": 0.000100,\n" + " \"crash_on_check_failure\": false,\n" + " \"optimize_scratch_bytes\": true,\n" + " \"scratch_bytes_window_size_us\": 10,\n" + " \"expect_all_instructions_in_cache\": false,\n" + " \"dump_logs_to\": \"/tmp/log\",\n" + " \"exclude_cublas_config\": true,\n" + " \"select_first_config\": false,\n" + " \"use_default_config\": true,\n" + " \"dump_hlos\": false\n" + "}"; + EXPECT_EQ(config.ToString(), expected); +} + } // namespace } // namespace xla diff --git a/third_party/xla/xla/service/gpu/autotuning/autotuner_pass.cc b/third_party/xla/xla/service/gpu/autotuning/autotuner_pass.cc index d053517780f..630899b170c 100644 --- a/third_party/xla/xla/service/gpu/autotuning/autotuner_pass.cc +++ b/third_party/xla/xla/service/gpu/autotuning/autotuner_pass.cc @@ -103,6 +103,7 @@ absl::StatusOr> AutotunerPass::Create( bool is_deviceless = stream_executor == nullptr; AutotuneConfig autotune_config = GetAutotuneConfig(debug_options, is_deviceless, optimize_scratch_bytes); + VLOG(1) << "Autotune config: " << autotune_config.ToString(); if (!is_deviceless) { profiler = GpuProfiler::Create(