Skip to content

fix: load checkpoints in weights-only mode - #601

Merged
jmccaffrey-nv merged 1 commit into
mainfrom
dev/jmccaffrey/checkpoint-mode-exec-github
Sep 9, 2026
Merged

fix: load checkpoints in weights-only mode#601
jmccaffrey-nv merged 1 commit into
mainfrom
dev/jmccaffrey/checkpoint-mode-exec-github

Conversation

@jmccaffrey-nv

Copy link
Copy Markdown
Collaborator

Summary

  • make weights-only behavior explicit for local, Hugging Face cache, S3, and distributed-checkpoint cache reads
  • preserve safetensors handling and tensor state-dict compatibility for .pt, .pth, and .ckpt files
  • cover non-weight objects and normal tensor-only checkpoints across each supported path

Rationale

The checkpoint-loading API returns state dictionaries. Loading legacy formats in weights-only mode keeps that contract consistent across supported PyTorch versions without removing existing checkpoint formats.

Validation

  • focused checkpoint suite: 9 passed
  • changed-file lint and formatting checks passed
  • changed-file type checks passed
  • broader CPU suite: 677 passed, with two unrelated environment-only cases excluded

Use explicit weights_only=True for .pt, .pth, and .ckpt reads from local paths, Hugging Face cache entries, S3, and the distributed-checkpoint cache. This keeps loading behavior consistent across supported PyTorch versions and matches the state-dict return contract.

Keep safetensors handling and tensor state-dict compatibility unchanged. Add coverage for non-weight objects and normal tensor-only checkpoints across the supported legacy extensions.

Signed-off-by: Jonathan McCaffrey <jmccaffrey@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 9, 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.

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking test-coverage gap for valid S3 and distributed-cache checkpoint reads.

Findings

  1. P2 Missing success-path coverage

Summary

  • Changes three torch.load call sites to use weights_only=True.
  • Adds coverage proving non-weight objects are rejected without executing their reducers.
  • Verifies local .pt, .pth, and .ckpt tensor state dictionaries still load.
  • Leaves successful tensor-only S3 and distributed-cache reads without direct regression coverage.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Local[Local checkpoint] --> SafeLoad[torch.load weights_only=True]
    HF[Hugging Face cached file] --> SafeLoad
    S3[S3 checkpoint bytes] --> SafeLoad
    DCP[Distributed checkpoint cache] --> SafeLoad
    SafeLoad --> StateDict[Tensor state dictionary]
    StateDict --> Model[Model load_state_dict]
    SafeLoad -. rejects .-> Object[Executable non-weight object]
Loading

Comment thread flashdreams/tests/test_checkpoint_loading.py
@jmccaffrey-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test aae515d

@jmccaffrey-nv
jmccaffrey-nv added this pull request to the merge queue Sep 9, 2026
Merged via the queue into main with commit 770f978 Sep 9, 2026
7 checks passed
@jmccaffrey-nv
jmccaffrey-nv deleted the dev/jmccaffrey/checkpoint-mode-exec-github branch September 9, 2026 20:31
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