Skip to content

serious bug with trainer.py when restarting the training from a checkpoint #11294

Description

@dorooddorood606

Environment info

  • transformers version: 4.5.1
  • Platform: Linux
  • Python version: 3.8
  • PyTorch version (GPU?): 1.8
  • Tensorflow version (GPU?): -
  • Using GPU in script?: -
  • Using distributed or parallel set-up in script?: -

Who can help

trainer: @sgugger, @patil-suraj

Information

Hi, I see this serious issue with trainer.py class, let please consider run_translation.py script [1] after you define the model, let freeze the encoder, or wrap the model in a class. So one can modify the model after this line

model = AutoModelForSeq2SeqLM.from_pretrained(

Then, during the training, one can stop the training, and now would like to continue the training from the place it is stopped, if you print the number of parameters inside trainer.py, right before this line:

self._load_optimizer_and_scheduler(resume_from_checkpoint)

like this

for n,p in model.named_parameters():
   if p.requires_grad:
       print(n)

what would we see? We see all parameters are there, even the ones we made frozen, this is a serious bug that if the user modify the model after creation, those modifications are not considered when restarting the training, could you kindly have a look?
thanks

[1] https://github.com/huggingface/transformers/blob/master/examples/seq2seq/run_translation.py

Expected behavior

The user should be able to continue training the modified model as they are modified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions