Skip to content

Commit 1bf0426

Browse files
authored
Revert "Perf entry superset (#58)"
This reverts commit 6d7a660.
1 parent 6d7a660 commit 1bf0426

File tree

10 files changed

+33
-1047
lines changed

10 files changed

+33
-1047
lines changed

src/madengine/mad.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ def main():
267267
parser_database_update_table.set_defaults(func=update_table)
268268
# Database subcommand uploading to MongoDB
269269
parser_database_upload_mongodb = subparsers_database.add_parser('upload-mongodb', description="Update table in DB.", help='Update table in DB')
270-
parser_database_upload_mongodb.add_argument('--csv-file-path', type=str, default='perf_entry.csv', help='Path to the csv file (for legacy perf.csv)')
271-
parser_database_upload_mongodb.add_argument('--json-file-path', type=str, default=None, help='Path to the json file (for perf_entry_super.json)')
270+
parser_database_upload_mongodb.add_argument('--csv-file-path', type=str, default='perf_entry.csv', help='Path to the csv file')
272271
parser_database_upload_mongodb.add_argument("--database-name", type=str, required=True, help="Name of the MongoDB database")
273272
parser_database_upload_mongodb.add_argument("--collection-name", type=str, required=True, help="Name of the MongoDB collection")
274273
parser_database_upload_mongodb.set_defaults(func=upload_mongodb)

src/madengine/tools/run_models.py

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@
5050
from madengine.core.constants import MODEL_DIR, PUBLIC_GITHUB_ROCM_KEY
5151
from madengine.core.timeout import Timeout
5252
from madengine.tools.update_perf_csv import update_perf_csv
53-
from madengine.tools.update_perf_super import update_perf_super_json
5453
from madengine.tools.csv_to_html import convert_csv_to_html
5554
from madengine.tools.discover_models import DiscoverModels
56-
from madengine.utils.config_parser import ConfigParser
5755

5856

5957
class RunDetails:
@@ -85,7 +83,6 @@ class RunDetails:
8583
data_download_duration (str): The duration of data download.
8684
build_number (str): The CI build number.
8785
additional_docker_run_options (str): The additional options used for docker run.
88-
configs (dict or list or None): The configuration data from config files.
8986
"""
9087

9188
# Avoiding @property for ease of code, add if needed.
@@ -115,7 +112,6 @@ def __init__(self):
115112
self.data_download_duration = ""
116113
self.build_number = ""
117114
self.additional_docker_run_options = ""
118-
self.configs = None
119115

120116
def print_perf(self):
121117
"""Print the performance results of a model.
@@ -130,30 +126,6 @@ def print_perf(self):
130126
def generate_json(self, json_name: str, multiple_results: bool = False) -> None:
131127
"""Generate JSON file for performance results of a model.
132128
133-
Args:
134-
json_name (str): The name of the JSON file.
135-
multiple_results (bool): The status of multiple results. Default is False.
136-
137-
Raises:
138-
Exception: An error occurred while generating JSON file for performance results of a model.
139-
"""
140-
# Exclude configs from CSV workflow as it can contain list/dict values
141-
# that cause issues with pandas DataFrame creation
142-
keys_to_exclude = (
143-
{"model", "performance", "metric", "status", "configs"} if multiple_results
144-
else {"configs"}
145-
)
146-
attributes = vars(self)
147-
output_dict = {x: attributes[x] for x in attributes if x not in keys_to_exclude}
148-
with open(json_name, "w") as outfile:
149-
json.dump(output_dict, outfile)
150-
151-
def generate_super_json(self, json_name: str, multiple_results: bool = False) -> None:
152-
"""Generate enhanced JSON file with config data for performance results.
153-
154-
This method is similar to generate_json but includes the configs field
155-
for perf_entry_super.json generation.
156-
157129
Args:
158130
json_name (str): The name of the JSON file.
159131
multiple_results (bool): The status of multiple results. Default is False.
@@ -167,7 +139,7 @@ def generate_super_json(self, json_name: str, multiple_results: bool = False) ->
167139
attributes = vars(self)
168140
output_dict = {x: attributes[x] for x in attributes if x not in keys_to_exclude}
169141
with open(json_name, "w") as outfile:
170-
json.dump(output_dict, outfile, indent=2)
142+
json.dump(output_dict, outfile)
171143

172144

173145
class RunModels:
@@ -1006,17 +978,6 @@ def run_model(self, model_info: typing.Dict) -> bool:
1006978
# Taking gpu arch from context assumes the host image and container have the same gpu arch.
1007979
# Environment variable updates for MAD Public CI
1008980
run_details.gpu_architecture = self.context.ctx["docker_env_vars"]["MAD_SYSTEM_GPU_ARCHITECTURE"]
1009-
1010-
# Parse and load config file if present in args for perf_entry_super.json
1011-
try:
1012-
config_parser = ConfigParser(scripts_base_dir=os.path.dirname(model_info.get("scripts", "")))
1013-
run_details.configs = config_parser.parse_and_load(
1014-
model_info["args"],
1015-
model_info.get("scripts", "")
1016-
)
1017-
except Exception as e:
1018-
print(f"Warning: Could not parse config file: {e}")
1019-
run_details.configs = None
1020981

1021982
# Check the setting of shared memory size
1022983
if "SHM_SIZE" in self.context.ctx:
@@ -1057,14 +1018,6 @@ def run_model(self, model_info: typing.Dict) -> bool:
10571018
# generate exception for testing
10581019
run_details.generate_json("perf_entry.json")
10591020
update_perf_csv(exception_result="perf_entry.json", perf_csv=self.args.output)
1060-
1061-
# Generate perf_entry_super.json
1062-
run_details.generate_super_json("perf_entry_super.json")
1063-
update_perf_super_json(
1064-
exception_result="perf_entry_super.json",
1065-
perf_super_json="perf_entry_super.json",
1066-
scripts_base_dir=os.path.dirname(model_info.get("scripts", "")),
1067-
)
10681021
else:
10691022
print(
10701023
f"Running model {run_details.model} on {run_details.gpu_architecture} architecture."
@@ -1166,30 +1119,12 @@ def run_model(self, model_info: typing.Dict) -> bool:
11661119
model_name=run_details.model,
11671120
common_info="common_info.json",
11681121
)
1169-
1170-
# Generate perf_entry_super.json
1171-
run_details.generate_super_json("common_info_super.json", multiple_results=True)
1172-
update_perf_super_json(
1173-
multiple_results=model_info['multiple_results'],
1174-
perf_super_json="perf_entry_super.json",
1175-
model_name=run_details.model,
1176-
common_info="common_info_super.json",
1177-
scripts_base_dir=os.path.dirname(model_info.get("scripts", "")),
1178-
)
11791122
else:
11801123
run_details.generate_json("perf_entry.json")
11811124
update_perf_csv(
11821125
single_result="perf_entry.json",
11831126
perf_csv=self.args.output,
11841127
)
1185-
1186-
# Generate perf_entry_super.json
1187-
run_details.generate_super_json("perf_entry_super.json")
1188-
update_perf_super_json(
1189-
single_result="perf_entry_super.json",
1190-
perf_super_json="perf_entry_super.json",
1191-
scripts_base_dir=os.path.dirname(model_info.get("scripts", "")),
1192-
)
11931128

11941129
self.return_status &= (run_details.status == 'SUCCESS')
11951130

@@ -1206,14 +1141,6 @@ def run_model(self, model_info: typing.Dict) -> bool:
12061141
exception_result="perf_entry.json",
12071142
perf_csv=self.args.output,
12081143
)
1209-
1210-
# Generate perf_entry_super.json
1211-
run_details.generate_super_json("perf_entry_super.json")
1212-
update_perf_super_json(
1213-
exception_result="perf_entry_super.json",
1214-
perf_super_json="perf_entry_super.json",
1215-
scripts_base_dir=os.path.dirname(model_info.get("scripts", "")),
1216-
)
12171144

12181145
except Exception as e:
12191146
self.return_status = False
@@ -1228,14 +1155,6 @@ def run_model(self, model_info: typing.Dict) -> bool:
12281155
exception_result="perf_entry.json",
12291156
perf_csv=self.args.output,
12301157
)
1231-
1232-
# Generate perf_entry_super.json
1233-
run_details.generate_super_json("perf_entry_super.json")
1234-
update_perf_super_json(
1235-
exception_result="perf_entry_super.json",
1236-
perf_super_json="perf_entry_super.json",
1237-
scripts_base_dir=os.path.dirname(model_info.get("scripts", "")),
1238-
)
12391158

12401159
return self.return_status
12411160

src/madengine/tools/update_perf_csv.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,7 @@ def perf_entry_dict_to_csv(perf_entry: typing.Dict) -> None:
7373
perf_entry: The performance entry dictionary.
7474
"""
7575
flatten_tags(perf_entry)
76-
77-
# Convert any non-scalar values (list/dict) to JSON strings
78-
# to avoid DataFrame creation errors when values don't match index length
79-
perf_entry_safe = {}
80-
for key, value in perf_entry.items():
81-
if isinstance(value, (list, dict)):
82-
# Convert lists and dicts to JSON strings
83-
perf_entry_safe[key] = json.dumps(value) if value is not None else None
84-
else:
85-
perf_entry_safe[key] = value
86-
87-
js_df = pd.DataFrame(perf_entry_safe, index=[0])
76+
js_df = pd.DataFrame(perf_entry, index=[0])
8877
perf_entry_df_to_csv(js_df)
8978

9079

@@ -127,29 +116,15 @@ def handle_multiple_results(
127116
row = common_info_json.copy()
128117
model = r.pop("model")
129118
row["model"] = model_name + "_" + str(model)
130-
131-
# Only extract essential result columns for perf.csv
132-
# The full details with all metrics are preserved in perf_entry_super.json
133-
row["performance"] = r.get("performance")
134-
row["metric"] = r.get("metric")
119+
row.update(r)
135120

136121
if row["performance"] is not None and pd.notna(row["performance"]):
137122
row["status"] = "SUCCESS"
138123
else:
139124
row["status"] = "FAILURE"
140125

141-
# Convert any non-scalar values (list/dict) to JSON strings
142-
# to avoid DataFrame creation errors when values don't match index length
143-
row_safe = {}
144-
for key, value in row.items():
145-
if isinstance(value, (list, dict)):
146-
# Convert lists and dicts to JSON strings
147-
row_safe[key] = json.dumps(value) if value is not None else None
148-
else:
149-
row_safe[key] = value
150-
151126
final_multiple_results_df = pd.concat(
152-
[final_multiple_results_df, pd.DataFrame(row_safe, index=[0])], ignore_index=True
127+
[final_multiple_results_df, pd.DataFrame(row, index=[0])], ignore_index=True
153128
)
154129
# Reorder columns according to existing perf csv
155130
columns = perf_csv_df.columns.tolist()

0 commit comments

Comments
 (0)