Skip to content

Commit

Permalink
clear memory before merging adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkrthakur committed Aug 26, 2024
1 parent 10defa9 commit 1cb2f48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion configs/llm_finetuning/gpt2_sft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ params:
scheduler: linear
gradient_accumulation: 4
mixed_precision: fp16
merge_adapter: true

hub:
username: ${HF_USERNAME}
token: ${HF_TOKEN}
push_to_hub: true
push_to_hub: false
4 changes: 4 additions & 0 deletions src/autotrain/trainers/clm/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ast
import gc
import os
from enum import Enum
from itertools import chain
Expand Down Expand Up @@ -295,6 +296,9 @@ def post_training_steps(config, trainer):
f.write(model_card)

if config.peft and config.merge_adapter:
del trainer
gc.collect()
torch.cuda.empty_cache()
logger.info("Merging adapter weights...")
try:
merge_adapter(
Expand Down

0 comments on commit 1cb2f48

Please sign in to comment.