-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimal_points_script.py
More file actions
56 lines (43 loc) · 1.49 KB
/
optimal_points_script.py
File metadata and controls
56 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pandas as pd
import os
from tabulate import tabulate
# ---------------- Config ----------------
INPUT_CSV = "data/lookup_table/pi_to_pi_lookup_results.csv"
OUTPUT_CSV = "data/lookup_table/optimal_points/pi_to_pi_optimal_splits.csv"
OUTPUT_TABLE = "data/lookup_table/optimal_points/pi_to_pi_optimal_splits.txt"
THROUGHPUT_COL = "system_inference_throughput_imgs_per_s"
# ---------------------------------------
df = pd.read_csv(INPUT_CSV)
# Ensure bandwidth is integer (prevents 750.0 / 939.0 bugs)
df["bandwidth_mbps"] = df["bandwidth_mbps"].astype(int)
# Find row with max throughput per (model, bandwidth)
idx = (
df.groupby(["model_name", "bandwidth_mbps"])[THROUGHPUT_COL]
.idxmax()
)
optimal_df = (
df.loc[idx, ["model_name", "bandwidth_mbps", "split_index", THROUGHPUT_COL]]
.sort_values(["model_name", "bandwidth_mbps"])
.reset_index(drop=True)
)
# Round for readability
optimal_df[THROUGHPUT_COL] = optimal_df[THROUGHPUT_COL].round(3)
# Ensure output directory exists
os.makedirs(os.path.dirname(OUTPUT_CSV), exist_ok=True)
# Save CSV (for code / lookup use)
optimal_df.to_csv(OUTPUT_CSV, index=False)
# Create pretty table
table = tabulate(
optimal_df,
headers="keys",
tablefmt="grid",
showindex=False
)
# Save table to text file
with open(OUTPUT_TABLE, "w") as f:
f.write(table)
# Print table to console
print("\nOptimal split per model per bandwidth:\n")
print(table)
print(f"\nSaved CSV → {OUTPUT_CSV}")
print(f"Saved table→ {OUTPUT_TABLE}")