-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[feature]:Add adaptation of all models to zero3 #1231
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Feng0w0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the training capabilities by integrating DeepSpeed Zero3 across various model architectures. The changes aim to optimize memory usage and training efficiency, especially for large models and NPU environments, while meticulously preserving model accuracy. It provides the necessary infrastructure, including configuration files and training scripts, to leverage these advanced optimization techniques. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces significant changes to adapt the models for DeepSpeed Zero3 training, particularly for NPU environments. Key updates include modifications to gradient checkpointing, a new model initialization context for Zero3, and adjusted state dictionary loading. The changes also involve updating several forward methods in wan_video_vae.py to correctly handle feature caching, and adding new configuration files and training scripts for NPU. Overall, the changes align with the goal of enabling Zero3 for various models.
|
|
||
| # Forward pass through the model | ||
| with torch.inference_mode(): | ||
| with torch.no_grad(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from torch.inference_mode() to torch.no_grad() might have minor performance implications during inference. torch.inference_mode() is generally preferred for inference tasks as it can offer better performance by disabling more autograd-related features than torch.no_grad(). While torch.no_grad() is functionally correct for disabling gradient computation, inference_mode is specifically optimized for inference workflows.
| with torch.no_grad(): | |
| with torch.inference_mode(): |
1.Based on the current hot models of the five major series, zero 3 is adapted and aligned with zero 2 for accuracy, with a loss error within 0.001.
2.Add a zero 3 YAML file for each series of models.
3.Add some training script files using zero3 on NPU.