Skip to content

RuntimeError: unscale_() has already been called on this optimizer since the last update(). #24050

@ryzn0518

Description

@ryzn0518

It mentions this fine-tuning notebook like:

https://colab.research.google.com/#fileId=https%3A//huggingface.co/dfurman/falcon-7b-chat-oasst1/blob/main/finetune_falcon7b_oasst1_with_bnb_peft.ipynb

full stack:

Traceback (most recent call last):
  File "/home/llama/train_infer/finetune_falcon7b_oasst1_with_bnb_peft.py", line 204, in <module>
    trainer.train()
  File "/home/.conda/envs/3.9/lib/python3.9/site-packages/transformers/trainer.py", line 1638, in train
    return inner_training_loop(
  File "/home/.conda/envs/3.9/lib/python3.9/site-packages/accelerate/utils/memory.py", line 132, in decorator
    return function(batch_size, *args, **kwargs)
  File "/home/.conda/envs/3.9/lib/python3.9/site-packages/transformers/trainer.py", line 1972, in _inner_training_loop
    self.accelerator.clip_grad_norm_(
  File "/home/.conda/envs/3.9/lib/python3.9/site-packages/accelerate/accelerator.py", line 1892, in clip_grad_norm_
    self.unscale_gradients()
  File "/home/.conda/envs/3.9/lib/python3.9/site-packages/accelerate/accelerator.py", line 1855, in unscale_gradients
    self.scaler.unscale_(opt)
  File "/home/.conda/envs/3.9/lib/python3.9/site-packages/torch/cuda/amp/grad_scaler.py", line 275, in unscale_
    raise RuntimeError("unscale_() has already been called on this optimizer since the last update().")
RuntimeError: unscale_() has already been called on this optimizer since the last update().

refs #23914, I had upgraded the transformers to the latest commit.

  • transformers version: 4.30.0.dev0
  • Platform: Linux-5.15.0-73-generic-x86_64-with-glibc2.31
  • Python version: 3.9.16
  • Safetensors version: 0.3.1
  • PyTorch version (GPU): 2.0.1+cu117 (True)
  • peft version: 0.4.0.dev0
  • accelerate version: 0.20.0.dev0
  • bitsandbytes version: 0.39.0

How to slove it?

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