Skip to content

Commit 291ace6

Browse files
committed
Show GC execution time
As we now call GC everytime when checkpointing, GC execution time can start to affect the async checkpointing and zero-overhead checkpointing overall efficiency. Log the GC execution for better understanding the effect. ghstack-source-id: 6b741b6 Pull Request resolved: #870
1 parent 6e49885 commit 291ace6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

torchtitan/tools/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import subprocess
1111
import sys
12+
import time
1213
from dataclasses import dataclass
1314
from typing import Optional
1415

@@ -43,8 +44,9 @@ def run(self, step_count):
4344

4445
@staticmethod
4546
def collect(reason: str):
46-
logger.info(reason)
47+
begin = time.monotonic()
4748
gc.collect(1)
49+
logger.info("[GC] %s %.2f seconds.", reason, time.monotonic() - begin)
4850

4951

5052
def get_num_params(model: torch.nn.Module, exclude_embedding: bool = False) -> int:

0 commit comments

Comments
 (0)