Skip to content
Closed
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
8 changes: 8 additions & 0 deletions src/megatron/bridge/training/utils/train_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,14 @@ def report_throughput(
elapsed_samples = int(history_samples[-1]) - int(history_samples[0])
elapsed_tokens = int(history_tokens[-1]) - int(history_tokens[0])
elapsed_wct = history_wct[-1] - history_wct[0]

# Skip throughput calculation if elapsed_wct is zero or negative
# This can happen during checkpoint resumption when history_wct is reinitialized
# and the first few iterations are very fast or have identical timestamps
if elapsed_wct <= 0:
print_rank_0(f"Warning: elapsed_wct is {elapsed_wct}, skipping throughput calculation at iteration {iteration}")
return {}

batches_per_sec = elapsed_batches / elapsed_wct
samples_per_sec = elapsed_samples / elapsed_wct
dev_batches_per_sec = batches_per_sec / world_size
Expand Down
Loading