Lightning-AI / Lightning-AI/pytorch-lightning

Support all iterator modes for fit/validate/test/predict

Open
#16,830 15 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

data handling feature help wanted pl
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Description & Motivation

`trainer.fit` only works with `CombinedLoader(..., mode="max_size_cycle"|"min_size")`

`trainer.{validate,test,predict}` only works with `CombinedLoader(..., mode="sequential")`

This constraint is checked in the top-level loops:
https://github.com/Lightning-AI/lightning/blob/0009cde1db1a9ab4e2f1e0a9f69a4affb59d5134/src/lightning/pytorch/loops/fit_loop.py#L351-L354
https://github.com/Lightning-AI/lightning/blob/0009cde1db1a9ab4e2f1e0a9f69a4affb59d5134/src/lightning/pytorch/loops/evaluation_loop.py#L182-L183

### Pitch

Have all trainer functions support all modes

TODO:
- [ ] FitLoop
- [x] EvaluationLoop (#17163)
- [ ] PredictionLoop

### Alternatives

Not do it

### Additional context

This builds on top of https://github.com/Lightning-AI/lightning/pull/16726

cc @borda @justusschock @awaelchli

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the iterator-mode checks linked in src/lightning/pytorch/loops/fit_loop.py and evaluation_loop.py, then review the completed EvaluationLoop work in pull request #17163. Focus on the unchecked FitLoop and PredictionLoop items, and verify that fit, validate, test, and predict support every CombinedLoader mode when the relevant tests are run.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.