Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: final-model.pt on KeyboardInterrupt even if save_final_model=False #3250

Closed
plonerma opened this issue May 25, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@plonerma
Copy link
Collaborator

Describe the bug

Flair's trainer saves a "final-model.pt" on a keyboard-interrupt even if save_final_model is false.

I haven't opened a PR yet, since I'm not sure, if this behavior is intended (e.g. to enable the continuation of training). Personally, I would not expect flair to produce a "final-model.pt" in this case.

The following line (as well as in the following except-block), would need to be encased by an if-statement:

self.model.save(base_path / "final-model.pt", checkpoint=save_optimizer_state)

To Reproduce

Execute any training with `save_final_model=False` and interrupt the training using Ctrl+C.

Expected behavior

I would expect flair to terminate the training (after doing the final evaluation) and to not write a final model file.

Logs and Stack traces

No response

Screenshots

No response

Additional Context

No response

Environment

Versions:

Flair

0.12.2

Pytorch

2.0.1+cu117

Transformers

4.29.2

GPU

True

@plonerma plonerma added the bug Something isn't working label May 25, 2023
@alanakbik
Copy link
Collaborator

Good catch! Yes, that is unintended behavior I would say.

@plonerma
Copy link
Collaborator Author

Alright, I will prepare a PR

plonerma added a commit that referenced this issue May 25, 2023
alanakbik added a commit that referenced this issue Aug 8, 2023
GH-3250: Save final model only if `save_final_model` is True (even if the training is interrupted)
@plonerma plonerma closed this as completed Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants