feat: support tuple values in cyclical schedulers#3812
Open
nightcityblade wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Ignite’s cyclical parameter schedulers to support tuple-valued optimizer parameters (e.g., Adam’s betas) by interpolating tuple elements while ensuring the optimizer receives a tuple (not a tensor/list) after each scheduler update.
Changes:
- Added tuple support to
CyclicalSchedulerby validating tuple inputs, interpolating via tensor math internally, and converting scheduled values back to Python tuples on write-back. - Added a regression test covering tuple scheduling on Adam
betas, including running an optimizer step after each update. - Added new validation tests for tuple start/end value consistency (both tuples, same length).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
ignite/handlers/param_scheduler.py |
Enables tuple-valued interpolation in cyclical schedulers and preserves tuple type when setting optimizer param groups. |
tests/ignite/handlers/test_param_scheduler.py |
Adds regression + validation tests to confirm tuple scheduling works and invalid tuple configurations raise expected errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #438
Description:
Allow cyclical schedulers to interpolate tuple-valued optimizer parameters while preserving the tuple type written back to optimizer parameter groups. This enables schedules such as Adam's
betas, including changing beta1 while keeping beta2 fixed. The regression test exercises five scheduled values and runs an Adam optimizer step after each update.Tests:
python -m pytest -q tests/ignite/handlers/test_param_scheduler.py(58 passed, 4 xfailed, 2 xpassed)python -m ruff check ignite/handlers/param_scheduler.py tests/ignite/handlers/test_param_scheduler.pyCheck list: