Skip to content

Adding trace to inference benchmark #4674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion fbgemm_gpu/bench/tbe/tbe_inference_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional

try:
from fbgemm_gpu.tbe.trace.fbgemm_kineto_trace_handler import (
FbgemmKinetoTraceHandler,
)
except Exception:
pass

import click
import numpy as np

Expand Down Expand Up @@ -540,7 +547,7 @@ def context_factory(on_trace_ready: Callable[[profile], None]):
with context_factory(
# pyre-ignore[6]
lambda p: time_dict.update(kernel_time=kineto_trace_profiler(p, trace_info))
):
) as p_obj:
# forward
time_per_iter = benchmark_requests(
requests,
Expand All @@ -565,6 +572,21 @@ def context_factory(on_trace_ready: Callable[[profile], None]):
f"Time: {kernel_time:.0f}us, "
f"Memory Usage For Pruning: {mem_for_pruning / 1.0e9:.0f} GB"
)
if p_obj is not None:
try:
FbgemmKinetoTraceHandler(p_obj).sync_log(
run_id=str(
trace_url.format(
tbe_type=tbe_type, phase=trace_info[0], ospid=os.getpid()
)
),
test_phase="inference",
test_name=str("tbe_inference"),
benchmark_duration_us=float(time_per_iter * 1.0e6),
achieved_bw_gbps=float(read_write_bytes / time_per_iter / 1.0e9),
)
except Exception as e:
logging.error(f"Failed to upload performance data to Scuba: {e}")

# free up GPU memory
del requests
Expand Down
Loading