Repository navigation
Fix stale batch indices in prediction writers for dataloaders without batch indices - #22065
Thanatos9404 wants to merge 2 commits into
Conversation
deependujha
left a comment
There was a problem hiding this comment.
LGTM, thanks for contributing :)
|
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #22065 +/- ##
=========================================
- Coverage 87% 79% -8%
=========================================
Files 270 267 -3
Lines 24015 23957 -58
=========================================
- Hits 20855 18826 -2029
- Misses 3160 5131 +1971 |
|
Additional CPU coverage on cb658e6, beyond the existing approval: an independent Trainer harness checked all three writer intervals ( All 24 combinations pass on this head. On base 84df182, 12 combinations fail with stale map indices reaching iterable batch callbacks. The other 12 pass, including epoch-only controls. Epoch index lists and the later map loader's real indices remain correct on head. The PR's prediction-writer tests plus the adjacent prediction-loop and fetcher suites give 112 passed on head. The same test files on base give 111 passed and one inspected stale-indices assertion failure, not a setup error. Python 3.11, single-process CPU only. No GPU or distributed claim. This verification and comment were AI-assisted |
What does this PR do?
Fixes #22059
When a dataloader's batch indices cannot be inferred (for example an
IterableDataset),_store_data_for_prediction_writerreturned early without touchingcurrent_batch_indices, soBasePredictionWriter.write_on_batch_endreceived the indices of the previous map-style batch. This happened both for a later dataloader in the samepredict()call and across separatepredict()calls on the same Trainer.This resets
current_batch_indicesto an empty list in that branch, as suggested in the issue, so those batches get[], the same as on a fresh Trainer.The new test covers both cases. It fails on master with
[[0, 1], [2, 3], [2, 3], [2, 3]]and passes with the change. I also ran the prediction writer, prediction loop, fetcher, loop state dict and trainer predict tests locally. CHANGELOG updated.Thanks @AryanRG for the clear diagnosis; happy to close this if you'd rather send your own fix.
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist