MCPcopy Create free account
hub / github.com/espnet/espnet / DataIteratorFactory

Class DataIteratorFactory

espnet2/speechlm/dataloader/iterator.py:21–345  ·  view source on GitHub ↗

Factory for creating data iterators for SpeechLM training. This class manages batching, data sharding across GPUs, and provides DataLoader instances for training with support for endless epochs. Features: - Supports multiple tasks and datasets with resampling factors -

Source from the content-addressed store, hash-verified

19
20
21class DataIteratorFactory:
22 """Factory for creating data iterators for SpeechLM training.
23
24 This class manages batching, data sharding across GPUs, and provides
25 DataLoader instances for training with support for endless epochs.
26
27 Features:
28 - Supports multiple tasks and datasets with resampling factors
29 - Bucket or pack batching strategies
30 - Distributed training with automatic batch synchronization
31 - Deterministic shuffling with configurable seeds
32 - State saving/loading for training resumption
33
34 Args:
35 unregistered_specifier: Space-separated unregistered data specs.
36 Format: "task:name:data_json[:factor]"
37 Example: "asr:librispeech:train.json:2.0"
38 registered_specifier: Space-separated registered data specs.
39 Format: "task:name[:factor]"
40 Example: "tts:ljspeech:1.5"
41 stats_dir: Directory containing statistics files (str or Path).
42 Each file should be named "stats_{task}_{data_name}.jsonl"
43 collate_fn: Optional collate function for DataLoader.
44 loader_state: Optional saved state dict to restore from.
45 batchfy_method: Batching method ("bucket" or "pack").
46 batch_size: Maximum tokens per batch.
47 num_workers: Number of DataLoader workers.
48 rank: GPU rank for distributed training (0-indexed).
49 world_size: Total number of GPUs in distributed training.
50 shuffle: Whether to shuffle batches.
51 seed: Random seed for reproducibility.
52
53 Example:
54 >>> factory = DataIteratorFactory(
55 ... unregistered_specifier="asr:libri:train.json:2.0",
56 ... registered_specifier="tts:lj:1.0",
57 ... stats_dir="/path/to/stats",
58 ... batch_size=10000,
59 ... shuffle=True,
60 ... )
61 >>> loader = factory.get_iterator(global_step=0, length=100)
62 >>> for batch in loader:
63 ... # Training loop
64 ... pass
65 """
66
67 def __init__(
68 self,
69 unregistered_specifier: str = "",
70 registered_specifier: str = "",
71 stats_dir: Union[str, Path] = None,
72 loader_state: Optional[Path] = None,
73 collate_fn: Optional[Callable] = None,
74 batchfy_method: str = "bucket",
75 batch_size: int = 1000,
76 num_workers: int = 4,
77 rank: int = 0,
78 world_size: int = 1,

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…