Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretrain tok sec #1805

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions litgpt/pretrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,22 @@ def main(
# Save final checkpoint
save_checkpoint(fabric, state, tokenizer_dir, out_dir / "final" / "lit_model.pth")

fabric.print(f"Training time: {(time.perf_counter()-train_time):.2f}s")
total_tokens = state["iter_num"] * train.micro_batch_size * model.max_seq_length * fabric.world_size

# Print formatted output
separator = "-" * 40
fabric.print(separator)
fabric.print("| Performance")
fabric.print(f"| - Total tokens : {total_tokens:,}")
fabric.print(f"| - Training Time : {(time.perf_counter()-train_time):.2f} s")
fabric.print(f"| - Tok/sec : {total_tokens / train_time:.2f} tok/s")
fabric.print("| " + "-" * 40)

if fabric.device.type == "cuda":
fabric.print(f"Memory used: {torch.cuda.max_memory_allocated() / 1e9:.02f} GB")
memory_used = torch.cuda.max_memory_allocated() / 1e9
fabric.print("| Memory Usage")
fabric.print(f"| - Memory Used : {memory_used:.2f} GB")
fabric.print(separator)


def fit(
Expand Down
2 changes: 1 addition & 1 deletion litgpt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def create_finetuning_performance_report(training_time, token_counts, device_typ
memory_used = torch.cuda.max_memory_allocated() / 1e9
output += f"| Memory Usage \n"
output += f"| - Memory Used : {memory_used:.02f} GB \n"
output += "=======================================================\n"
output += "-------------------------------------------------------\n"

return output

Expand Down
Loading