Skip to content

fix(runners): guard against empty loss_history in all trainers#36

Merged
sacredvoid merged 1 commit intomainfrom
fix/empty-loss-history-guard
Mar 26, 2026
Merged

fix(runners): guard against empty loss_history in all trainers#36
sacredvoid merged 1 commit intomainfrom
fix/empty-loss-history-guard

Conversation

@sacredvoid
Copy link
Owner

Summary

  • Adds if not loss_history: loss_history = [result.training_loss] fallback in SFT, DPO, and GRPO train methods
  • Prevents IndexError when max_steps < logging_steps produces no log entries with loss
  • Common in notebooks with small training runs (max_steps=1)

Fixes #35

Test plan

  • All 179 tests pass, lint/format clean

When max_steps < logging_steps, loss_history is empty, causing
IndexError in notebooks and CLI. Now falls back to [training_loss]
from TRL's result object when no log entries contain loss.

Fixes #35
@sacredvoid sacredvoid merged commit e8888d6 into main Mar 26, 2026
@sacredvoid sacredvoid deleted the fix/empty-loss-history-guard branch March 26, 2026 01:32
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.

Bug: empty loss_history crashes CLI and notebooks with IndexError

1 participant