Skip to content

Commit eacdc0a

Browse files
gchalumpfacebook-github-bot
authored andcommitted
Adding trace to inference benchmark (#4674)
Summary: X-link: facebookresearch/FBGEMM#1705 Adding trace from inference benchmark Differential Revision: D79920630
1 parent 87f413c commit eacdc0a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

fbgemm_gpu/bench/tbe/tbe_inference_benchmark.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
from pathlib import Path
1919
from typing import Any, Callable, Dict, List, Optional
2020

21+
try:
22+
from fbgemm_gpu.tbe.trace.fbgemm_kineto_trace_handler import (
23+
FbgemmKinetoTraceHandler,
24+
)
25+
except Exception:
26+
pass
27+
2128
import click
2229
import numpy as np
2330

@@ -540,7 +547,7 @@ def context_factory(on_trace_ready: Callable[[profile], None]):
540547
with context_factory(
541548
# pyre-ignore[6]
542549
lambda p: time_dict.update(kernel_time=kineto_trace_profiler(p, trace_info))
543-
):
550+
) as p_obj:
544551
# forward
545552
time_per_iter = benchmark_requests(
546553
requests,
@@ -565,6 +572,21 @@ def context_factory(on_trace_ready: Callable[[profile], None]):
565572
f"Time: {kernel_time:.0f}us, "
566573
f"Memory Usage For Pruning: {mem_for_pruning / 1.0e9:.0f} GB"
567574
)
575+
if p_obj is not None:
576+
try:
577+
FbgemmKinetoTraceHandler(p_obj).sync_log(
578+
run_id=str(
579+
trace_url.format(
580+
tbe_type=tbe_type, phase=trace_info[0], ospid=os.getpid()
581+
)
582+
),
583+
test_phase="inference",
584+
test_name=str("tbe_inference"),
585+
benchmark_duration_us=float(time_per_iter * 1.0e6),
586+
achieved_bw_gbps=float(read_write_bytes / time_per_iter / 1.0e9),
587+
)
588+
except Exception as e:
589+
logging.error(f"Failed to upload performance data to Scuba: {e}")
568590

569591
# free up GPU memory
570592
del requests

0 commit comments

Comments
 (0)