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

@@ -617,9 +617,6 @@ def main():
output_dir = os.path.join(args.output_dir, output_dir)
accelerator.save_state(output_dir)
if args.with_tracking:
accelerator.end_training()
if args.output_dir is not None:
accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
@@ -640,6 +637,9 @@ def main():
with open(os.path.join(args.output_dir, "all_results.json"), "w") as f:
json.dump(all_results, f)
accelerator.wait_for_everyone()
accelerator.end_training()
if __name__ == "__main__":
main()