MCPcopy
hub / github.com/huggingface/transformers / MetricsRecorder

Class MetricsRecorder

benchmark/benchmarks_entrypoint.py:40–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40class MetricsRecorder:
41 def __init__(
42 self,
43 connection,
44 logger: logging.Logger,
45 repository: str,
46 branch: str,
47 commit_id: str,
48 commit_msg: str,
49 collect_csv_data: bool = True,
50 ):
51 self.conn = connection
52 self.use_database = connection is not None
53 if self.use_database:
54 self.conn.autocommit = True
55 self.logger = logger
56 self.repository = repository
57 self.branch = branch
58 self.commit_id = commit_id
59 self.commit_msg = commit_msg
60 self.collect_csv_data = collect_csv_data
61
62 # For CSV export - store all data in pandas DataFrames (only if CSV collection is enabled)
63 if self.collect_csv_data:
64 # Initialize empty DataFrames with proper schemas
65 self.benchmarks_df = pd.DataFrame(
66 columns=[
67 "benchmark_id",
68 "repository",
69 "branch",
70 "commit_id",
71 "commit_message",
72 "metadata",
73 "created_at",
74 ]
75 )
76 self.device_measurements_df = pd.DataFrame(
77 columns=["benchmark_id", "cpu_util", "mem_megabytes", "gpu_util", "gpu_mem_megabytes", "time"]
78 )
79 self.model_measurements_df = pd.DataFrame(
80 columns=[
81 "benchmark_id",
82 "time",
83 "model_load_time",
84 "first_eager_forward_pass_time_secs",
85 "second_eager_forward_pass_time_secs",
86 "first_eager_generate_time_secs",
87 "second_eager_generate_time_secs",
88 "time_to_first_token_secs",
89 "time_to_second_token_secs",
90 "time_to_third_token_secs",
91 "time_to_next_token_mean_secs",
92 "first_compile_generate_time_secs",
93 "second_compile_generate_time_secs",
94 "third_compile_generate_time_secs",
95 "fourth_compile_generate_time_secs",
96 ]
97 )

Callers 2

run_benchmarkFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected