Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Conversation

@guopengf
Copy link
Contributor

#410 support ConvTranspose to avoid F.interpolate limitation and activation checkpointing to save memeory.

@guopengf guopengf linked an issue Jul 27, 2023 that may be closed by this pull request
@guopengf guopengf marked this pull request as ready for review August 3, 2023 15:31
Copy link
Collaborator

@marksgraham marksgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @guopengf

This looks good to me - thanks for adding. Do you think it would be possible to also implement the checkpointing in the VQ-VAE so we can maintain a consistent interface between the two?

@guopengf
Copy link
Contributor Author

Hi @marksgraham

I think enabling checkpointing in the VQ-VAE is a good point. I implemented it and added corresponding tests.

However, it is worth noting that currently, TorchScript does not support activation checkpointing. It will trigger the following NotSupportedError error:
torch.jit.frontend.NotSupportedError: Compiled functions can't take variable number of arguments or use keyword-only arguments with defaults: def checkpoint(function, *args, use_reentrant: bool = True, **kwargs): ~~~~~~~ <--- HERE r"""Checkpoint a model or part of the model 'VQVAE.encode' is being compiled since it was called from 'VQVAE.forward' File "/home/pengfeig/code/GenerativeModels/generative/networks/nets/vqvae.py", line 440 def forward(self, images: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: quantizations, quantization_losses = self.quantize(self.encode(images)) ~~~~~~~~~~~~~~~~~~ <--- HERE reconstruction = self.decode(quantizations)
So I removed TorchScript test case here.

I think for a similar reason, Walter removed TorchScript test case to support xformers package in AutoencoderKL.

# def test_script(self):

@guopengf guopengf requested a review from marksgraham August 10, 2023 17:15
@marksgraham marksgraham merged commit 4547ca4 into main Aug 11, 2023
@marksgraham marksgraham deleted the 410-add-ae-convtranspose-checkpoint branch December 21, 2023 09:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible Improvements for Current Repository

3 participants