[Bug] verify_integrity_manifest hangs non-zero ranks indefinitely when integrity.json raises non-CheckpointingException on rank 0
Summary
In megatron/core/dist_checkpointing/validation.py:590-611 (verify_integrity_manifest, commit 4f13dabb5b66064457af695bcf031b179b53ea00), when torch.distributed.get_world_size() > 1, rank 0 runs _verify_integrity_manifest_impl(checkpoint_dir) inside:
if torch.distributed.get_rank() == 0:
try:
_verify_integrity_manifest_impl(checkpoint_dir)
except CheckpointingException as exc:
error_payload = [str(exc)]
torch.distributed.broadcast_object_list(error_payload, src=0)
However, _verify_integrity_manifest_impl (lines 555-568) calls json.load(f) and indexes manifest_data['files'] without wrapping JSONDecodeError, OSError / PermissionError, KeyError, or TypeError into CheckpointingException.
When integrity.json is truncated, malformed, missing the 'files' key, or unreadable on rank 0, rank 0 unwinds out of verify_integrity_manifest() immediately, bypassing broadcast_object_list, while all non-zero ranks enter torch.distributed.broadcast_object_list(error_payload, src=0) and hang until distributed backend timeout.
Affected Location
- Repository:
NVIDIA/Megatron-LM(4f13dabb5b66064457af695bcf031b179b53ea00, present atHEAD) - File & lines:
megatron/core/dist_checkpointing/validation.py:555-568,590-611(verify_integrity_manifest)
Minimal Standalone Reproduction
import datetime, pathlib, tempfile
import torch.distributed as dist
from megatron.core.dist_checkpointing.validation import verify_integrity_manifest
# With 2 ranks initialized via torch.distributed:
# Write malformed JSON (e.g., "{truncated") to <ckpt_dir>/integrity.json
# and call verify_integrity_manifest(ckpt_dir) on both ranks.
Observed behavior (2-rank Gloo spawn):
- Rank 0 exits immediately with
json.decoder.JSONDecodeError(orKeyErrorif'files'is missing). - Rank 1 hangs in
torch.distributed.broadcast_object_list(error_payload, src=0)until the 4s Gloo timeout expires.
Suggested Fix
Catch (CheckpointingException, json.JSONDecodeError, KeyError, TypeError, OSError) (or wrap _verify_integrity_manifest_impl parsing in try ... except Exception as exc: raise CheckpointingException(...) from exc) on rank 0 so error_payload is always broadcast to all ranks.