Skip to content

Commit c7d12c1

Browse files
masnesralfacebook-github-bot
authored andcommitted
Suppress csv creation on cold-start phase of --warm-start-latency (#125953)
Summary: It seems that most (all?) of our utilities for examining benchmark output expect single-line entries per benchmark. The way the --warm-start-latency flag is currently implemented, it means that we'll see two entries for every benchmark run (one for the warm-up run and one for the actual run). This PR adds a --disable-output flag that we can use for the first run to suppress populating the csv. This way, the existing utilities like `benchmarks/dynamo/check_accuracy.py` will function without any changes. X-link: pytorch/pytorch#125953 Approved by: https://github.com/desertfire ghstack dependencies: #125917 Reviewed By: huydhn Differential Revision: D57421488 Pulled By: masnesral fbshipit-source-id: 02c6e7500fbddcb7eb474e2170c3a3ae5f369487
1 parent 5ad98c6 commit c7d12c1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

userbenchmark/dynamo/dynamobench/common.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
current_onnx_compiler = ""
109109
current_batch_size = None
110110
output_filename = None
111+
disable_output = False
111112

112113
MAX_DOWNLOAD_ATTEMPTS = 5
113114

@@ -306,6 +307,9 @@ def load_model_from_path(path_and_class_str):
306307

307308

308309
def output_csv(filename, headers, row):
310+
global disable_output
311+
if disable_output:
312+
return
309313
if os.path.exists(filename):
310314
with open(filename) as fd:
311315
lines = list(csv.reader(fd)) or [[]]
@@ -3212,6 +3216,11 @@ def get_example_inputs(self):
32123216
"--output-directory",
32133217
help="Overrides the directory to place output files.",
32143218
)
3219+
parser.add_argument(
3220+
"--disable-output",
3221+
action="store_true",
3222+
help="Disable writing of output files, e.g., for warm-up runs",
3223+
)
32153224
parser.add_argument(
32163225
"--baseline",
32173226
help="Compare with a prior --output",
@@ -3612,7 +3621,8 @@ def main(runner, original_dir=None, args=None):
36123621
cmd.remove("--warm-start-latency")
36133622

36143623
print(f"Performing cold-start run for {args.only}")
3615-
subprocess.check_call(cmd + ["--repeat=1"], timeout=args.timeout, env=env)
3624+
warmup_cmd = cmd + ["--repeat=1", "--disable-output"]
3625+
subprocess.check_call(warmup_cmd, timeout=args.timeout, env=env)
36163626

36173627
print(f"Performing warm-start run for {args.only}")
36183628
subprocess.check_call(cmd, timeout=args.timeout, env=env)
@@ -3821,9 +3831,12 @@ def run(runner, args, original_dir=None):
38213831
runner.skip_models.clear()
38223832

38233833
experiment = null_experiment
3824-
global current_name, current_device, current_batch_size, output_filename, optimize_ctx, current_onnx_compiler
3834+
global current_name, current_device, current_batch_size, output_filename, disable_output, optimize_ctx, current_onnx_compiler
38253835
optimize_ctx = contextlib.nullcontext()
38263836

3837+
if args.disable_output:
3838+
disable_output = True
3839+
38273840
if args.overhead:
38283841
optimize_ctx = torch._dynamo.optimize(dummy_fx_compile, nopython=args.nopython)
38293842
experiment = speedup_experiment

0 commit comments

Comments
 (0)