Skip to content

Exit non-zero when --exit-on-missing-checkpoint triggers - #6321

Draft
shanmugamr1992 wants to merge 1 commit into
NVIDIA:mainfrom
shanmugamr1992:fix/exit-on-missing-checkpoint-nonzero
Draft

Exit non-zero when --exit-on-missing-checkpoint triggers#6321
shanmugamr1992 wants to merge 1 commit into
NVIDIA:mainfrom
shanmugamr1992:fix/exit-on-missing-checkpoint-nonzero

Conversation

@shanmugamr1992

Copy link
Copy Markdown
Contributor

What does this PR do?

When --exit-on-missing-checkpoint is set and no checkpoint is found,
_load_base_checkpoint (in megatron/training/checkpointing.py) called
sys.exit() with no argument, i.e. exit code 0. Callers — notably CI
functional-test harnesses — therefore treat a missing required checkpoint as
a successful run and continue, which produces confusing downstream
failures far from the real cause.

Concrete example: a dynamic-inference functional test whose checkpoint is not
staged in the CI artifacts tree exits cleanly (code 0) before generating
anything, never writes its INFERENCE_OUTPUT_PATH, and then fails only at the
golden-value comparison step with an opaque
FileNotFoundError: .../golden_values_dev_dgx_h100.json — giving no hint that
the checkpoint was the problem.

This PR makes the missing-checkpoint path fail loudly at its source:

  • Exit with a non-zero status (sys.exit(1)) so callers/CI detect the
    failure instead of silently treating exit code 0 as success.
  • Print a descriptive message naming the --load directory and the missing
    metadata/tracker file.

Behavior change

--exit-on-missing-checkpoint with a missing checkpoint now returns a non-zero
exit code (previously 0). This flag is only meant to guard "this checkpoint is
required; stop if it's absent," so surfacing it as a failure is the intended
semantics and is consistent across its callers (inference examples, text
generation server, checkpoint converter).

Test plan

  • Run any inference functional test with a --load path that does not
    exist and confirm the job exits non-zero with the new message, instead of
    exiting 0 and later failing on a missing golden/output file.
  • Confirm normal runs (checkpoint present) are unaffected.

🤖 Generated with Claude Code

When `--exit-on-missing-checkpoint` is set and no checkpoint is found,
`_load_base_checkpoint` called `sys.exit()`, which returns exit code 0.
CI harnesses and other callers therefore treat the missing checkpoint as a
successful run and continue, producing confusing downstream failures (e.g. an
inference functional test that never writes its output and later fails with a
FileNotFoundError on the golden-value comparison step).

Exit with a non-zero status and a descriptive message that names the load
directory and the missing tracker file, so a missing required checkpoint is
surfaced clearly as a failure at its source.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: shanmugamr1992 <shanmugamr@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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.

2 participants