Lightning-AI/pytorch-lightning

trainer.test() with given checkpoint logs last epoch instead of checkpoint epoch

开放

#20,052 创建于 2024年7月5日

 (1 条评论) (1 个反应) (0 位负责人)Python (3,233 个派生)batch import
bughelp wantedrepro needed

仓库指标

星标
 (26,687 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Bug description

Testing from a given checkpoint leads to logging the epoch number of the last checkpoint instead of the checkpoint specified:

trainer = Trainer(..., max_epochs=10)
lightning_module = MyLightningModule(...)
datamodule = MyDatamodule()

trainer.fit(lightning_module , datamodule=datamodule)

trainer.test(lightning_module , datamodule=datamodule, ckpt_path="last")     # <-- ok: logs correct epoch and step
ckpt_path="/.../checkpoints/epoch=2-step=396.ckpt"
trainer.test(lightning_module , datamodule=datamodule, ckpt_path=ckpt_path)  # <-- incorrect: logs last epoch and step

The second test logs epoch 10 instead of epoch 2. Similarly, the step number of the second test is incorrect.

What version are you seeing the problem on?

v2.2.1

贡献者指南