# Bc-breaking update to torch.utils.checkpoint: not passing in use\_reentrant flag will raise an error

**URL:** <https://dev-discuss.pytorch.org/t/bc-breaking-update-to-torch-utils-checkpoint-not-passing-in-use-reentrant-flag-will-raise-an-error/1745>\
**Category:** autodiff\
**Created:** [December 20, 2023, 2:34pm UTC](https://dev-discuss.pytorch.org/t/bc-breaking-update-to-torch-utils-checkpoint-not-passing-in-use-reentrant-flag-will-raise-an-error/1745 "2023-12-20T14:34:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw3468](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jw3468](https://dev-discuss.pytorch.org/u/jw3468)\
**Post date:** [December 20, 2023, 2:34pm UTC](https://dev-discuss.pytorch.org/t/bc-breaking-update-to-torch-utils-checkpoint-not-passing-in-use-reentrant-flag-will-raise-an-error/1745/1 "2023-12-20T14:34:02Z")

</div>

We are preparing to update the default value of the use\_reentrant parameter in torch.utils.checkpoint from True to False. To prevent these changes from silently affecting users, we are implementing the change in the following stages.

Timeline:

- 2.1 (current state) - If use\_reentrant is not explicitly passed, **a warning is raised** (if the flag is not passed, it still defaults to True)

- 2.2 - Behavior unchanged

- 2.3 - If use\_reentrant is not explicitly passed, **an exception will now be raised**

- 2.4 - Remove the requirement to explicitly pass use\_reentrant and **set the default value to False**.

On the main branch after [#115868](https://github.com/pytorch/pytorch/pull/115868) lands and in the 2.3 release, you’ll need to explicitly specify either use\_reentrant=True or use\_reentrant=False when using torch.utils.checkpoint.checkpoint.

To keep the current behavior, you should use use\_reentrant=True. However, we recommend using use\_reentrant=False. You can refer to the [documentation](https://pytorch.org/docs/stable/checkpoint.html#torch.utils.checkpoint.checkpoint) for a more detailed comparison between these two options.

---

<div class="post-metadata">

**Author:** ![jw3468](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jw3468](https://dev-discuss.pytorch.org/u/jw3468)\
**Post date:** [January 5, 2024, 3:00am UTC](https://dev-discuss.pytorch.org/t/bc-breaking-update-to-torch-utils-checkpoint-not-passing-in-use-reentrant-flag-will-raise-an-error/1745/2 "2024-01-05T03:00:52Z")

</div>

UPDATE: we are postponing this update until version 2.4 to make the transition smoother. [#115868](https://github.com/pytorch/pytorch/pull/115868) is being reverted by [#116710](https://github.com/pytorch/pytorch/pull/116710)

Updated timeline:

- 2.1 (current state) - If use\_reentrant is not explicitly passed, **a warning is raised** (if the flag is not passed, it still defaults to True)
- 2.2 - Behavior unchanged
- 2.3 - Behavior unchanged (docs clarified)
- 2.4- If use\_reentrant is not explicitly passed, **an exception will now be raised**
- 2.5 - Remove the requirement to explicitly pass use\_reentrant and **set the default value to False**.

---

<div class="post-metadata">

**Author:** ![kit1980](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/kit1980/32/491_2.png) [@kit1980](https://dev-discuss.pytorch.org/u/kit1980)\
**Post date:** [January 19, 2024, 12:55am UTC](https://dev-discuss.pytorch.org/t/bc-breaking-update-to-torch-utils-checkpoint-not-passing-in-use-reentrant-flag-will-raise-an-error/1745/3 "2024-01-19T00:55:43Z")

</div>

FYI you can use [TorchFix](https://github.com/pytorch-labs/torchfix) to automate fixing calls to `torch.utils.checkpoint` without `use_reentrant` in your codebase (as well as many other issues).
