Add missing newline to repro and some utility thing in repro (#121051)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/121051
Approved by: https://github.com/ezyang, https://github.com/shunting314, https://github.com/eellison
This commit is contained in:
chilli 2024-03-02 12:41:55 -08:00 committed by PyTorch MergeBot
parent eba28a6f91
commit 83c312990f

View File

@ -274,7 +274,7 @@ def save_graph_repro(
fd.write("if __name__ == '__main__':\n") fd.write("if __name__ == '__main__':\n")
fd.write(" from torch._dynamo.repro.after_aot import run_repro\n") fd.write(" from torch._dynamo.repro.after_aot import run_repro\n")
fd.write( fd.write(
f" with torch.no_grad():" f" with torch.no_grad():\n"
f" run_repro(mod, load_args, accuracy={accuracy!r}, command={command!r}, " f" run_repro(mod, load_args, accuracy={accuracy!r}, command={command!r}, "
f"save_dir={save_dir!r}, tracing_mode={tracing_mode!r}, check_str={check_str!r}" f"save_dir={save_dir!r}, tracing_mode={tracing_mode!r}, check_str={check_str!r}"
")\n" ")\n"
@ -702,9 +702,10 @@ def repro_run(options, mod, load_args):
if isinstance(arg, torch.Tensor) and arg.is_cuda: if isinstance(arg, torch.Tensor) and arg.is_cuda:
need_sync = True need_sync = True
break break
ref = compiled(args) ref = compiled(list(args))
if need_sync: if need_sync:
synchronize() # ensure segfaults are surfaced synchronize() # ensure segfaults are surfaced
return lambda: compiled(list(args))
# TODO: lazily load the inputs or something, rather than cloning them # TODO: lazily load the inputs or something, rather than cloning them
@ -928,4 +929,4 @@ divergences--you just might not end up with a useful repro in the end.""",
"minifier-query": repro_minifier_query, "minifier-query": repro_minifier_query,
"run": repro_run, "run": repro_run,
} }
COMMAND_FNS[options.command](options, mod, load_args) return COMMAND_FNS[options.command](options, mod, load_args)