Skip to content

feat: add max_steps to all trainers - #382

Closed
stephantul wants to merge 1 commit into
mainfrom
max-steps
Closed

stephantul wants to merge 1 commit into
mainfrom
max-steps

Conversation

@stephantul

Copy link
Copy Markdown
Contributor

fit now accepts max_steps, which stops training after that many steps, also in the middle of an epoch. When it is reached, the model is validated one last time, unless that step was already a validation step, and the best checkpoint is kept. max_steps takes precedence over min_epochs. This is mostly prep work for a trainer which doesn't have the concept of epochs.

fit now accepts max_steps, which stops training after that many steps,
also in the middle of an epoch. When it is reached, the model is validated
one last time, unless that step was already a validation step, and the best
checkpoint is kept. max_steps takes precedence over min_epochs.
@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
model2vec/train/base.py 99.54% <ø> (ø)
model2vec/train/classifier.py 98.33% <ø> (ø)
model2vec/train/pairs.py 100.00% <ø> (ø)
model2vec/train/similarity.py 100.00% <ø> (ø)
model2vec/train/trainer.py 99.13% <100.00%> (+0.06%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Adds optional training step limit to all model trainers.

The PR appears safe to merge; a checkpoint-selection regression test would strengthen coverage of its central promise.

Reviews (1) · Last reviewed commit: "feat(train): add max_steps to all traine..."

Comment thread tests/test_trainable.py
Comment on lines +895 to +899
def test_run_training_loop_stops_at_max_steps() -> None:
"""Training stops after max_steps, across epochs, and validates once at the end."""
loss = _run_counting_loop(max_steps=13)
assert loss.train_calls == 13
assert loss.val_calls == 2 * 2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Best checkpoint remains untested The new test checks training and validation call counts, but it never checks the returned checkpoint. It would pass even if training validated at max_steps and then returned the final weights instead of an earlier, better checkpoint. A test with controlled validation results would protect that behavior.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@stephantul stephantul closed this Sep 28, 2026
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.

1 participant