Skip to content

Commit

Permalink
Improve test reliability for Accelerator.free_memory() (huggingface#2935
Browse files Browse the repository at this point in the history
)
  • Loading branch information
matthewdouglas authored Jul 16, 2024
1 parent 7a5c231 commit d16d737
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import pickle
import tempfile
import time
from unittest.mock import patch

import psutil
Expand Down Expand Up @@ -220,6 +221,10 @@ def test_free_memory_dereferences_prepared_components(self):
model, optimizer, scheduler, train_dl, valid_dl = accelerator.prepare(
model, optimizer, scheduler, train_dl, valid_dl
)

# Short sleep here makes this test more reliable
time.sleep(1e-3)

model, optimizer, scheduler, train_dl, valid_dl = accelerator.free_memory(
model, optimizer, scheduler, train_dl, valid_dl
)
Expand Down

0 comments on commit d16d737

Please sign in to comment.