Checkpoint loading can mix model weights and training state from different epochs
メンテナーはふだん 2 日以内に返信
関連するプルリクエストがすでにマージされています。
- #2010 @peterdsharpe による — マージ済み
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
調査の方向性
Start at the load_checkpoint and save_checkpoint entry points and run the minimal reproduction to observe the mismatched epoch, model weight, and optimizer state. Ensure loading chooses one checkpoint index for all requested models and training state, fails before mutation when a required file is missing, and preserves model-only directory behavior; verify the single-process and distributed cases described in the issue.
索引モデルが issue の本文から書いたものです。
説明
Version and installation
Source checkout: main at 94dbdf829d1a4e93e3f31ecb77713392c471388e. Also reproduced in the original #2010 implementation at 01757c816713892c38455d489376494ee7ee11e5. Python 3.13.8, PyTorch 2.12.0+cu130, Linux.
Description
load_checkpoint(..., epoch=None) independently selects the latest surviving file for the training state and for each requested model. If the newest model weights are deleted but an older weights file remains, loading succeeds with old model weights and newer optimizer/scheduler state. It reports the newer epoch, so training silently resumes from an inconsistent combination of states.
The same mismatch can occur in the other direction: a newer model file with no matching training-state file is combined with older training state.
Minimal reproduction
from pathlib import Path
from tempfile import TemporaryDirectory
import torch
from physicsnemo.utils import load_checkpoint, save_checkpoint
with TemporaryDirectory() as directory:
path = Path(directory)
model = torch.nn.Linear(1, 1, bias=False)
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
for epoch in (1, 2):
with torch.no_grad():
model.weight.fill_(epoch)
optimizer.param_groups[0]["lr"] = epoch * 0.01
save_checkpoint(path, models=model, optimizer=optimizer, epoch=epoch)
(path / "Linear.0.2.pt").unlink()
fresh = torch.nn.Linear(1, 1, bias=False)
fresh_optimizer = torch.optim.Adam(fresh.parameters(), lr=0.5)
epoch = load_checkpoint(path, models=fresh, optimizer=fresh_optimizer)
print(epoch, fresh.weight.item(), fresh_optimizer.param_groups[0]["lr"])
Observed output:
2 1.0 0.02
The returned epoch and optimizer learning rate come from epoch 2; the model weight comes from epoch 1. No exception is raised.
Expected behavior
Select one training checkpoint index and require every requested model's weights at that same index. If any required file is missing, fail clearly before changing model or training state. The caller can explicitly select an older complete checkpoint. Do not independently fall back to older or newer model files.
This should also work for automatically numbered saves, where the filename index may exist without an epoch key in the training-state payload. Preserve current behavior for directories containing only model weights.
Scope and verification
Reproduced with single-process loading and on both ranks of a two-process CPU/Gloo DTensor run, including optimizer and scheduler restoration. The filename selection is independent of the device backend. The issue exists on main and was identified while reviewing #2010; that PR will address it.
- 主要言語
- Python
- スター
- 3.4k
- フォーク
- 824
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 70
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/physicsnemo のほかの issue
-
Wasserstein CDF distance uses the first width for every bin対応中かも @sylvesterkaczmarek が 22 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NVIDIA/physicsnemo#2042 ·
メンテナーはふだん 2 日以内に返信
-
🐛[BUG]: Darcy2D Jacobi kernel divides grad(k)·grad(u) by 2dx instead of 4dx², so the data doesn't solve the Darcy equation対応中かも @coreyjadams が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/physicsnemo#2036 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
🐛[BUG]: MHD_PDE equation "B_grad_u" uses v * Bx.diff(y) instead of By * u.diff(y)対応中かも @aaguadob が 27 日前に担当しました。 オープン? - Needs Triage bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
NVIDIA/physicsnemo#2021 ·
メンテナーはふだん 2 日以内に返信
-
🐛[BUG]: Diffusion(time=True) in darcy_physics_informed/utils.py silently drops the time-derivative term対応中かも @aaguadob が 27 日前に担当しました。 オープン? - Needs Triage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NVIDIA/physicsnemo#2020 ·
メンテナーはふだん 2 日以内に返信
-
🐛[BUG]: DistributedManager's SLURM setup connects to the srun launch node, not to rank 0's node対応中かも @peterdsharpe が 1 日前に担当しました。 オープン? - Needs Triage bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
NVIDIA/physicsnemo#2168 ·
メンテナーはふだん 2 日以内に返信
NVIDIA/physicsnemo の issue をすべて見る
似ている issue
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-free対応中かも @Aaqibhafeezkhan が今日担当しました。 オープンbeginner documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BistaDinesh03/critique#164 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug IO
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MrNeRF/LichtFeld-Studio#3824 ·
メンテナーはふだん 1 日以内に返信
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-webui/open-webui#33200 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
The changelog workflow excludes otelbot but not dependabot, so every Dependabot pull request fails the changelog check対応中かも @ocelotl が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
open-telemetry/opentelemetry-python#5825 ·
メンテナーはふだん 2 日以内に返信