[Bugfix] Flush TunableOp results before worker processes are destroyed. (#13623)

Signed-off-by: Nichols A. Romero <nick.romero@amd.com>
This commit is contained in:
Nichols A. Romero 2025-02-25 05:08:20 -06:00 committed by GitHub
parent 75e9d49796
commit fa82074167
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -250,6 +250,15 @@ def _run_worker_process(
except Exception:
logger.exception("Worker failed")
# Flush TunableOp results when TunableOp is enabled and
# online (in situ) tuning is enabled.
# Offline tuning API (record_untuned_is_enabled()) only
# available in PyTorch 2.6 or later.
import torch.cuda.tunable as tunable
if (tunable.is_enabled() and tunable.tuning_is_enabled()
and not tunable.record_untuned_is_enabled()):
tunable.write_file()
logger.info("Worker exiting")