Skip to content

feat(handlers): rename EarlyStopping params for consistency with PyTorch#3739

Closed
joemunene-by wants to merge 1 commit intopytorch:masterfrom
joemunene-by:feat/early-stopping-param-rename
Closed

feat(handlers): rename EarlyStopping params for consistency with PyTorch#3739
joemunene-by wants to merge 1 commit intopytorch:masterfrom
joemunene-by:feat/early-stopping-param-rename

Conversation

@joemunene-by
Copy link
Copy Markdown

Summary

Addresses the remaining work in #3411 — renames EarlyStopping parameters to align with PyTorch's ReduceLROnPlateau naming conventions, with full backward compatibility and deprecation warnings.

Parameter Renames

Old Name New Name Rationale
min_delta threshold Matches ReduceLROnPlateau.threshold
min_delta_mode threshold_mode Matches ReduceLROnPlateau.threshold_mode
cumulative_delta cumulative Shorter, clearer

Backward Compatibility

  • Old parameter names still work — they emit a DeprecationWarning and forward the value to the new name
  • If both old and new names are passed simultaneously, a ValueError is raised with a clear message
  • All existing code using old names will continue to work without changes

Changes

ignite/handlers/early_stopping.py

  • Added new parameter names as primary, old names kept as deprecated Optional kwargs
  • warnings.warn() with DeprecationWarning for each old name
  • ValueError on conflict (both old + new specified)
  • Internal attributes and __call__ use new names
  • Updated docstrings with versionchanged:: 0.5.5 note

tests/ignite/handlers/test_early_stopping.py

  • Updated existing tests to use new parameter names
  • Added 8 new test cases:
    • test_args_validation_deprecated_names — validation through deprecated params
    • test_deprecated_min_delta — DeprecationWarning + value forwarding
    • test_deprecated_cumulative_delta — same for cumulative_delta
    • test_deprecated_min_delta_mode — same for min_delta_mode
    • test_deprecated_and_new_param_conflict — ValueError when both passed
    • test_backward_compat_deprecated_params_still_work — end-to-end with old names
    • test_backward_compat_cumulative_delta — end-to-end with deprecated cumulative
    • test_backward_compat_min_delta_mode — end-to-end with deprecated threshold_mode

Test Plan

  • All 28 non-distributed EarlyStopping tests pass
  • Old parameter names emit DeprecationWarning
  • New parameter names work correctly
  • Conflict detection works (ValueError)
  • No regression in existing behavior

Rename parameters to align with PyTorch's ReduceLROnPlateau naming:
- min_delta -> threshold
- min_delta_mode -> threshold_mode
- cumulative_delta -> cumulative

Old parameter names are preserved as deprecated aliases with
DeprecationWarning. Passing both old and new names simultaneously
raises ValueError. All existing behavior is maintained for backward
compatibility.
@github-actions github-actions Bot added the module: handlers Core Handlers module label Apr 15, 2026
@joemunene-by
Copy link
Copy Markdown
Author

Thanks for letting me know @ramyars466! I can see your PR #3619 already covers this — glad it's approved and ready to go. Closing this one in favor of yours.

@ramyars466
Copy link
Copy Markdown
Contributor

Thank you, @joemunene-by! I really appreciate your understanding and support. Looking forward to seeing your future contributions to the project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: handlers Core Handlers module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants