From 90cdb7138333673f74d19e80cdf7f55c9ff34923 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Wed, 31 Jul 2024 17:36:31 -0500 Subject: [PATCH] Compute power only in start - stop window --- .../result_summarizer/result_summarizer.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/mlperf_logging/result_summarizer/result_summarizer.py b/mlperf_logging/result_summarizer/result_summarizer.py index 42161cc..089e6b6 100644 --- a/mlperf_logging/result_summarizer/result_summarizer.py +++ b/mlperf_logging/result_summarizer/result_summarizer.py @@ -521,23 +521,35 @@ def _compute_power_node(loglines, time_to_train): power_stop = 0 agg_power = 0 conversion_eff = 1.0 + power_stop_found = False + power_start_found = False + loglines.sort(key=lambda x: x.timestamp) for logline in loglines: if logline.key == "power_measurement_start": power_start = logline.timestamp prev_timestamp = logline.timestamp - if logline.key == "power_reading": - agg_power += (logline.value['value'] * (logline.timestamp - prev_timestamp)) + power_start_found = True + if ( + (logline.key == "power_reading") + and (not power_stop_found) + and (power_start_found) + ): + agg_power += logline.value["value"] * (logline.timestamp - prev_timestamp) prev_timestamp = logline.timestamp max_timestamp = max(max_timestamp, logline.timestamp) if logline.key == "power_measurement_stop": power_stop = logline.timestamp - break + power_stop_found = True if logline.key == "conversion_eff": - conversion_eff = logline.value['value'] - + conversion_eff = logline.value["value"] + + # If power stop is not found, set it to the latest power reading + if not power_stop_found: + power_stop = max_timestamp # Compute the result, convert ms to s - power_stop = max(power_stop, max_timestamp) - result = conversion_eff * agg_power * time_to_train / (power_stop - power_start) / 1000 + result = ( + conversion_eff * agg_power * time_to_train / (power_stop - power_start) / 1000 + ) return result