Skip to content
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

Fix component DB integration isseus #184

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
35 changes: 31 additions & 4 deletions train/compute/python/lib/pytorch/benchmark_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def __init__(
self.cupti_profiler_measure_per_kernel: bool = getattr(
config, "cupti_profiler_measure_per_kernel", True
)
self.upload_to_manifold: bool = getattr(config, "upload_to_manifold", False)

def eval(self, evaluate_file_path: str) -> Dict:
self.logger.info("Microbenchmarking started")
Expand Down Expand Up @@ -208,10 +209,36 @@ def eval(self, evaluate_file_path: str) -> Dict:
file=out_file,
)
if self.profile and prof:
self.trace_file = f"{self.out_file_prefix}_trace.json"
self.logger.info(f"trace: {self.trace_file}")
prof.export_chrome_trace(self.trace_file)
ret_files["trace_file"] = self.trace_file
if self.upload_to_manifold is True:
try:
import os
import socket
from datetime import datetime

import aiplatform.monitoring.unitrace.upload_manifold as unitrace_upload_manifold

def trace_handler_save_manifold(prof):
trace_file_prefix = "{}.{}.{}".format(
"component-db",
datetime.now().strftime(
unitrace_upload_manifold.TIME_FORMAT_STR
),
os.getpid(),
)
file_name = trace_file_prefix + ".pt.trace.json"
kineto_manifold_target_name = f"manifold://gpu_traces/{unitrace_upload_manifold.DEFAULT_ROOT_MANIFOLD_PATH}/{socket.gethostname()}/{file_name}"
prof.export_chrome_trace(kineto_manifold_target_name)
return kineto_manifold_target_name

mainfold_file_path = trace_handler_save_manifold(prof)
ret_files["trace_file"] = mainfold_file_path
except Exception as e:
self.logger.error(f"Failed to upload trace to manifold: {e}")
else:
self.trace_file = f"{self.out_file_prefix}_trace.json"
self.logger.info(f"trace: {self.trace_file}")
prof.export_chrome_trace(self.trace_file)
ret_files["trace_file"] = self.trace_file

ret_files["benchmark_file"] = self.out_file_name

Expand Down
Loading