Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
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.
Why
Trainer appends the configured loss to the default validation metric suite. When that exact metric type is already present, both results accumulate under the same output key. On two trajectories with amplitudes 1 and 3, zero predictions give training RMSE
2and validation RMSE4. A configured RMSE instance whose forward hook multiplies the result by 3 gives training loss6and validation loss8.What changed
Let the configured instance own its exact metric type in each Trainer's suite. Retain the other metric types and leave the shared default list unchanged. MSE, custom subclasses and partial callables retain their existing paths.
Also preserve best-model selection when resuming older checkpoints that used an overlapping loss. Their saved scores combine the default and configured instances, so dividing by 2 would be wrong for the hook example. A version marker distinguishes the single-loss score definition. Affected legacy resumes re-evaluate the actual
best.ptweights once under the current loss and the same full/short validation sample stream before comparing the current model.The calibration skips saved evaluation artifacts and restores the current parameters, registered buffer bindings and values, module modes, RNG, explicit loader generators and DDP synchronization state. It doesn't load the old best's optimizer. Pending checkpoints retain the legacy marker until current validation succeeds. An external best-checkpoint source is preserved when input and output directories differ, and a colocated best remains checkpoint-local so the run directory can move together. New best checkpoints save the selected score as their best threshold. Relative checkpoint paths retain their original source directory for this deferred read.
If a historical best score exists and its weights are missing, training identifies the required
best.ptpath and preserves the existing recovery/evaluation boundary. An early checkpoint with no prior best can continue, and evaluation-only remains available. This stays separate from the scheduler/scaler restoration in #102 and from changes to sampling or the metric formulas.Verification
Could a maintainer approve the Tests run for
691eccb5so the Linux Python 3.10 and 3.13 jobs check validation-loss counting and resumed checkpoints?train_one_epoch, validation and saved curves cover 11 loss configurations, including the default suite types, the configured hook, MSE, a partial with explicit epsilon and custom losses. The original implementation fails five of those configuration checks.2, saved legacy score4and current-model RMSE3. The corrected resume preserves the better model. The hook case checks a non-factor-of-two migration and a genuine improvement.recent.ptor a periodic checkpoint, then restart while preserving the original best. Checkpoints written after successful calibration no longer depend on that old file. Calibration failure preserves the original exception and current training state.Noneinitialization, aliases and persistent inference-mode values. Successful calibration and a current-definition control produce identical subsequent state and artifacts.git diff --checkpass.Execution used CPU, Python 3.11.18 and PyTorch 2.15.0. Affected legacy resumes pay for one extra regular validation and a CPU state snapshot, with no second GPU model. Current-format and unaffected MSE resumes keep their existing path. CUDA RNG restoration, NCCL, minimum PyTorch and the remaining Python/platform matrix remain unrun.
Partially sampled versus full validation, DDP sampler padding, rank-local curves, different loss classes that produce the same key, and arbitrary changes of loss configuration keep their existing behavior.