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 warmup lr when using deepspeed #2125

Closed
wants to merge 1 commit into from
Closed

fix warmup lr when using deepspeed #2125

wants to merge 1 commit into from

Conversation

Eikor
Copy link

@Eikor Eikor commented Nov 6, 2023

What does this PR do?

Fixes #2124
Current DeepSpeedEngineWrapper.backwards() calls DeepSpeedEngine._take_model_step(), which performs optimizer step first, followed by lr_scheduler step.

self.engine.step()

However, the DS optimizer will be initialized with the maximum learning rate in the prepare function, the optimizer will update model parameters with the maximum learning rate at the first step, which will cause an unexpected behavior.

engine, optimizer, _, lr_scheduler = deepspeed.initialize(**kwargs)

This PR solves this problem by initializing the optimizer with warmup_min_lr if the warmup lr scheduler is activated.

@pacman100

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@muellerzr
Copy link
Collaborator

@Eikor can you please do pip install -e .[quality]; make style; make quality? This should fix the failing test, thanks!

@pacman100
Copy link
Contributor

I don't think this should be the case. Let me deep dive into this.

Copy link

github-actions bot commented Dec 6, 2023

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot closed this Dec 14, 2023
@mjbommar
Copy link

mjbommar commented Jan 7, 2024

Was there a reason this was never merged, @pacman100 and @muellerzr?

Pretty sure it's still happening on 4.36.2/0.25.0:

10.19.136.148: {'loss': 10.375, 'learning_rate': 1e-07, 'epoch': 0.0}                                                                                                                        
10.19.140.225: {'loss': 10.375, 'learning_rate': 1e-07, 'epoch': 0.0}                                                                                                                        
10.19.140.13: {'loss': 10.375, 'learning_rate': 1e-07, 'epoch': 0.0}                                                                                                                         
10.19.139.205: {'loss': 10.375, 'learning_rate': 1e-07, 'epoch': 0.0}                         
10.19.138.33: {'loss': 10.375, 'learning_rate': 1e-07, 'epoch': 0.0}                                                                                                                         
10.19.136.148: {'loss': 10.375, 'learning_rate': 3.772122370810605e-05, 'epoch': 0.0}                                                                                                        
10.19.140.225: {'loss': 10.375, 'learning_rate': 3.772122370810605e-05, 'epoch': 0.0}                                                                                                        
10.19.139.205: {'loss': 10.375, 'learning_rate': 3.772122370810605e-05, 'epoch': 0.0}                                                                                                        
10.19.140.13: {'loss': 10.375, 'learning_rate': 3.772122370810605e-05, 'epoch': 0.0}                                                                                                         
10.19.138.33: {'loss': 10.375, 'learning_rate': 3.772122370810605e-05, 'epoch': 0.0}                                                                                                         
10.19.140.225: {'loss': 10.375, 'learning_rate': 5.972822880858981e-05, 'epoch': 0.0}                                                                                                        
10.19.140.13: {'loss': 10.375, 'learning_rate': 5.972822880858981e-05, 'epoch': 0.0}                                                                                                         
10.19.139.205: {'loss': 10.375, 'learning_rate': 5.972822880858981e-05, 'epoch': 0.0}                                                                                                        
10.19.136.148: {'loss': 10.375, 'learning_rate': 5.972822880858981e-05, 'epoch': 0.0}                                                                                                        
10.19.138.33: {'loss': 10.375, 'learning_rate': 5.972822880858981e-05, 'epoch': 0.0}                                                                                                         
10.19.136.148: {'loss': 10.0375, 'learning_rate': 7.53424474162121e-05, 'epoch': 0.0}                                                                                                        
10.19.140.225: {'loss': 10.0375, 'learning_rate': 7.53424474162121e-05, 'epoch': 0.0}                                                                                                        
10.19.140.13: {'loss': 10.0375, 'learning_rate': 7.53424474162121e-05, 'epoch': 0.0}                                                                                                         
10.19.139.205: {'loss': 10.0375, 'learning_rate': 7.53424474162121e-05, 'epoch': 0.0}                                                                                                        
10.19.138.33: {'loss': 10.0375, 'learning_rate': 7.53424474162121e-05, 'epoch': 0.0}                                                                                                         
10.19.140.225: {'loss': 9.9891, 'learning_rate': 8.745377629189394e-05, 'epoch': 0.0}                                                                                                        
10.19.136.148: {'loss': 9.9891, 'learning_rate': 8.745377629189394e-05, 'epoch': 0.0}                                                                                                        
10.19.140.13: {'loss': 9.9891, 'learning_rate': 8.745377629189394e-05, 'epoch': 0.0}                                                                                                         
10.19.139.205: {'loss': 9.9891, 'learning_rate': 8.745377629189394e-05, 'epoch': 0.0}                                                                                                        
10.19.138.33: {'loss': 9.9891, 'learning_rate': 8.745377629189394e-05, 'epoch': 0.0}                                                                                                         
10.19.139.205: {'loss': 9.875, 'learning_rate': 9.734945251669586e-05, 'epoch': 0.0}                                                                                                         
10.19.136.148: {'loss': 9.875, 'learning_rate': 9.734945251669586e-05, 'epoch': 0.0}                                                                                                         
10.19.140.225: {'loss': 9.875, 'learning_rate': 9.734945251669586e-05, 'epoch': 0.0}                                                                                                         
10.19.140.13: {'loss': 9.875, 'learning_rate': 9.734945251669586e-05, 'epoch': 0.0}                                                                                                          
10.19.138.33: {'loss': 9.875, 'learning_rate': 9.734945251669586e-05, 'epoch': 0.0}                                                                                                          
10.19.136.148: {'loss': 9.8125, 'learning_rate': 0.00010571612755078175, 'epoch': 0.0}                                                                                                       
10.19.140.225: {'loss': 9.8125, 'learning_rate': 0.00010571612755078175, 'epoch': 0.0}                                                                                                       
10.19.140.13: {'loss': 9.8125, 'learning_rate': 0.00010571612755078175, 'epoch': 0.0}                                                                                                        
10.19.139.205: {'loss': 9.8125, 'learning_rate': 0.00010571612755078175, 'epoch': 0.0}                                                                                                       
10.19.138.33: {'loss': 9.8125, 'learning_rate': 0.00010571612755078175, 'epoch': 0.0}                                                                                                        
10.19.136.148: {'loss': 9.6984, 'learning_rate': 0.00011296367112431813, 'epoch': 0.0}                                                                                                       
10.19.140.225: {'loss': 9.6984, 'learning_rate': 0.00011296367112431813, 'epoch': 0.0}                                                                                                       
10.19.140.13: {'loss': 9.6984, 'learning_rate': 0.00011296367112431813, 'epoch': 0.0}                                                                                                        
10.19.139.205: {'loss': 9.6984, 'learning_rate': 0.00011296367112431813, 'epoch': 0.0}                                                                                                       
10.19.138.33: {'loss': 9.6984, 'learning_rate': 0.00011296367112431813, 'epoch': 0.0}                                                                                                        
10.19.140.225: {'loss': 9.5625, 'learning_rate': 0.00011935645761717962, 'epoch': 0.0}                                                                                                       
10.19.139.205: {'loss': 9.5625, 'learning_rate': 0.00011935645761717962, 'epoch': 0.0}                                                                                                       
10.19.140.13: {'loss': 9.5625, 'learning_rate': 0.00011935645761717962, 'epoch': 0.0}
10.19.136.148: {'loss': 9.5625, 'learning_rate': 0.00011935645761717962, 'epoch': 0.0}
10.19.138.33: {'loss': 9.5625, 'learning_rate': 0.00011935645761717962, 'epoch': 0.0}

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.

The warmup lr schedule are not working as expected when using Deepspeed.
5 participants