Skip to content
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

fix checkpoint #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions models/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ def timestep_embedding(timesteps, dim, max_period=10000):
return embedding


def torch_checkpoint(func, args, flag, preserve_rng_state=False):
def torch_checkpoint(func, args, flag, preserve_rng_state=True):
# torch's gradient checkpoint works with automatic mixed precision, given torch >= 1.8
if flag:
return torch.utils.checkpoint.checkpoint(
func, *args, preserve_rng_state=preserve_rng_state)
func, *args,
use_reentrant=True,
preserve_rng_state=preserve_rng_state)
else:
return func(*args)