# Warning occured when trying to load checkpoint to continue training

**URL:** <https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694>\
**Category:** 🤗Transformers\
**Created:** [August 12, 2020, 9:26am UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694 "2020-08-12T09:26:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![proxyht](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@proxyht](https://discuss.huggingface.co/u/proxyht)\
**Post date:** [August 12, 2020, 9:26am UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694/1 "2020-08-12T09:26:38Z")

</div>

When I tried to load the trainer from a specific checkpoint (which were generated during a previous training process)

```
trainer.train("checkpoint-100")

```

The model did continue to train from the given checkpoint, but also I encountered this warning:

```
UserWarning: Please also save or load the state of the optimzer when saving or loading the scheduler.

```

warnings.warn(SAVE\_STATE\_WARNING, UserWarning)

Inside the “checkpoint-100” directory, there are 5 files: **config.json** , **optimizer.pt** , **pytorch\_model.bin** , **scheduler.pt** , **training\_args.bin**

---

<div class="post-metadata">

**Author:** ![proxyht](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@proxyht](https://discuss.huggingface.co/u/proxyht)\
**Post date:** [August 12, 2020, 2:51pm UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694/2 "2020-08-12T14:51:08Z")

</div>

Update:  
The model loss reset (to higher value) after loading the checkpoint with the warning

---

<div class="post-metadata">

**Author:** ![kintaro](https://avatars.discourse-cdn.com/v4/letter/k/e56c9b/32.png) [@kintaro](https://discuss.huggingface.co/u/kintaro)\
**Post date:** [September 17, 2020, 2:11am UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694/3 "2020-09-17T02:11:43Z")

</div>

HI, I’m facing a similar issue. How did you solve it?

---

<div class="post-metadata">

**Author:** ![proxyht](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@proxyht](https://discuss.huggingface.co/u/proxyht)\
**Post date:** [September 17, 2020, 2:23pm UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694/4 "2020-09-17T14:23:09Z")

</div>

It appeared to be some bug in my code. Did manage to fix it but now I don’t remember how

Vào 09:23, T.5, 17 Th9, 2020 Alex via Hugging Face Forums \<[hellohellohello@discoursemail.com](mailto:hellohellohello@discoursemail.com)\> đã viết:

---

<div class="post-metadata">

**Author:** ![jsrozner](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jsrozner/32/264_2.png) [@jsrozner](https://discuss.huggingface.co/u/jsrozner)\
**Post date:** [October 12, 2020, 6:08am UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694/5 "2020-10-12T06:08:00Z")

</div>

I have this problem, too. I am running finetune\_t5.sh (or finetune bart) as given in transformers/examples/seq2seq. The error is given even when running the example script as given:

From transformers/examples/seq2seq, run ./finetune\_bart\_tiny.sh. Observe the following output with warning about scheduler:

cnn\_tiny.tgz 100%[================================================\>] 22.59K --.-KB/s in 0.08s

2020-10-11 22:53:22 (299 KB/s) - ‘cnn\_tiny.tgz’ saved [23131/23131]

x cnn\_tiny/  
x cnn\_tiny/train.target  
x cnn\_tiny/train.source  
x cnn\_tiny/val.source  
x cnn\_tiny/val.target  
x cnn\_tiny/test.source  
x cnn\_tiny/test.target

GPU available: False, used: False  
TPU available: False, using: 0 TPU cores  
Epoch 1: 100%|█████████████████████████████████████████████████████| 4/4 [00:48\<00:00, 12.22s/it, loss=10.838, v\_num=6]/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/torch/optim/lr\_scheduler.py:200: UserWarning: Please also save or load the state of the optimzer when saving or loading the scheduler.  
warnings.warn(SAVE\_STATE\_WARNING, UserWarning)  
Epoch 1: 100%|█████████████████████████████████████████████████████| 4/4 [00:59\<00:00, 14.81s/it, loss=10.838, v\_num=6]  
(cryptic)

---

<div class="post-metadata">

**Author:** ![jsrozner](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jsrozner/32/264_2.png) [@jsrozner](https://discuss.huggingface.co/u/jsrozner)\
**Post date:** [October 13, 2020, 6:22pm UTC](https://discuss.huggingface.co/t/warning-occured-when-trying-to-load-checkpoint-to-continue-training/694/6 "2020-10-13T18:22:32Z")

</div>

Bug filed: [https://github.com/huggingface/transformers/issues/7765](https://github.com/huggingface/transformers/issues/7765)
