Lightning-AI/pytorch-lightning · error · FileNotFoundError

{default_message}. It looks like you passed the path to a fi

Error message

{default_message}. It looks like you passed the path to a file inside a DeepSpeed checkpoint folder. Try to load using this parent directory instead: {grandparent}

What it means

Variant of the checkpoint path validation: the path is a file whose grandparent directory is a valid DeepSpeed checkpoint (e.g. .../global_step10/checkpoint/zero_to_fp16.py). Lightning tells you to load the grandparent directory instead.

Source

Thrown at src/lightning/fabric/strategies/deepspeed.py:924

    # └── zero_to_fp32.py

    path_str = str(path)
    fs = get_filesystem(path_str)
    path_is_ds_checkpoint = _is_deepspeed_checkpoint(path_str, fs)
    default_message = f"The provided path is not a valid DeepSpeed checkpoint: {path_str}"

    if not path_is_ds_checkpoint:
        # Case 1: User may have accidentally passed the subfolder "checkpoint"
        parent = os.path.dirname(path_str)
        if _is_deepspeed_checkpoint(parent, fs):
            raise FileNotFoundError(
                f"{default_message}. It looks like you passed the path to a subfolder."
                f" Try to load using this parent directory instead: {parent}"
            )
        # Case 2: User may have accidentally passed the path to a file inside the "checkpoint" subfolder
        grandparent = os.path.dirname(parent)
        if fs.isfile(path_str) and _is_deepspeed_checkpoint(grandparent, fs):
            raise FileNotFoundError(
                f"{default_message}. It looks like you passed the path to a file inside a DeepSpeed"
                f" checkpoint folder. Try to load using this parent directory instead: {grandparent}"
            )
        raise FileNotFoundError(default_message)


def _format_precision_config(
    config: dict[str, Any],
    precision: str,
    loss_scale: float,
    loss_scale_window: int,
    min_loss_scale: int,
    initial_scale_power: int,
    hysteresis: int,
) -> None:
    if "fp16" not in config and precision in ("16-mixed", "16-true"):
        # FP16 is a DeepSpeed standalone AMP implementation
        rank_zero_info("Enabling DeepSpeed FP16. Model parameters and inputs will be cast to `float16`.")

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Pass the checkpoint directory (the grandparent printed in the message), e.g. .../global_step10
  2. If you truly have a single full-weights file, use DeepSpeedStrategy(..., load_full_weights=True) and the file itself

Example fix

# before
fabric.load_checkpoint("save/step10/checkpoint/zero_to_fp16.pt", state)

# after
fabric.load_checkpoint("save/step10", state)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(ckpt_path)
if p.is_file() and p.parent.parent.joinpath("checkpoint").is_dir():
    ckpt_path = str(p.parent.parent)

Try / catch

try:
    fabric.load_checkpoint(path, state)
except FileNotFoundError as e:
    if "parent directory instead" in str(e):
        suggested = str(e).split("parent directory instead: ")[-1].rstrip(".")
        fabric.load_checkpoint(suggested, state)

Prevention

When it happens

Trigger: load_checkpoint pointing at a file inside a DeepSpeed checkpoint folder, such as a zero_to_* shard, the mp_rank sd file, or latest inside the checkpoint subfolder.

Common situations: User drills into the checkpoint dir and picks one of the shard files, assuming it is a consolidated checkpoint; globbing for *.pt inside the save dir; copying a single shard to another machine.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/4a02246e34fe9faa. Report an issue: GitHub.