Skip to content

Commit c0c5d69

Browse files
committed
reintroduce args.jobs, and recalculate timeouts accordingly
Signed-off-by: Jack Luar <[email protected]>
1 parent a5bb16f commit c0c5d69

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,13 @@ def parse_arguments():
446446
default=int(np.floor(cpu_count() / 2)),
447447
help="CPU Hours",
448448
)
449+
parser.add_argument(
450+
"--jobs",
451+
type=int,
452+
metavar="<int>",
453+
default=int(np.floor(cpu_count() / 2)),
454+
help="Max number of concurrent jobs.",
455+
)
449456
parser.add_argument(
450457
"--openroad_threads",
451458
type=int,
@@ -510,14 +517,17 @@ def parse_arguments():
510517
if args.timeout is not None:
511518
args.timeout = round(args.timeout * 3600)
512519

513-
# Calculate jobs
514-
jobs = int(args.cpu_budget / args.resources_per_trial)
515-
args.jobs = jobs
516-
517520
# Calculate timeout based on cpu_budget
518521
if args.cpu_budget is not None:
519522
args.timeout = round(args.cpu_budget / os.cpu_count() * 3600)
520-
template = calculate_expected_numbers(args.timeout, args.samples)
523+
args.timeout_per_trial = round(
524+
args.cpu_budget / (args.jobs * args.resources_per_trial) * 3600
525+
)
526+
overall_timeout = min(args.timeout, args.timeout_per_trial)
527+
if args.mode == "tune":
528+
template = calculate_expected_numbers(overall_timeout, args.samples)
529+
else:
530+
template = calculate_expected_numbers(overall_timeout, 1)
521531
print(template)
522532
if not args.yes:
523533
ans = input("Are you sure you want to proceed? (y/n): ")

tools/AutoTuner/test/smoke_test_sweep.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def setUp(self):
2929
# limit jobs because ray.get() does not terminate if jobs > number of samples
3030
core = os.cpu_count()
3131
self.resources_per_trial = 1
32-
self.cpu_budget = 4 if core >= 4 else core
32+
self.jobs = 4
33+
self.cpu_budget = 1 # test should terminate in 1/(4*1) = 0.25 hours
3334
self.experiment = f"smoke-test-sweep-{self.platform}"
3435
self.command = (
3536
"python3 -m autotuner.distributed"
@@ -38,6 +39,7 @@ def setUp(self):
3839
f" --experiment {self.experiment}"
3940
f" --config {self.config}"
4041
f" --cpu_budget {self.cpu_budget}"
42+
f" --jobs {self.jobs}"
4143
f" --yes"
4244
f" sweep --resources_per_trial {self.resources_per_trial}"
4345
)

0 commit comments

Comments
 (0)