-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Gradient checkpointing throws use_reentrant warning on PyTorch 2.1 #28536
Comments
Thanks for raising! given that we had #27020, this should be fairly easy to fix! cc @younesbelkada |
@ArthurZucker is this still outstanding? |
Will merge the PR today |
Which version start this fixed? Am using 3.47.2 still get this error. |
4.39.3 till get this warning. |
For my case, |
I'm using transformers==4.43.3, and still getting errors when trying to use the |
Me too.. Try to use |
Could you all share which model you are using? 🤗 |
Hi, I use Llama3 8b. |
Hello, I'm using Llama-2-7b and Mistral-7B-v0.3. Both are giving same warning. |
Are you using a recent version of transformers? By default we do pass this flag: transformers/src/transformers/modeling_utils.py Line 2345 in 834ec7b
so something like |
Thanks it will solve my problem, Since I'm using trainer and I can pass this argument. transformers/src/transformers/modeling_utils.py Line 2362 in 834ec7b
The problem will be solved removing this if https://github.com/huggingface/transformers/blob/main/src/transformers/trainer.py#L2121 |
Yep good catch! Do you want to open a PR for this? 🤗 |
Of course, it would be a pleasure to collaborate. |
System Info
transformers
version: 4.36.2- distributed_type: DEEPSPEED
- mixed_precision: bf16
- use_cpu: False
- debug: False
- num_processes: 8
- machine_rank: 0
- num_machines: 1
- rdzv_backend: static
- same_network: True
- main_training_function: main
- deepspeed_config: {'gradient_accumulation_steps': 1, 'offload_optimizer_device': 'none', 'offload_param_device': 'none', 'zero3_init_flag': True, 'zero3_save_16bit_model': False, 'zero_stage': 3}
- downcast_bf16: no
- tpu_use_cluster: False
- tpu_use_sudo: False
- tpu_env: []
Who can help?
@ArthurZucker @younesbelkada
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Training any text model with gradient checkpointing enabled on PyTorch 2.1 and higher produces this warning:
This can be resolved by manually monkey-patching the model code with
use_reentrant=True
, eg. like so:This is caused by an upstream change in PyTorch:
https://medium.com/pytorch/how-activation-checkpointing-enables-scaling-up-training-deep-learning-models-7a93ae01ff2d
Expected behavior
No warning should be written
The text was updated successfully, but these errors were encountered: