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

make garbage collection interval configurable #533

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion olmo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,10 @@ class TrainConfig(BaseConfig):
How often to log to the console.
"""

gen1_gc_interval: int = 1
gen1_gc_interval: Optional[int] = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking, we want the default behavior to be messing with GC?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think so. There might be a better default interval for smaller models, but this was a huge improvement for the 70B.

"""
How often (in steps) to run generation 1 garbage collection.
Set to ``None`` to use automatic garbage collection (i.e. we don't mess with it).
"""

compile: Optional[CompilerConfig] = None
Expand Down
5 changes: 3 additions & 2 deletions olmo/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,8 @@ def fit(self):
self._gc_init_state = gc.isenabled() # cache if garbage collection is enabled, reset on close.

# Disable automatic garbage collection, FSDP doesn't work well with it.
gc.disable()
if self.cfg.gen1_gc_interval is not None:
gc.disable()

if self.cfg.load_path is not None and self.global_step > 0 and self.cfg.eval_on_load:
eval_metrics = self.eval()
Expand Down Expand Up @@ -1155,7 +1156,7 @@ def on_trace_ready(p):
break

# Run generation 1 garbage collection.
if self.global_step % self.cfg.gen1_gc_interval == 0:
if self.cfg.gen1_gc_interval is not None and self.global_step % self.cfg.gen1_gc_interval == 0:
gc.collect(1)

# Python Profiler stuff
Expand Down
Loading