Skip to content

fix(checkpointing): raise RuntimeError on fatal checkpointing errors - #4927

Open
RexBearIU wants to merge 1 commit into
mainfrom
jackyf/fix-checkpoint-silent-failure
Open

fix(checkpointing): raise RuntimeError on fatal checkpointing errors#4927
RexBearIU wants to merge 1 commit into
mainfrom
jackyf/fix-checkpoint-silent-failure

Conversation

@RexBearIU

@RexBearIU RexBearIU commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Description

When checkpointing encounters an unexpected runtime or I/O failure, _checkpoint_error_handler previously converted the exception into exceptions.StopTraining(...).

In train.py, all StopTraining exceptions are treated as graceful completions (_job_completed_gracefully = True), which causes the Python process to exit with status code 0 (success). This silently masks fatal checkpointing failures from upstream orchestration tools (such as Airflow DAGs, SLURM scripts, and CI runners), causing subsequent pipeline stages (like evaluation or decode) to fail cryptically with missing checkpoint errors.

Fix

  • Updated _checkpoint_error_handler in src/maxtext/common/checkpointing.py to raise RuntimeError(f"Checkpointing failed. {str(err)}") from err directly on unexpected errors.
  • Elasticity signals (JaxRuntimeError, ScaleUpSignalError) continue to be bubbled up upstream via checkpoint_exception_guard.
  • Fatal checkpoint errors now properly cause training to fail loudly with a non-zero exit code and full stack trace attached via from err.
  • Added unit test coverage in tests/unit/checkpointing_test.py to verify RuntimeError raising and exception chaining (__cause__).

Tests

  • Pre-commit linters and formatters:
    • codespell, pylint, pyink, mdformat, yamllint, actionlint (all passed on diff files)
  • Unit test suites:
    • tests/unit/checkpointing_test.py (13 tests passed)

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the checkpoint error handler in checkpointing.py to only raise a StopTraining exception when elastic training is enabled, and otherwise re-raise the original error. The reviewer suggests using elastic_utils.elastic_enabled(config) instead of checking config.elastic_enabled directly to ensure consistency and avoid unexpected behavior when the job is not running in an elastic environment.

Comment thread src/maxtext/common/checkpointing.py Outdated
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@RexBearIU
RexBearIU force-pushed the jackyf/fix-checkpoint-silent-failure branch 3 times, most recently from f1aab5b to 89ff3ee Compare August 19, 2026 07:56
@RexBearIU
RexBearIU force-pushed the jackyf/fix-checkpoint-silent-failure branch from 89ff3ee to 3b59c51 Compare August 21, 2026 08:01
@RexBearIU RexBearIU changed the title fix(checkpointing): re-raise fatal checkpointing errors in non-elastic mode fix(checkpointing): raise RuntimeError on fatal checkpointing errors Aug 21, 2026
Comment thread src/maxtext/common/checkpointing.py Outdated
@RexBearIU
RexBearIU force-pushed the jackyf/fix-checkpoint-silent-failure branch from 3b59c51 to 5089d22 Compare August 21, 2026 08:25
@RexBearIU
RexBearIU force-pushed the jackyf/fix-checkpoint-silent-failure branch from 5089d22 to 3626e0c Compare August 21, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants