Skip to content

Commit a02c97e

Browse files
[Core] Tying wandb CLI Args in Capacity Search (#6)
* wandb CLI args for capacity search * benchmark config bug fix * benchmark config bug fix * make format * Adding "no-"" to bool CLI args
1 parent c009611 commit a02c97e

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

metron/capacity_search/capacity_search.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,10 @@ def is_under_sla(self, qps: float) -> Tuple[bool, float, float, float, float, st
241241
),
242242
qps=qps,
243243
tbt_deadline=self.args.tbt_slo,
244-
wandb_project="Metron",
245-
wandb_group="gatech-sysml",
246-
wandb_run_name=f"qps_{qps}_model_{self.job_config.model_config.name}_ttftslack_{self.args.ttft_slack_slo}_tbt_{self.args.tbt_slo}_tpot_{self.args.tpot_slo}_ttft_{self.args.ttft_slo}_trace_{self.job_config.request_generator_config.trace_file_name}",
244+
wandb_project=self.args.wandb_project,
245+
wandb_group=self.args.wandb_group,
246+
wandb_run_name=f"qps_{qps}_model_{self.job_config.model_config.name}_engine_{self.job_config.server_config.openai_server_engine}",
247+
should_write_metrics=self.args.should_write_metrics_to_wandb,
247248
)
248249

249250
run_dir = benchmark_config.get_run_dir()
@@ -347,7 +348,7 @@ def search(self):
347348
f"Best Run ID: {best_run_id}",
348349
)
349350

350-
if self.args.wandb_project is not None:
351+
if self.args.wandb_project is not None and self.args.enable_wandb_sweep:
351352
best_run = wandb.Api().run(f"{self.args.wandb_project}/{best_run_id}")
352353
best_run.tags.append("BEST_CONFIG")
353354
best_run.update()

metron/capacity_search/config/config.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ class BenchmarkConfig:
354354
wandb_group: Optional[str] = None
355355
wandb_project: Optional[str] = None
356356
wandb_run_name: Optional[str] = None
357+
should_write_metrics: Optional[bool] = True
357358

358359
def to_config_dict(self):
359360
return {
@@ -366,14 +367,21 @@ def to_config_dict(self):
366367
"wandb-group": self.wandb_group,
367368
"wandb-project": self.wandb_project,
368369
"wandb-run-name": self.wandb_run_name,
370+
"should-write-metrics": self.should_write_metrics,
369371
}
370372

371373
def to_args(self):
372374
config_dict = self.to_config_dict()
373375
args = []
374376
for key, value in config_dict.items():
375377
if value is not None:
376-
args.append(f"--{key} {value}")
378+
if isinstance(value, bool):
379+
if value:
380+
args.append(f"--{key}")
381+
else:
382+
args.append(f"--no-{key}")
383+
else:
384+
args.append(f"--{key} {value}")
377385
return " ".join(args)
378386

379387
def get_run_id(self):

metron/capacity_search/main.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,25 @@ def get_args():
4949
"--debug", action="store_true", help="Print debug logs and commands"
5050
)
5151
parser.add_argument("--wandb-project", type=str, default=None)
52+
parser.add_argument("--wandb-group", type=str, default=None)
53+
parser.add_argument(
54+
"--should-write-metrics-to-wandb",
55+
type=bool,
56+
action=argparse.BooleanOptionalAction,
57+
default=False,
58+
)
5259
parser.add_argument("--wandb-sweep-name", type=str, default=None)
5360
parser.add_argument("--wandb-sweep-id", type=str, default=None)
61+
parser.add_argument(
62+
"--enable-wandb-sweep",
63+
type=bool,
64+
action=argparse.BooleanOptionalAction,
65+
default=False,
66+
)
5467

5568
args = parser.parse_args()
5669

57-
if args.wandb_project:
70+
if args.wandb_project and args.enable_wandb_sweep:
5871
assert (
5972
args.wandb_sweep_name or args.wandb_sweep_id
6073
), "wandb-sweep-name/id is required with wandb-project"
@@ -80,7 +93,7 @@ def get_args():
8093
# store the config and args
8194
json.dump(config, open(f"{args.output_dir}/config.json", "w"))
8295

83-
if args.wandb_project and not args.wandb_sweep_id:
96+
if args.wandb_project and args.enable_wandb_sweep and not args.wandb_sweep_id:
8497
config["name"] = args.wandb_sweep_name
8598
config["method"] = "custom"
8699

metron/run_benchmark.py

+1
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ def parse_args():
530530
"--should-use-given-dir", # added to prevent the creation of a new directories for the capacity search
531531
type=bool,
532532
default=True,
533+
action=argparse.BooleanOptionalAction,
533534
help=(
534535
"Whether to add directly use --output-dir directory or create new directories for the results. (default: %(default)s)"
535536
),

0 commit comments

Comments
 (0)