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, eval_dataset=self.eval_dataset,
) )
# Register cleanup now that we have the trainer # Ensure cleanup of liger patches after the test
self.addCleanup(cleanup_liger_patches, trainer) try:
trainer.train()
trainer.train() release_memory(trainer.model, trainer)
finally:
release_memory(trainer.model, trainer) cleanup_liger_patches(trainer)
@parameterized.expand(list(itertools.product(MODELS_TO_TEST, PACKING_OPTIONS))) @parameterized.expand(list(itertools.product(MODELS_TO_TEST, PACKING_OPTIONS)))
@require_torch_accelerator @require_torch_accelerator