Skip to content

Commit c11de4f

Browse files
committed
fixes to smoke_test_timeout
- subprocess bug: check must be False to capture nonzero retcode. - METRIC key not inside best_result if timeout prematurely called before trial completes (true for smoke test) Signed-off-by: Jack Luar <[email protected]>
1 parent c0bf0bb commit c11de4f

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ def save_best(results):
627627
Save best configuration of parameters found.
628628
"""
629629
best_config = results.best_config
630+
if METRIC not in results.best_result:
631+
print("[ERROR TUN-0023] Metric not found in results.")
632+
sys.exit(1)
630633
best_config["best_result"] = results.best_result[METRIC]
631634
trial_id = results.best_trial.trial_id
632635
new_best_path = f"{LOCAL_DIR}/{args.experiment}/"

tools/AutoTuner/test/smoke_test_timeout.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ def setUp(self):
2020

2121
# 0.001 hour translates to 3.6 seconds, which will definitely cause failure.
2222
timeout_flags = ["--timeout 0.001", "--timeout_per_trial 0.001"]
23-
self.timeout_limit = 15 # 15 second upper limit
23+
self.timeout_limit = 60 # 60 second upper limit (Ray needs time to shutdown)
2424
self.commands = [
2525
"python3 distributed.py"
2626
f" --design {self.design}"
2727
f" --platform {self.platform}"
2828
f" --experiment {self.experiment}"
2929
f" --config {self.config}"
30-
f" --cpu_budget 1"
3130
f" --yes"
3231
f" {flag}"
3332
f" tune --samples 1"
@@ -47,10 +46,10 @@ class asap7TimeoutSmokeTest(BaseTimeoutSmokeTest):
4746
def test_timeout(self):
4847
for command in self.commands:
4948
out = subprocess.run(
50-
command, shell=True, check=True, timeout=self.timeout_limit
49+
command, shell=True, check=False, timeout=self.timeout_limit
5150
)
52-
successful = out.returncode == 0
53-
self.assertTrue(successful)
51+
failed = out.returncode == 1
52+
self.assertTrue(failed)
5453

5554

5655
class sky130hdTimeoutSmokeTest(BaseTimeoutSmokeTest):
@@ -60,10 +59,10 @@ class sky130hdTimeoutSmokeTest(BaseTimeoutSmokeTest):
6059
def test_timeout(self):
6160
for command in self.commands:
6261
out = subprocess.run(
63-
command, shell=True, check=True, timeout=self.timeout_limit
62+
command, shell=True, check=False, timeout=self.timeout_limit
6463
)
65-
successful = out.returncode == 0
66-
self.assertTrue(successful)
64+
failed = out.returncode == 1
65+
self.assertTrue(failed)
6766

6867

6968
class ihpsg13g2TimeoutSmokeTest(BaseTimeoutSmokeTest):
@@ -73,10 +72,10 @@ class ihpsg13g2TimeoutSmokeTest(BaseTimeoutSmokeTest):
7372
def test_timeout(self):
7473
for command in self.commands:
7574
out = subprocess.run(
76-
command, shell=True, check=True, timeout=self.timeout_limit
75+
command, shell=True, check=False, timeout=self.timeout_limit
7776
)
78-
successful = out.returncode == 0
79-
self.assertTrue(successful)
77+
failed = out.returncode == 1
78+
self.assertTrue(failed)
8079

8180

8281
if __name__ == "__main__":

0 commit comments

Comments
 (0)