Fix CI slow test AttributeError: 'TestSFTTrainerSlow' object has no attribute 'addCleanup' (#4255)

This commit is contained in:
Albert Villanova del Moral
2025-10-10 17:19:53 +02:00
committed by GitHub
parent 039d526d24
commit 86d1963cc1

View File

@ -412,12 +412,12 @@ class TestSFTTrainerSlow(TrlTestCase):
eval_dataset=self.eval_dataset,
)
# Register cleanup now that we have the trainer
self.addCleanup(cleanup_liger_patches, trainer)
trainer.train()
release_memory(trainer.model, trainer)
# Ensure cleanup of liger patches after the test
try:
trainer.train()
release_memory(trainer.model, trainer)
finally:
cleanup_liger_patches(trainer)
@parameterized.expand(list(itertools.product(MODELS_TO_TEST, PACKING_OPTIONS)))
@require_torch_accelerator