Skip to content

Commit 86d1963

Browse files
Fix CI slow test AttributeError: 'TestSFTTrainerSlow' object has no attribute 'addCleanup' (#4255)
1 parent 039d526 commit 86d1963

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/slow/test_sft_slow.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ def cleanup_liger_patches(trainer):
412412
eval_dataset=self.eval_dataset,
413413
)
414414

415-
# Register cleanup now that we have the trainer
416-
self.addCleanup(cleanup_liger_patches, trainer)
417-
418-
trainer.train()
419-
420-
release_memory(trainer.model, trainer)
415+
# Ensure cleanup of liger patches after the test
416+
try:
417+
trainer.train()
418+
release_memory(trainer.model, trainer)
419+
finally:
420+
cleanup_liger_patches(trainer)
421421

422422
@parameterized.expand(list(itertools.product(MODELS_TO_TEST, PACKING_OPTIONS)))
423423
@require_torch_accelerator

0 commit comments

Comments
 (0)