Bc-breaking update to torch.utils.checkpoint: not passing in use_reentrant flag will raise an error

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 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 for a more detailed comparison between these two options.

UPDATE: we are postponing this update until version 2.4 to make the transition smoother. #115868 is being reverted by #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.
1 Like

FYI you can use TorchFix to automate fixing calls to torch.utils.checkpoint without use_reentrant in your codebase (as well as many other issues).

1 Like