tokenized_flat_dataset
optimus_dl.modules.data.datasets.tokenized_flat_dataset
¶
TokenizedFlatDataset
¶
Bases: BaseDataset
Dataset that treats multiple token files as a single contiguous stream.
This dataset memory-maps all provided files and calculates a global token offset. It then partitions this global stream into equal segments for each distributed rank. This is ideal for pre-training on very large corpora where data is stored as raw token IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
TokenizedFlatDatasetConfig
|
Flat tokenized dataset configuration. |
required |
rank
|
int
|
Distributed rank. |
required |
world_size
|
int
|
Total number of ranks. |
required |
Source code in optimus_dl/modules/data/datasets/tokenized_flat_dataset.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
file_index
property
¶
Find the index of the file containing the current token offset.
get_state()
¶
Return current token offset for checkpointing.
Source code in optimus_dl/modules/data/datasets/tokenized_flat_dataset.py
next()
¶
Yield the next batch of sequences.
Source code in optimus_dl/modules/data/datasets/tokenized_flat_dataset.py
reset(initial_state=None)
¶
Restore dataset state or recalculate boundaries for a fresh start.
Source code in optimus_dl/modules/data/datasets/tokenized_flat_dataset.py
TokenizedFlatDatasetConfig
dataclass
¶
Bases: RegistryConfigStrict
Configuration for flat tokenized datasets.
Attributes:
| Name | Type | Description |
|---|
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
str
|
|
'np.uint16'
|
files
|
list[str]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
seq_len
|
int
|
|
'???'
|
batch_size
|
int
|
|
'???'
|