openxla / xla

A machine learning compiler for GPUs, CPUs, and ML accelerators
Apache License 2.0
2.64k stars 418 forks source link

[NFC] debug_options: Make all singular scalar fields explicitly optional. #14866

Open copybara-service[bot] opened 3 months ago

copybara-service[bot] commented 3 months ago

[NFC] debug_options: Make all singular scalar fields explicitly optional.

By default in proto3, there is no way to tell the difference between when a non-repeated (singular) non-message (scalar) field that is not set and when that field has been explicitly set to its default value. Normally this is not a problem for DebugOptions, as XLA_FLAGS simply translates default values as expected. However, when replaying compilation of modules with saved HloModuleConfigs, user XLA_FLAGS values should always take precedence, which means we need to know the difference. Concrete use cases include setting xla_dump_to to "", which is the supported way to disable dumping, as the saved compilation may have set it to an arbitrary directory and thus replaying to it would risk permissions errors or overwriting user data, and disabling GPU autotuning by setting --xla_gpu_autotune_level to 0.

This property is enforced by a unit test. In an ideal world only fields that directly correspond to XLA_FLAGS would have the enforcement, but tsl::Flag doesn't expose accessors so we simply enforce it for all fields.