Skip to content

(issue #67) make early_stopping optional; cpu default device for trainer, evaluator - #68

Merged
ChrisNick92 merged 1 commit into
mainfrom
67-make-early-stopping-optional-and-add-current-patience-on-trainers-state
May 8, 2026
Merged

(issue #67) make early_stopping optional; cpu default device for trainer, evaluator#68
ChrisNick92 merged 1 commit into
mainfrom
67-make-early-stopping-optional-and-add-current-patience-on-trainers-state

Conversation

@ChrisNick92

Copy link
Copy Markdown
Collaborator

Make Early Stopping Optional & Add current_patience to Trainer State

Overview

Early stopping is now opt-in rather than always active, current_patience is exposed on trainer.state for runtime introspection, and the default device for Trainer and Evaluator is changed to "cpu" to avoid errors on machines without a GPU.

Changes

Early Stopping — opt-in

  • patience now defaults to None (previously 15). When None, EarlyStopper is not added to the callback list and training always runs for the full number of epochs.
  • EarlyStopper is only instantiated when patience is explicitly set.
  • Callback list typed as list[BaseCallback] to correctly accommodate both Checkpointer and EarlyStopper.

current_patience on State

  • State.current_patience: int = 0 added — updated by EarlyStopper after each epoch, allowing callers to monitor patience consumption via trainer.state.current_patience.

Default device changed to "cpu"

  • Trainer, Evaluator, and get_device now default to device="cpu". Previously defaulting to "cuda" caused an immediate ValueError on CPU-only machines before any training could start.
  • get_device error messages updated to suggest the correct alternative device.

@ChrisNick92
ChrisNick92 merged commit e501038 into main May 8, 2026
9 checks passed
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.

make early stopping optional and add current patience on trainer's state

2 participants