Commit ·
ff230a0
1
Parent(s): 9a3c989
Update icy_dolma.py
Browse files- icy_dolma.py +38 -9
icy_dolma.py
CHANGED
|
@@ -25,9 +25,9 @@ _CITATION = """
|
|
| 25 |
"""
|
| 26 |
|
| 27 |
|
| 28 |
-
_VARIANTS = ["v3"]
|
|
|
|
| 29 |
|
| 30 |
-
_DATA_URL = "gs://meliad2_us2/datasets/dolma/clustered_v3/train/shard_{}/subshard_{}/phase{}.jsonl"
|
| 31 |
|
| 32 |
@dataclasses.dataclass
|
| 33 |
class State:
|
|
@@ -169,6 +169,40 @@ class IcyDolmaConfig(datasets.BuilderConfig):
|
|
| 169 |
self.shard_spec = shard_spec
|
| 170 |
assert (self.shard_spec is None) or (self.filepaths is None ) #one of these must be None
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
class IcyDolma(datasets.GeneratorBasedBuilder):
|
| 173 |
BUILDER_CONFIGS = [IcyDolmaConfig(name) for name in _VARIANTS]
|
| 174 |
|
|
@@ -176,13 +210,8 @@ class IcyDolma(datasets.GeneratorBasedBuilder):
|
|
| 176 |
self.worker_id = self.config.worker_id
|
| 177 |
self.n_workers = self.config.n_workers
|
| 178 |
self.buffer_size = self.config.buffer_size
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
elif self.config.shard_spec is not None:
|
| 182 |
-
shard_idx, subshard_idx = self.config.shard_spec
|
| 183 |
-
self.filepaths = [_DATA_URL.format(shard_idx,subshard_idx,k) for k in range(2)]
|
| 184 |
-
else:
|
| 185 |
-
self.filepaths = [_DATA_URL.format(i,j,k) for i in range(64) for j in range(64) for k in range(2)]
|
| 186 |
if self.config.file_loc is not None:
|
| 187 |
self.file_loc = self.config.file_loc
|
| 188 |
else:
|
|
|
|
| 25 |
"""
|
| 26 |
|
| 27 |
|
| 28 |
+
_VARIANTS = ["v3","v5"]
|
| 29 |
+
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
@dataclasses.dataclass
|
| 33 |
class State:
|
|
|
|
| 169 |
self.shard_spec = shard_spec
|
| 170 |
assert (self.shard_spec is None) or (self.filepaths is None ) #one of these must be None
|
| 171 |
|
| 172 |
+
_DATA_URL = {"v3":"gs://meliad2_us2/datasets/dolma/clustered_v3/train/shard_{}/subshard_{}/phase{}.jsonl",
|
| 173 |
+
"v5":"gs://meliad2_us2/datasets/c4/c4_w_cluster_v2/train/subtagged/tag_{}/subtag_{}.jsonl.zst"
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
DS_CLUSTER_LAYOUT = {"v3":(64,64,2),"v5":(128,256)}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
import numpy as np
|
| 180 |
+
import itertools
|
| 181 |
+
def get_cluster_tuples(cluster_layout, shard_spec):
|
| 182 |
+
if shard_spec is None:
|
| 183 |
+
shard_spec = (None,)*len(cluster_layout)
|
| 184 |
+
# if shard_spec is 2d and cluster_layout is 3d, we will pad shard_spec with Nones at the end.
|
| 185 |
+
shard_spec = shard_spec + (None,)*(len(cluster_layout)-len(shard_spec))
|
| 186 |
+
dim_list = []
|
| 187 |
+
for a,b in zip(cluster_layout,shard_spec):
|
| 188 |
+
if b is None:
|
| 189 |
+
dim_list.append(range(a))
|
| 190 |
+
else:
|
| 191 |
+
dim_list.append([b])
|
| 192 |
+
|
| 193 |
+
return list(itertools.product(*dim_list))
|
| 194 |
+
|
| 195 |
+
def _get_filepaths(config):
|
| 196 |
+
cluster_layout = DS_CLUSTER_LAYOUT[config.name]
|
| 197 |
+
shard_spec = config.shard_spec
|
| 198 |
+
if config.filepaths is not None:
|
| 199 |
+
filepaths = config.filepaths
|
| 200 |
+
else:
|
| 201 |
+
tuples = get_cluster_tuples(cluster_layout, shard_spec)
|
| 202 |
+
filepaths = [_DATA_URL[config.name].format(*tup) for tup in tuples]
|
| 203 |
+
return filepaths
|
| 204 |
+
|
| 205 |
+
|
| 206 |
class IcyDolma(datasets.GeneratorBasedBuilder):
|
| 207 |
BUILDER_CONFIGS = [IcyDolmaConfig(name) for name in _VARIANTS]
|
| 208 |
|
|
|
|
| 210 |
self.worker_id = self.config.worker_id
|
| 211 |
self.n_workers = self.config.n_workers
|
| 212 |
self.buffer_size = self.config.buffer_size
|
| 213 |
+
self.filepaths = _get_filepaths(self.config)
|
| 214 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
if self.config.file_loc is not None:
|
| 216 |
self.file_loc = self.config.file_loc
|
| 217 |
else:
|