transformers
[`gradient_checkpointing`] default to use it for torch 2.3
#28538
Merged

[`gradient_checkpointing`] default to use it for torch 2.3 #28538

ArthurZucker merged 4 commits into main from use-rentrant
ArthurZucker
ArthurZucker1 year ago

What does this PR do?

Fixes #28536 in preparation for next torch release

ArthurZucker default to use it
b6f6d11f
ArthurZucker ArthurZucker changed the title default to use it [`gradient_checkpointing`] default to use it for torch 2.3 1 year ago
younesbelkada
younesbelkada approved these changes on 2024-01-17
younesbelkada1 year ago

Makes sense!

hiyouga
hiyouga1 year ago

Why do we use reentrant gc by default? It said the non-reentrant gc can be more advantageous than the reentrant version: https://pytorch.org/docs/2.0/checkpoint.html#torch.utils.checkpoint.checkpoint

younesbelkada
younesbelkada1 year ago👍 1

@hiyouga the use_reentrant=True is used by default in PT anyway so if you set it to None, use_reentrant will be set to True

ArthurZucker Merge branch 'main' into use-rentrant
49aaf6ec
github-actions
github-actions1 year ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

ArthurZucker ArthurZucker marked this pull request as ready for review 1 year ago
ArthurZucker style
6592f39e
HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev1 year ago

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

ArthurZucker Merge branch 'main' of github.com:huggingface/transformers into use-r…
6986b541
ArthurZucker ArthurZucker merged 9094abe8 into main 1 year ago
ArthurZucker ArthurZucker deleted the use-rentrant branch 1 year ago
lucasjinreal
lucasjinreal1 year ago

I upgrade transformers to latest, still got this warning, and this warning is logged every single step

s/env-3.9.2/lib/python3.9/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/data/miniconda3/envs/env-3.9.2/lib/python3.9/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
/data/miniconda3/envs/env-3.9.2/lib/python3.9/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/data/miniconda3/envs/env-3.9.2/lib/python3.9/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
/data/miniconda3/envs/env-3.9.2/lib/python3.9/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/data/miniconda3/envs/env-3.9.2/lib/python3.9/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(

how to disable it?

ArthurZucker
ArthurZucker1 year ago

Can you open a new issue with a proper reproducer ?

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone