Training: small finetune datasets fail with a misleading "no readable samples ... (0 failures)" error when the manifest is smaller than num_bucket_batches × batch_size × loader_procs

Author: lumatic2Created Sep 28, 2026Updated Sep 28, 2026

Summary. When finetuning on a small dataset, which is the main use case for finetune.yaml, training fails on the first batch with an error that points at the wrong cause:

ValueError: no readable samples in data/train_aligned.jsonl: every entry failed to load (0 failures). Check the paths in the manifest.

Every entry is readable. The real cause is that the length-bucketing pool (#309) is never filled:

  • training/dataloader/loader.py:363-365 only emits batches once num_bucket_batches * batch_size samples have been collected, and the leftover pool is dropped at the end of each pass.
  • Defaults: num_bucket_batches = 20 (training/args.py:39), loader_procs = 6 (training/args.py:37), and finetune.yaml uses batch_size: 64 (training/configs/finetune.yaml:28).
  • SubprocessDataLoader shards the manifest across world_size * loader_procs loaders. So with the stock finetune.yaml, each loader needs at least 20 × 64 = 1,280 entries, which means about 7,680 utterances per GPU before a single batch comes out.
  • If a shard is smaller than that, no batch is ever yielded, and loader.py:377-381 raises the "every entry failed to load" error with 0 failures.

The existing guard at loader.py:342 only checks len(entries) < batch_size, so it does not catch this.

(Before #318, _prefetch did not forward exceptions from its worker thread. The same situation was then a silent hang: 0 steps, GPU near idle, no error. We hit that on 2026-09-21 at dfff26e. HEAD now fails fast, which is much better, but the message sends you to check paths that are fine.)

Repro (HEAD 7972095, a CPU-only DataLoader call, 110-entry aligned manifest, dummy tokenizer):

python
from training.dataloader import DataLoader
dl = DataLoader("train_aligned.jsonl", lambda t: [1] * max(1, len(t) // 3), 16, 24000, 12.5,
                30.0, 5.0, rank=0, world_size=1, num_bucket_batches=20)
next(iter(dl))
# ValueError: no readable samples in train_aligned.jsonl: every entry failed to load (0 failures). ...
# num_bucket_batches=1 -> first batch in 0.06 s

Suggested fix (either or both):

  1. Validate up front: if len(entries) < max(1, num_bucket_batches) * batch_size, raise a message that names the knobs. For example: "110 entries for this loader but the bucket pool needs 20 × 16 = 320; lower data.num_bucket_batches (1 disables bucketing) or data.loader_procs, or use a larger manifest." Alternatively, clamp the pool to the shard size or flush the partial pool at the end of a pass.
  2. Document this in training/README.md next to finetune.yaml: small-data finetunes need data.num_bucket_batches: 1 and a lower data.loader_procs.

Related gaps we hit on the same small finetune (happy to split these out):

  • Validation fails only at the first validation step. validate() (training/train.py:318-345) builds a fresh in-process DataLoader with the train batch_size. With a 10-entry valid_jsonl and batch_size: 16, it can never form a batch. The loader.py:342 guard fires at step valid_freq (2,500 in finetune.yaml), not at startup, so the run dies after the first training segment. Before #318 this was a silent hang at that step. Checking the valid manifest size at startup would catch it.
  • model_config must be a local path in training. load_model_config calls load_config(Path(path)) / Path(path).read_text() (training/modules/builders.py:39-40). The inference CLI accepts https:// and hf:// configs (pocket_tts/main.py), so pointing finetune.yaml at a community model's hosted YAML seems natural but fails. Either accept the same URL forms or add a one-line note.

Environment: WSL2 Ubuntu 24.04, 1× RTX 5090, Python 3.10, finetuning seastar105/pocket-tts-korean-300m on about 9 minutes (120 clips) of speech.