Skip to content

Catching very infrequent error in train-logs writing which crashes train job. #1760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions checkpoint/orbax/checkpoint/_src/path/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,18 +733,26 @@ def _checkpoint_steps(path: epath.Path) -> List[int]:


def any_checkpoint_step(checkpoint_dir: epath.PathLike) -> Optional[int]:
"""Returns any finalized checkpoint step in the directory or None.

This avoids iterating over the entire directory.
"""Returns any (preferably the latest) finalized checkpoint step in the directory or None.

Args:
checkpoint_dir: Checkpoint directory.

Returns:
Any finalized checkpoint step in the directory or None.
Latest finalized checkpoint step in the directory or None.
"""
checkpoint_dir = epath.Path(checkpoint_dir)
valid_steps = []
for s in checkpoint_dir.iterdir():
if _is_legacy_finalized_step_checkpoint(s):
return step_from_checkpoint_name(s.name)
valid_steps.append(step_from_checkpoint_name(s.name))
logging.info('Found valid checkpoint step: %s', s.name)
else:
logging.info('Skipping invalid checkpoint: %s', s.name)

if valid_steps:
selected_step = max(valid_steps)
logging.info('Latest valid step found: %s', selected_step)
return selected_step

return None