Skip to content

Commit 34b8d8b

Browse files
xmfanpytorchmergebot
authored andcommitted
update compile time benchmarks to dump compile times to stdout and csv (pytorch#145447)
```python # inductor.csv dev,name,batch_size,accuracy,calls_captured,unique_graphs,graph_breaks,unique_graph_breaks,autograd_captures,autograd_compiles,cudagraph_skips,compilation_latency cuda,cait_m36_384,8,pass,2510,1,0,0,0,0,0,87.705186 ``` ```python loading model: 0it [01:27, ?it/s] cuda eval cait_m36_384 Compilation time (from dynamo_timed): 87.705186276 # <---------------- pass TIMING: _recursive_pre_grad_passes:0.11023 pad_mm_benchmark:0.50341 _recursive_joint_graph_passes:3.88557 _recursive_post_grad_passes:6.71182 async_compile.wait:4.16914 code_gen:17.57586 inductor_compile:42.55769 backend_compile:72.47122 entire_frame_compile:87.70519 gc:0.00112 total_wall_time:87.70519 STATS: call_* op count: 2510 | FakeTensorMode.__torch_dispatch__:101743 | FakeTensor.__torch_dispatch__:12959 | ProxyTorchDispatchMode.__torch_dispatch__:41079 Dynamo produced 1 graphs covering 2510 ops with 0 graph breaks (0 unique) ``` Pull Request resolved: pytorch#145447 Approved by: https://github.com/ezyang
1 parent 629fb15 commit 34b8d8b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.ci/pytorch/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ test_single_dynamo_benchmark() {
625625
TEST_CONFIG=${TEST_CONFIG//_avx512/}
626626
fi
627627
python "benchmarks/dynamo/$suite.py" \
628-
--ci --accuracy --timing --explain \
628+
--ci --accuracy --timing --explain --print-compilation-time \
629629
"${DYNAMO_BENCHMARK_FLAGS[@]}" \
630630
"$@" "${partition_flags[@]}" \
631631
--output "$TEST_REPORTS_DIR/${name}_${suite}.csv"

benchmarks/dynamo/common.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ def output_signpost(data, args, suite, error=None):
532532

533533
from torch._dynamo.utils import calculate_time_spent, compilation_time_metrics
534534

535+
wall_time_by_phase = calculate_time_spent()
536+
535537
open_source_signpost(
536538
subsystem="dynamo_benchmark",
537539
name=event_name,
@@ -544,7 +546,7 @@ def output_signpost(data, args, suite, error=None):
544546
# NB: Externally, compilation_metrics colloquially refers to
545547
# the coarse-grained phase timings, even though internally
546548
# they are called something else
547-
"compilation_metrics": calculate_time_spent(),
549+
"compilation_metrics": wall_time_by_phase,
548550
"agg_compilation_metrics": {
549551
k: sum(v) for k, v in compilation_time_metrics.items()
550552
},
@@ -557,6 +559,8 @@ def output_signpost(data, args, suite, error=None):
557559
),
558560
)
559561

562+
return wall_time_by_phase["total_wall_time"]
563+
560564

561565
def nothing(f):
562566
return f
@@ -2907,13 +2911,17 @@ def record_status(accuracy_status, dynamo_start_stats):
29072911
headers.append(k)
29082912
fields.append(v)
29092913

2910-
write_outputs(output_filename, headers, fields)
2911-
2912-
output_signpost(
2914+
total_wall_time = output_signpost(
29132915
dict(zip(o_headers, o_fields)),
29142916
self.args,
29152917
self.suite_name,
29162918
)
2919+
headers.append("compilation_latency")
2920+
fields.append(total_wall_time)
2921+
write_outputs(output_filename, headers, fields)
2922+
2923+
if self.args.print_compilation_time:
2924+
print(f"Compilation time (from dynamo_timed): {total_wall_time}")
29172925

29182926
return accuracy_status
29192927

0 commit comments

Comments
 (0)