Add GreedyLR adaptive learning rate scheduler#44271
Add GreedyLR adaptive learning rate scheduler#44271Rocketknight1 merged 2 commits intohuggingface:mainfrom
Conversation
dcd2311 to
1d70c35
Compare
|
@Rocketknight1 could you provide specific feedback on what led to closing this? I'd like to address any concerns. For context: I'm one of the authors of this paper from our team at AWS (https://arxiv.org/abs/2512.14527). GreedyLR is a new adaptive LR scheduler that adjusts the learning rate during training based on the current loss. We validated it across NLP, CV, and LLM tasks up to 7B parameters, showing faster convergence without performance loss for both fine-tuning and pre-training. The implementation follows the existing ReduceLROnPlateau integration pattern, includes 30 unit tests, and has been E2E tested on single and multi-GPU setups on AWS. All CI checks pass. Happy to address any specific feedback or make changes to better fit the library's conventions. cc: @w601sxs @pranavvm26 (co-authors) |
|
Hi @balak4, I'm sorry! We've been getting swamped with code agent PRs lately, and so we've been trying to filter out code agent PRs from first-time contributors because a lot of them are low-quality spam and our reviewer time is too limited to read them all in detail. In this case the PR was more legitimate than I realized at first - I'll reopen it. Sorry for the inconvenience! |
@Rocketknight1 Gotcha, I understand, thanks for re-opening. Please let me know if you have any questions / need clarification. We're eager to share this work with the community! |
|
Hey @Rocketknight1 , checking in since it's been 2 weeks since we submitted this PR - any update on when the PR could be reviewed? |
|
Ah, sorry! I should have pinged a reviewer when I reopened it. cc @SunMarc! |
| # GreedyLR: Adaptive Learning Rate Scheduler | ||
|
|
||
| GreedyLR monitors training metrics and adaptively adjusts the learning rate -- increasing when improving, decreasing when plateauing. It works for both pre-training and fine-tuning. | ||
|
|
||
| ## Paper | ||
|
|
||
| > **GreedyLR: A Novel Adaptive Learning Rate Scheduler** | ||
| > | ||
| > Despite significant advances in optimizers for training, most research works use common scheduler choices like Cosine or exponential decay. In this paper, we study GreedyLR, a novel scheduler that adaptively adjusts the learning rate during training based on the current loss. To validate the effectiveness of our proposed scheduler, we conduct experiments on several NLP, CV, and LLM tasks with up to 7B parameters, including both fine-tuning and pretraining experiments. The results show that our approach outperforms several state-of-the-art schedulers in terms of accuracy, speed, and convergence. | ||
|
|
There was a problem hiding this comment.
maybe create a new folder called examples/scheduler and put that there ? It will be better ! Also, maybe it will be interesting to have a section for scheduler in trainer docs cc @stevhliu
examples/greedy-lr/.gitignore
Outdated
| CLAUDE.md | ||
| archive/ |
| # Copyright 2026 The HuggingFace Team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import unittest | ||
|
|
||
| from transformers import is_torch_available | ||
| from transformers.testing_utils import require_torch | ||
|
|
There was a problem hiding this comment.
add some trainer tests also to make sure the integration is correctly done. You need to update the test_trainer_optimizers.py file
@SunMarc thanks for the feedback! Will get these addressed |
Add GreedyLR, a metric-based scheduler that increases LR on improvement and decreases on plateau, based on arxiv.org/abs/2512.14527. - Add GreedyLR class and get_greedy_schedule() to optimization.py - Add StreamingAverage helper for metric smoothing - Integrate with Trainer via ReduceLROnPlateau-style metric stepping - Add GREEDY to SchedulerType enum and TrainingArguments validation - Add comprehensive tests in tests/optimization/test_greedy_lr.py - Add example script and documentation
…ler, delete .gitignore, add trainer integration tests
cadcd23 to
4e608f1
Compare
|
@SunMarc comments addressed. Please review and let me know if there's anything else you'd like updated. cc: @Rocketknight1 |
|
@SunMarc @Rocketknight1 hope you're well, just a friendly follow-up. Are we good to get this PR merged now that the comments are addressed? |
SunMarc
left a comment
There was a problem hiding this comment.
Thanks a lot ! Sorry for the delay
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Summary
Changes
optimization.py: AddGreedyLRclass,StreamingAveragehelper, andget_greedy_schedule()factorytrainer.py: Add GreedyLR alongside ReduceLROnPlateau for metric-based scheduler steppingtraining_args.py: Add validation requiring eval strategy for greedy schedulertrainer_utils.py: AddGREEDYtoSchedulerTypeenum__init__.py: ExportGreedyLRandget_greedy_scheduletests/optimization/test_greedy_lr.py: Comprehensive test suite (30 tests)docs/source/en/main_classes/optimizer_schedules.md: Autodoc entriesexamples/greedy-lr/: Example script and documentationHow it works
GreedyLR adaptively adjusts the learning rate during training based on the current loss:
Usage
Test plan
pytest tests/optimization/test_greedy_lr.py— 30/30 passpytest tests/optimization/test_optimization.py— 4/4 pass (no regressions)make check-repo— no new errors introducedfrom transformers import GreedyLR, get_greedy_scheduleworks