Skip to content

Commit 2a91af7

Browse files
forklady42claude
andcommitted
Fix val_loss metric key ambiguity for HPO callbacks
With on_step=True and on_epoch=True, Lightning creates val_loss_step and val_loss_epoch keys, making the plain val_loss key unreliable in callback_metrics. This caused ModelCheckpoint, EarlyStopping, and the HPO trial result to silently fail. Setting on_step=False ensures the metric is logged only as val_loss at epoch end. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 23a0aa4 commit 2a91af7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/electrai/lightning.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ def training_step(self, batch):
3838
def validation_step(self, batch):
3939
loss = self._loss_calculation(batch)
4040
self.log(
41-
"val_loss", loss, prog_bar=True, on_step=True, on_epoch=True, sync_dist=True
41+
"val_loss",
42+
loss,
43+
prog_bar=True,
44+
on_step=False,
45+
on_epoch=True,
46+
sync_dist=True,
4247
)
4348
return loss
4449

0 commit comments

Comments
 (0)