Skip to content

Resume training from a checkpoint or an MLflow run - #6

Merged
leifdenby merged 1 commit into
dev/dmi-convgru-trainingfrom
feat/resume-from-mlflow
Oct 18, 2026
Merged

leifdenby merged 1 commit into
dev/dmi-convgru-trainingfrom
feat/resume-from-mlflow

Conversation

@leifdenby

Copy link
Copy Markdown

Lets a run be continued instead of restarted, e.g. to train the DMI ConvGRU run intrigued-sow-455 beyond its 22 h.

What it adds

  • Experiment.ckpt_path, passed to Trainer.fit(ckpt_path=...) (Lightning 2.x has no Trainer-level resume argument). Restores weights, optimizer, LR scheduler, step counter and the max_time timer, so max_time is the total budget.
  • resume_training fiddler (ckpt_path, optional mlflow_run_id): sets the above; with a run id the MLflow logger keeps logging into that run, so the metric curves continue.
  • mlcast train --config mlflow:<run>: accepts a run id, runs:/<id> or the run URL from the MLflow UI (which also gives the tracking server). Downloads the run's config/*.yaml and its latest checkpoint (highest step=N) into .mlcast-resume/<run_id>/, seeds the config from the YAML and applies resume_training; your set:/fiddler: overrides apply on top.
  • Checkpoint upload: use_mlflow_logger now sets log_model="all", so every checkpoint is uploaded to the run as it is saved (~770 MB each for the 5-block ConvGRU) and runs can be resumed from any machine. For runs from before this, the local <experiment_id>/<run_id>/checkpoints is used.
  • The config artifact is now config/config.yaml (it was a random temp-file name, although the log message already said config/config.yaml), so a resumed run replaces it instead of adding a second YAML.

Example

mlcast train \
    --config mlflow:https://mlflow.dmidev.org/#/experiments/114/runs/52dd4f17fad94d2eb0ac8489c234f6c2 \
    --config 'set:trainer.max_time="03:00:00:00"'

Testing

  • tests/config/test_mlflow_resume.py (22 tests): run-reference parsing, latest-checkpoint choice from artifacts and the local fallback, reuse of an existing download, the fiddler, Experiment.run passing ckpt_path, CLI token extraction. Full suite: 169 passed, 5 skipped.
  • End to end against a local MLflow file store: trained 20 steps, then --config mlflow:<run> with max_epochs=2 downloaded the step-20 checkpoint, Lightning restored all states, and training continued to step 40 in the same MLflow run, uploading the new checkpoint.
  • docs/config_diagram.svg is unchanged: regenerating it locally gives the same labels; only the local Graphviz (12.2.1 vs CI's 2.43.0) renders differently, so that hook was skipped for the commit.

🤖 Generated with Claude Code

- Experiment.ckpt_path is passed to Trainer.fit; the resume_training
  fiddler sets it, restoring the full training state (max_time is then the
  total budget), and optionally keeps logging into an existing MLflow run.
- mlcast train --config mlflow:<run id, runs:/<id> or run URL> downloads
  the run's config and latest checkpoint (highest step=N) and resumes it;
  set:/fiddler: overrides still apply on top. Falls back to the local
  <experiment_id>/<run_id>/checkpoints for runs without uploaded checkpoints.
- use_mlflow_logger uploads every checkpoint to the run (log_model='all').
- The config artifact is now config/config.yaml rather than a temp name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leifdenby
leifdenby requested a review from arjj8 October 18, 2026 19:14
@leifdenby
leifdenby merged commit e3db35e into dev/dmi-convgru-training Oct 18, 2026
5 checks passed
leifdenby added a commit that referenced this pull request Oct 19, 2026
Uploading every checkpoint (log_model='all', added in #6) crashed a
continuation of the DMI ConvGRU run at its first validation:
mlflow.dmidev.org cut the connection on the ~770 MB upload (SSLEOFError,
7 retries over ~9 min) and Lightning's MLFlowLogger let the error stop
training.

- use_mlflow_logger(upload_checkpoints=False): upload is now opt-in.
- ResilientMLFlowLogger turns a failed checkpoint upload into a warning
  and marks the checkpoint as handled so later saves don't retry it. Used
  by use_mlflow_logger, and resume_training switches configs saved with
  plain MLFlowLogger (e.g. log_model='all' from #6-era runs) over to it.
- resume_training no longer forces log_model='all'.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant