fix issue that some example with no trainer use accelerator.end_train… (#37435)

* fix issue that some example with no trainer use accelerator.end_training in a wrong way

* reformat code

---------

Co-authored-by: Marc Sun <57196510+SunMarc@users.noreply.github.com>
This commit is contained in:
we1559
2025-04-18 23:59:42 +08:00
committed by GitHub
parent 6f5014ac31
commit b0c6ff5e13
12 changed files with 36 additions and 36 deletions

View File

@@ -759,9 +759,6 @@ def main():
logger.info(f"Test metrics: {metrics}")
if args.with_tracking:
accelerator.end_training()
if args.output_dir is not None:
accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
@@ -784,6 +781,9 @@ def main():
ignore_patterns=["epoch_*"],
)
accelerator.wait_for_everyone()
accelerator.end_training()
if __name__ == "__main__":
main()