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

Question on Memory Optimization in PR #75 #150

Closed
wladradchenko opened this issue Nov 2, 2024 · 3 comments
Closed

Question on Memory Optimization in PR #75 #150

wladradchenko opened this issue Nov 2, 2024 · 3 comments

Comments

@wladradchenko
Copy link

Hi! I have a question about the memory optimization introduced in PR #75. Specifically, I’m curious about how the approach reduces the required video memory during generation.

I’ve encountered a method where different layers of large models are assigned to various devices in one machine (not cluster) to manage memory:

device_map = {
    'encoder.layer.0': 'cuda:0',
    'encoder.layer.1': 'cuda:1',
    'decoder.layer.0': 'cuda:0',
    'decoder.layer.1': 'cuda:1',
}

This kind of device mapping allows loading on both GPUs and CPUs (for example change cuda:1 on cpu). Is the optimization in this PR based on a similar concept, or is there a different mechanism at work here?

Thanks in advance for any insights!

@feifeiobama
Copy link
Collaborator

The underlying mechanism is indeed similar, CPU offloading manually moves unused modules to the CPU device and keeps the currently used module on the GPU.

@wladradchenko
Copy link
Author

@jy0205 @feifeiobama Thank you. Got it. I have another question about the approach. As I understand, it is possible to generate video from text or image, and the approach is based on Stable Diffusion 3. But, is it possible to generate video with this approach based on the first and last frame? If it is not possible in the current repository, does the approach itself have such capabilities or is this an insurmountable limitation?

@feifeiobama
Copy link
Collaborator

I think this limitation comes from our MAGVIT2-like VAE. Since it explicitly encodes only the first frame, it is much easier to do conditioning on the first frame than on both the first and last frames. Of course, this can be overcome with architectural changes, such as adding a conditioning branch for the last frame.

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

No branches or pull requests

2 participants