Skip to content

Commit 4bec11d

Browse files
authored
Merge pull request #322 from GATEOverflow/master
Merge the power checker changes from the inference repository Approved per PowerWG 11/28
2 parents fb56813 + 05e4ef2 commit 4bec11d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

compliance/check.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# =============================================================================
1616

1717
from collections import OrderedDict
18-
from datetime import datetime, timezone
18+
from datetime import datetime, timezone, timedelta
1919
from typing import Dict, List, Tuple, Any, Optional, Callable
2020
import argparse
2121
import hashlib
@@ -84,7 +84,7 @@ class CheckerWarning(Exception):
8484
re.compile(r"Uncertainty \d+.\d+%, which is above 1.00% limit for the last sample!")
8585
]
8686

87-
TIME_DELTA_TOLERANCE = 500 # in milliseconds
87+
TIME_DELTA_TOLERANCE = 800 # in milliseconds
8888

8989

9090
def _normalize(path: str) -> str:
@@ -395,6 +395,10 @@ def get_avg_power(power_path: str, run_path: str) -> Tuple[float, float]:
395395
os.path.join(path, os.path.basename(run_path)), client_sd
396396
)
397397

398+
# convert to UTC
399+
power_begin = datetime.fromtimestamp(power_begin, tz=timezone.utc)
400+
power_end = datetime.fromtimestamp(power_end, tz=timezone.utc)
401+
398402
detail_log_fname = os.path.join(run_path, "mlperf_log_detail.txt")
399403
datetime_format = "%m-%d-%Y %H:%M:%S.%f"
400404

@@ -406,7 +410,7 @@ def get_avg_power(power_path: str, run_path: str) -> Tuple[float, float]:
406410
for line in f:
407411
timestamp = (
408412
datetime.strptime(line.split(",")[1], datetime_format)
409-
).timestamp()
413+
).replace(tzinfo=timezone.utc)
410414
if timestamp > power_begin and timestamp < power_end:
411415
cpower = float(line.split(",")[3])
412416
cpf = float(line.split(",")[9])
@@ -596,13 +600,13 @@ def find_error_or_warning(reg_exp: str, line: str, error: bool) -> None:
596600
problem_line = re.search(reg_exp, line)
597601

598602
if problem_line and problem_line.group(0):
599-
log_time = get_time_from_line(line, date_regexp, file_path, timezone_offset)
603+
log_time = get_time_from_line(line, date_regexp, file_path, 0)
600604
if start_ranging_time is None or stop_ranging_time is None:
601605
assert False, "Can not find ranging time in ptd_logs.txt."
602606
if error:
603607
if problem_line.group(0).strip() in COMMON_ERROR_TESTING:
604608
raise CheckerWarning(
605-
f"{line.strip()!r} in ptd_log.txt during testing stage but it is accepted. Treated as WARNING"
609+
f"{line.strip().replace('ERROR', 'Warning')!r} in ptd_log.txt during testing stage but it is accepted. Treated as WARNING"
606610
)
607611
assert (
608612
start_ranging_time < log_time < stop_ranging_time
@@ -614,7 +618,7 @@ def find_error_or_warning(reg_exp: str, line: str, error: bool) -> None:
614618
for common_ranging_error in COMMON_ERROR_RANGING
615619
):
616620
raise CheckerWarning(
617-
f"{line.strip()!r} in ptd_log.txt during ranging stage. Treated as WARNING"
621+
f"{line.strip().replace('ERROR', 'Warning')!r} in ptd_log.txt during ranging stage. Treated as WARNING"
618622
)
619623
else:
620624
if (
@@ -653,12 +657,12 @@ def get_msg_without_time(line: str) -> Optional[str]:
653657
continue
654658
if (not start_ranging_time) and (start_ranging_line == msg):
655659
start_ranging_time = get_time_from_line(
656-
line, date_regexp, file_path, timezone_offset
660+
line, date_regexp, file_path, 0 # timezone_offset
657661
)
658662
if (not stop_ranging_time) and bool(start_ranging_time):
659663
if ": Completed test" == msg:
660664
stop_ranging_time = get_time_from_line(
661-
line, date_regexp, file_path, timezone_offset
665+
line, date_regexp, file_path, 0 # timezone_offset
662666
)
663667
break
664668

@@ -673,7 +677,7 @@ def get_msg_without_time(line: str) -> Optional[str]:
673677
try:
674678
log_time = None
675679
log_time = get_time_from_line(
676-
line, date_regexp, file_path, timezone_offset
680+
line, date_regexp, file_path, 0 # timezone_offset
677681
)
678682
except LineWithoutTimeStamp:
679683
assert (

0 commit comments

Comments
 (0)