Skip to content

Torch: allow enable_checkpointing=False in trainer_kwargs - #3359

Open
Thanatos9404 wants to merge 1 commit into
awslabs:devfrom
Thanatos9404:fix/enable-checkpointing-false
Open

Thanatos9404 wants to merge 1 commit into
awslabs:devfrom
Thanatos9404:fix/enable-checkpointing-false

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 19, 2026 •

Copy link
Copy Markdown

Issue #, if available: #3203

Description of changes:

PyTorchLightningEstimator.train_model always adds its own ModelCheckpoint, so passing enable_checkpointing=False in trainer_kwargs made Lightning raise a MisconfigurationException. There was no way to train a torch estimator without writing checkpoints, which the reporter needs on a read-only filesystem.

The default checkpoint is now only added when checkpointing is enabled (None, the default, counts as enabled, as in Lightning). Without a checkpoint, the model at the end of training is returned, and if fit fails the original exception is re-raised.

Tests: added test_estimator_trains_with_checkpointing_disabled and test_estimator_reraises_with_checkpointing_disabled to test/torch/model/test_estimators.py. Both fail on dev and pass with this change. test_estimator_loads_best_checkpoint_by_default guards the existing behaviour.

This touches the same try/except in train_model as #3346, so whichever is merged second will have a one-line conflict.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Please tag this pr with at least one of these labels to make our release process faster: bug fix

Fixes #3203

PyTorchLightningEstimator.train_model always added its own
ModelCheckpoint callback, so passing enable_checkpointing=False in
trainer_kwargs made Lightning raise a MisconfigurationException.

Only add the default checkpoint when checkpointing is enabled (Lightning
treats None as enabled). Without it, a failure during fit is re-raised
because there is nothing to recover from, and the last trained model is
returned instead of the best checkpoint.

Fixes awslabs#3203
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.

enable_checkpointing = False results in MisconfigurationException

1 participant