LMFuser 0.0.4__tar.gz → 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lmfuser-0.0.4 → lmfuser-0.0.5}/PKG-INFO +2 -2
- {lmfuser-0.0.4 → lmfuser-0.0.5}/pyproject.toml +2 -2
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/task.py +96 -49
- {lmfuser-0.0.4 → lmfuser-0.0.5}/.github/workflows/python-publish.yml +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/.gitignore +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/.vscode/settings.json +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/LICENSE +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/README.md +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/__init__.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/model_loader.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/optimizers.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/runners/__init__.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/runners/ddp_runner.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/runners/runner.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/schedulers.py +0 -0
- {lmfuser-0.0.4 → lmfuser-0.0.5}/src/lmfuser/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: LMFuser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: The LMFuser training framework.
|
|
5
5
|
Project-URL: Homepage, https://github.com/TYTTYTTYT/LMFuser
|
|
6
6
|
Project-URL: Documentation, https://github.com/TYTTYTTYT/LMFuser
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
17
17
|
Classifier: Topic :: Utilities
|
|
18
18
|
Requires-Python: >=3.11
|
|
19
19
|
Requires-Dist: hyperargs>=0.1.3
|
|
20
|
-
Requires-Dist: lmfuser-data
|
|
20
|
+
Requires-Dist: lmfuser-data>=0.1.0
|
|
21
21
|
Requires-Dist: numpy
|
|
22
22
|
Requires-Dist: pandas
|
|
23
23
|
Requires-Dist: pyarrow
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "LMFuser"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.5"
|
|
8
8
|
requires-python = ">= 3.11"
|
|
9
9
|
description = "The LMFuser training framework."
|
|
10
10
|
readme = "README.md"
|
|
@@ -20,7 +20,7 @@ dependencies = [
|
|
|
20
20
|
"pandas",
|
|
21
21
|
"pyarrow",
|
|
22
22
|
"torch",
|
|
23
|
-
"LMFuser-data",
|
|
23
|
+
"LMFuser-data>=0.1.0",
|
|
24
24
|
"tqdm",
|
|
25
25
|
"wandb",
|
|
26
26
|
"HyperArgs>=0.1.3",
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
from
|
|
2
|
-
from typing import TypeVar, Any, Callable
|
|
1
|
+
from typing import Any, Callable
|
|
3
2
|
from collections.abc import Iterable
|
|
4
3
|
|
|
5
4
|
import torch
|
|
6
5
|
from torch import nn
|
|
7
6
|
from lmfuser_data.interfaces import Batch, Row
|
|
8
7
|
from lmfuser_data.scanners import Scanner
|
|
9
|
-
from lmfuser_data import DataLoader
|
|
8
|
+
from lmfuser_data import DataLoader, PyTorchDataLoader
|
|
10
9
|
from lmfuser_data.interfaces import SubclassTracer
|
|
11
10
|
from hyperargs import Conf, StrArg, FloatArg, IntArg, OptionArg, add_dependency, monitor_on
|
|
12
11
|
|
|
13
|
-
|
|
14
12
|
def scanner_type_list() -> list[str]:
|
|
15
13
|
return list(Scanner.all_subclass_names())
|
|
16
14
|
|
|
17
|
-
|
|
18
15
|
@add_dependency('num_train_data_path', 'train_data_path_list')
|
|
19
16
|
@add_dependency('num_train_data_path', 'train_data_weights')
|
|
20
17
|
class TaskBase(Conf, SubclassTracer):
|
|
@@ -28,8 +25,11 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
28
25
|
|
|
29
26
|
scanner_type = OptionArg(default='C4Scanner', option_fn=scanner_type_list)
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
train_dataloader_type = OptionArg(default='single file', options=['single file', 'sharded'])
|
|
29
|
+
eval_dataloader_type = OptionArg(default='single file', options=['single file', 'sharded'])
|
|
30
|
+
|
|
31
|
+
_train_dataloader: DataLoader | None | PyTorchDataLoader = None
|
|
32
|
+
_eval_dataloader: DataLoader | None | PyTorchDataLoader = None
|
|
33
33
|
|
|
34
34
|
@monitor_on('num_train_data_path')
|
|
35
35
|
def set_train_path_list(self) -> None:
|
|
@@ -66,7 +66,7 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
66
66
|
num_workers: int,
|
|
67
67
|
rank: int,
|
|
68
68
|
world_size: int
|
|
69
|
-
) -> DataLoader |
|
|
69
|
+
) -> None | DataLoader | PyTorchDataLoader:
|
|
70
70
|
if self.num_train_data_path.value() == 0:
|
|
71
71
|
return None
|
|
72
72
|
if self._train_dataloader is not None:
|
|
@@ -76,25 +76,45 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
76
76
|
scanner_type = self.scanner_type.value()
|
|
77
77
|
assert scanner_type is not None, 'scanner_type is None'
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
79
|
+
dataloader_type = self.train_dataloader_type.value()
|
|
80
|
+
assert dataloader_type in ('sharded', 'single file'), f'Unknown dataloader type: {dataloader_type}'
|
|
81
|
+
|
|
82
|
+
if dataloader_type == 'sharded':
|
|
83
|
+
self._train_dataloader = DataLoader(
|
|
84
|
+
batch_size=batch_size,
|
|
85
|
+
path_list=path_list, # type: ignore
|
|
86
|
+
distributor_weights=weight_list, # type: ignore
|
|
87
|
+
scanner_type=Scanner.get_subclass(scanner_type),
|
|
88
|
+
seed=seed,
|
|
89
|
+
shuffle=shuffle,
|
|
90
|
+
pre_fetch_factor=prefetch_factor,
|
|
91
|
+
ignore_error=ignore_error,
|
|
92
|
+
qps=qps,
|
|
93
|
+
instruct_timeout=instruct_timeout,
|
|
94
|
+
worker_timeout=worker_timeout,
|
|
95
|
+
num_workers=num_workers,
|
|
96
|
+
map_fn=self.get_row_processor(),
|
|
97
|
+
flow_fn=self.get_flow_processor(),
|
|
98
|
+
batch_map_fn=self.get_batch_processor(),
|
|
99
|
+
rank_idx=rank,
|
|
100
|
+
num_ranks=world_size,
|
|
101
|
+
)
|
|
102
|
+
elif dataloader_type == 'single file':
|
|
103
|
+
PyTorchDataLoader(
|
|
104
|
+
batch_size=batch_size,
|
|
105
|
+
path_list=path_list, # type: ignore
|
|
106
|
+
scanner_type=Scanner.get_subclass(scanner_type),
|
|
107
|
+
seed=seed,
|
|
108
|
+
shuffle=shuffle,
|
|
109
|
+
pre_fetch_factor=prefetch_factor,
|
|
110
|
+
num_workers=num_workers,
|
|
111
|
+
num_ranks=world_size,
|
|
112
|
+
rank_idx=rank,
|
|
113
|
+
collate_fn=self.get_collate_fn(),
|
|
114
|
+
drop_last=False
|
|
115
|
+
)
|
|
116
|
+
else:
|
|
117
|
+
raise ValueError(f'Unknown dataloader type: {dataloader_type}')
|
|
98
118
|
|
|
99
119
|
return self._train_dataloader
|
|
100
120
|
|
|
@@ -111,7 +131,7 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
111
131
|
num_workers: int,
|
|
112
132
|
rank: int,
|
|
113
133
|
world_size: int
|
|
114
|
-
) -> DataLoader |
|
|
134
|
+
) -> None | DataLoader | PyTorchDataLoader:
|
|
115
135
|
if self.num_eval_data_path.value() == 0:
|
|
116
136
|
return None
|
|
117
137
|
if self._eval_dataloader is not None:
|
|
@@ -120,25 +140,49 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
120
140
|
weight_list = [w.value() for w in self.eval_data_weights]
|
|
121
141
|
scanner_type = self.scanner_type.value()
|
|
122
142
|
assert scanner_type is not None, 'scanner_type is None'
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
|
|
144
|
+
dataloader_type = self.eval_dataloader_type.value()
|
|
145
|
+
assert dataloader_type is not None, 'dataloader_type is None'
|
|
146
|
+
|
|
147
|
+
dataloader_type = self.eval_dataloader_type.value()
|
|
148
|
+
assert dataloader_type in ('sharded', 'single file'), f'Unknown dataloader type: {dataloader_type}'
|
|
149
|
+
|
|
150
|
+
if dataloader_type == 'sharded':
|
|
151
|
+
self._eval_dataloader = DataLoader(
|
|
152
|
+
batch_size=batch_size,
|
|
153
|
+
path_list=path_list, # type: ignore
|
|
154
|
+
distributor_weights=weight_list, # type: ignore
|
|
155
|
+
scanner_type=Scanner.get_subclass(scanner_type),
|
|
156
|
+
seed=seed,
|
|
157
|
+
shuffle=shuffle,
|
|
158
|
+
pre_fetch_factor=prefetch_factor,
|
|
159
|
+
ignore_error=ignore_error,
|
|
160
|
+
qps=qps,
|
|
161
|
+
instruct_timeout=instruct_timeout,
|
|
162
|
+
worker_timeout=worker_timeout,
|
|
163
|
+
num_workers=num_workers,
|
|
164
|
+
map_fn=self.get_row_processor(),
|
|
165
|
+
flow_fn=self.get_flow_processor(),
|
|
166
|
+
batch_map_fn=self.get_batch_processor(),
|
|
167
|
+
rank_idx=rank,
|
|
168
|
+
num_ranks=world_size,
|
|
169
|
+
)
|
|
170
|
+
elif dataloader_type == 'single file':
|
|
171
|
+
PyTorchDataLoader(
|
|
172
|
+
batch_size=batch_size,
|
|
173
|
+
path_list=path_list, # type: ignore
|
|
174
|
+
scanner_type=Scanner.get_subclass(scanner_type),
|
|
175
|
+
seed=seed,
|
|
176
|
+
shuffle=shuffle,
|
|
177
|
+
pre_fetch_factor=prefetch_factor,
|
|
178
|
+
num_workers=num_workers,
|
|
179
|
+
num_ranks=world_size,
|
|
180
|
+
rank_idx=rank,
|
|
181
|
+
collate_fn=self.get_collate_fn(),
|
|
182
|
+
drop_last=False
|
|
183
|
+
)
|
|
184
|
+
else:
|
|
185
|
+
raise ValueError(f'Unknown dataloader type: {dataloader_type}')
|
|
142
186
|
|
|
143
187
|
return self._eval_dataloader
|
|
144
188
|
|
|
@@ -174,6 +218,9 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
174
218
|
def get_batch_processor(self) -> Callable[[Batch], Batch] | None:
|
|
175
219
|
return None
|
|
176
220
|
|
|
221
|
+
def get_collate_fn(self) -> Callable[[list[Row]], Batch] | None:
|
|
222
|
+
return None
|
|
223
|
+
|
|
177
224
|
|
|
178
225
|
class Task(TaskBase):
|
|
179
226
|
pass
|
|
@@ -230,7 +277,7 @@ class Tasks(Conf):
|
|
|
230
277
|
num_workers: int,
|
|
231
278
|
rank: int,
|
|
232
279
|
world_size: int
|
|
233
|
-
) -> list[DataLoader | None]:
|
|
280
|
+
) -> list[DataLoader | None | PyTorchDataLoader]:
|
|
234
281
|
return [
|
|
235
282
|
task.conf._get_train_dataloader(
|
|
236
283
|
batch_size=batch_size,
|
|
@@ -261,7 +308,7 @@ class Tasks(Conf):
|
|
|
261
308
|
num_workers: int,
|
|
262
309
|
rank: int,
|
|
263
310
|
world_size: int
|
|
264
|
-
) -> list[DataLoader | None]:
|
|
311
|
+
) -> list[DataLoader | None | PyTorchDataLoader]:
|
|
265
312
|
return [
|
|
266
313
|
task.conf._get_eval_dataloader(
|
|
267
314
|
batch_size=batch_size,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|