# Ten test cases, two workers and just six cases delivered

Imagine handing someone ten cards to pass on three at a time, with instructions to discard an incomplete group. Nine cards get through. Give five cards apiece to two people working under those same instructions and only six get through.

We saw that difference when a PyTorch program prepared ten cases for testing. With incomplete groups discarded in both runs, the main program handed over nine cases when it worked alone. Two workers handed over six. We counted which cases could have been scored. No model or scoring program ran.

PyTorch’s DataLoader supplies cases in groups called batches. Our example used batches of three and a setting called `drop_last=True` that discards an unfinished batch. Losing cases matters because an eventual score would describe only the cases that reached the calculation. We tried the same input with the setting on and off. [Test script](https://sapien1.com/research/check-dataloader-case-coverage-evidence/replay.py) · [Recorded case lists](https://sapien1.com/research/check-dataloader-case-coverage-evidence/observations.json)

## Which of the ten IDs arrived?

We numbered our cases `case-00` through `case-09`. ‘0 workers’ in the table means the main program read all ten in order. With two workers, our own `IterableDataset`, the code for supplying one case at a time, assigned alternate positions to the workers. One got 0, 2, 4, 6 and 8. The other got 1, 3, 5, 7 and 9. Each put its cases into batches of 3. [Test script](https://sapien1.com/research/check-dataloader-case-coverage-evidence/replay.py)

When unfinished batches were kept, both arrangements delivered all ten cases. When they were dropped, the main program delivered nine and the two workers delivered six. The brackets show groups in the order the loader delivered them. ‘Denominator’ counts one possible scoring opportunity per ID.

**Cases the loader delivered with incomplete batches kept or discarded**

| Workers | `drop_last` | Batches in emission order | Missing IDs | Denominator |
| ---: | --- | --- | --- | ---: |
| 0 | `False` | `[case-00, case-01, case-02]` `[case-03, case-04, case-05]` `[case-06, case-07, case-08]` `[case-09]` | None | 10 |
| 0 | `True` | `[case-00, case-01, case-02]` `[case-03, case-04, case-05]` `[case-06, case-07, case-08]` | `case-09` | 9 |
| 2 | `False` | `[case-00, case-02, case-04]` `[case-01, case-03, case-05]` `[case-06, case-08]` `[case-07, case-09]` | None | 10 |
| 2 | `True` | `[case-00, case-02, case-04]` `[case-01, case-03, case-05]` | `case-06`, `case-07`, `case-08`, `case-09` | 6 |

When the short batches were kept (`drop_last=False`), both workers delivered all their cases between them. The reading order changed, but all ten IDs appeared exactly once. No run in the table produced a duplicate. [Recorded case lists](https://sapien1.com/research/check-dataloader-case-coverage-evidence/observations.json)

## Each worker had its own leftovers

With `drop_last=True`, one reader can fill three batches from ten cases. Only `case-09` is left over. In our two-worker setup, automatic batching discarded the last unfinished group separately for each worker. With five cases apiece each worker could fill just one batch. One discarded `case-06` and `case-08`, the other `case-07` and `case-09`.

That result depends on the batch size and the way these particular cases were divided. We used Windows, Python `3.13.17`, CPU PyTorch `2.9.1+cpu`, Windows `spawn` to start the workers and ordered batch delivery. [PyTorch data-loading guide](https://docs.pytorch.org/docs/2.9/data.html#multi-process-data-loading) · [How PyTorch fetches an iterable batch](https://github.com/pytorch/pytorch/blob/5811a8d7da873dd699ff6687092c225caffcf1bb/torch/utils/data/_utils/fetch.py)

## Before comparing scores from different loader settings

Save each case ID every time a case actually reaches the scorer before and after a settings change. Keep repeated IDs. Compare the lists with each other and with the roster you intended to test, and check which count the scoring calculation actually used. Two runs of the same size can still contain different cases.

If a worker reads its own portion of an iterable dataset, rerun with `drop_last=False` and everything else held fixed. Identify which IDs arrived in each worker’s incomplete batch and check whether those were the IDs missing previously.

## Related research

- [Why the first of five test cases turned up on both workers’ lists](https://sapien1.com/research/check-distributed-sampler-coverage)
- [Two scores of 0.5, with no questions in common](https://sapien1.com/research/check-metric-case-coverage)

[Testing models](https://sapien1.com/research#evaluations)
