-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow benchmark between multiple configs
[ghstack-poisoned]
- Loading branch information
Showing
8 changed files
with
193 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
from typing import Any, Dict, Sequence | ||
|
||
from torchtitan.metrics import MetricRetriever | ||
|
||
metrics: Dict[str, Dict[int, Dict[str, Any]]] = {} | ||
|
||
run_id = 0 | ||
dump_dir = f"test_out/my_example" | ||
log_dir = os.path.join(dump_dir, "tb", str(run_id)) | ||
print(log_dir) | ||
metric_retriever = MetricRetriever(log_dir) | ||
|
||
metrics[f"Run ID {run_id}"] = metric_retriever.get_metrics() | ||
|
||
|
||
def print_metrics( | ||
metrics: Dict[str, Dict[int, Dict[str, Any]]], | ||
filter_keys=[ | ||
"wps", | ||
"mfu(%)", | ||
"memory/max_active(GiB)", | ||
"memory/max_active(%)", | ||
"memory/max_reserved(%)", | ||
"loss_metrics/global_avg_loss", | ||
"loss_metrics/global_max_loss", | ||
], | ||
) -> None: | ||
for run_id, all_step_metrics in metrics.items(): | ||
print("=" * 100) | ||
print(run_id) | ||
print("=" * 100) | ||
if all_step_metrics: | ||
last_step = next(reversed(all_step_metrics)) | ||
last_step_metrics = all_step_metrics[last_step] | ||
# Print the column headers | ||
if filter_keys: | ||
filtered_keys = [key for key in filter_keys if key in last_step_metrics] | ||
else: | ||
filtered_keys = list(last_step_metrics.keys()) | ||
|
||
max_key_length = max(len(key) for key in filtered_keys) | ||
# Add an empty header for the run_id column | ||
header_row = " | ".join( | ||
[" " * 10] + [f"{key.ljust(max_key_length)}" for key in filtered_keys] | ||
) | ||
print(header_row) | ||
print("-" * len(header_row)) | ||
# Print the run_id and the values | ||
value_row = " | ".join( | ||
[f"{run_id:10}"] | ||
+ [ | ||
f"{str(last_step_metrics[key]).ljust(max_key_length)}" | ||
for key in filtered_keys | ||
] | ||
) | ||
print(value_row) | ||
|
||
|
||
print_metrics(metrics) |
Binary file added
BIN
+7.59 KB
..._out/my_example/tb/0/events.out.tfevents.1732658391.devvm2170.rva0.facebook.com.3145570.0
Binary file not shown.
Binary file added
BIN
+7.59 KB
..._out/my_example/tb/1/events.out.tfevents.1732658435.devvm2170.rva0.facebook.com.3159818.0
Binary file not shown.
Binary file added
BIN
+7.59 KB
..._out/my_example/tb/2/events.out.tfevents.1732658475.devvm2170.rva0.facebook.com.3169841.0
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters