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

Updated "checkpoint" to use "self.use_checkpoint" flag #144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gauenk
Copy link

@gauenk gauenk commented Apr 16, 2024

I want to use the gradient in a loss function, so I do not want to use "checkpoint" since I will use the backward pass twice. This code change simply makes the "use_checkpoint" flag turn off the checkpointing, if requested.

I want to use the gradient in a loss function, so I do not want to use "checkpoint" since I will use the backward pass twice. This code change simply makes the "use_checkpoint" flag turn off the checkpointing, if requested.
@francois-rozet
Copy link

francois-rozet commented Aug 20, 2024

I have the same issue. The checkpoint function does not support several backward passes with retain_graph=True. I cannot disable checkpoint because the Attention module does not use its use_checkpoint flag.

My current solution is to monkey patch checkpoint:

from guided_diffusion import unet

def monkey_checkpoint(func, inputs, params, flag):
    return func(*inputs)

unet.checkpoint = monkey_checkpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants