Skip to content

[FSDP] Support lr scheduler#1040

Merged
zhuzilin merged 12 commits intoTHUDM:mainfrom
ChangyiYang:main
Dec 7, 2025
Merged

[FSDP] Support lr scheduler#1040
zhuzilin merged 12 commits intoTHUDM:mainfrom
ChangyiYang:main

Conversation

@ChangyiYang
Copy link
Contributor

@ChangyiYang ChangyiYang commented Dec 5, 2025

PR Description

[FSDP] Support LR scheduler

Implement FSDPLRScheduler for FSDP backend to align with Megatron-LM's learning rate scheduling behavior.

Key Changes

  • Add FSDPLRScheduler class inheriting from PyTorch LRScheduler
  • Support warmup, decay, and weight decay scheduling (linear, cosine, etc.)
  • Update actor logging and checkpoint functionality

Related issue #962

Reference

Based on Megatron-LM OptimizerParamScheduler

This ensures consistent LR scheduling behavior between FSDP and Megatron backends.

Example

image

Load and Save Test
image

AI Assistant and others added 8 commits December 5, 2025 19:57
- Modify FSDPLRScheduler.get_lr() to accept param_group parameter like Megatron
- Update FSDP actor logging to use lr_scheduler.get_lr(group) instead of group['lr']
- Ensure consistent LR logging behavior between FSDP and Megatron backends
- Update step() method to call get_lr(param_group) for each param_group individually
- Allow different param_groups to have different learning rates based on their max_lr/min_lr settings
- Previously all param_groups got the same LR regardless of their individual settings
- Fix lr_scheduler.step() call in actor.py to use standard PyTorch interface
- Ensure proper inheritance from torch.optim.lr_scheduler.LRScheduler
- Verify get_lr() returns list[float] as required by PyTorch standard
- Confirm state_dict/load_state_dict compatibility
@ChangyiYang
Copy link
Contributor Author

@PopSoda2002 Hi! I think this pr is ready for review

@Hecate0821
Copy link
Collaborator

LGTM

AI Assistant and others added 3 commits December 6, 2025 15:57
@zhuzilin zhuzilin merged commit 41b5932 into THUDM:main Dec 7, 2025
Fengzdadi pushed a commit to Fengzdadi/slime that referenced this pull request Dec 19, 2025
Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: andy <andy271828@163.com>
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.

3 participants