LMFuser 0.0.7__tar.gz → 0.0.8__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.7 → lmfuser-0.0.8}/PKG-INFO +1 -1
- {lmfuser-0.0.7 → lmfuser-0.0.8}/pyproject.toml +1 -1
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/task.py +33 -9
- {lmfuser-0.0.7 → lmfuser-0.0.8}/.github/workflows/python-publish.yml +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/.gitignore +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/.vscode/settings.json +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/LICENSE +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/README.md +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/__init__.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/model_loader.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/optimizers.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/runners/__init__.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/runners/ddp_runner.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/runners/runner.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/schedulers.py +0 -0
- {lmfuser-0.0.7 → lmfuser-0.0.8}/src/lmfuser/utils.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from typing import Any, Callable
|
|
2
|
-
from collections.abc import Iterable
|
|
2
|
+
from collections.abc import Iterable, Iterator
|
|
3
3
|
|
|
4
4
|
import torch
|
|
5
5
|
from torch import nn
|
|
@@ -12,6 +12,26 @@ from hyperargs import Conf, StrArg, FloatArg, IntArg, OptionArg, add_dependency,
|
|
|
12
12
|
def scanner_type_list() -> list[str]:
|
|
13
13
|
return list(Scanner.all_subclass_names())
|
|
14
14
|
|
|
15
|
+
|
|
16
|
+
class EmptyDataLoader:
|
|
17
|
+
'''
|
|
18
|
+
EmptyDataLoader is a class that provides empty data for running with no data requierment.
|
|
19
|
+
'''
|
|
20
|
+
def __init__(self, init_step: int = 0) -> None:
|
|
21
|
+
self.init_step = init_step
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def epoch(self) -> int:
|
|
25
|
+
return 0
|
|
26
|
+
|
|
27
|
+
def __iter__(self) -> Iterator[Batch]:
|
|
28
|
+
def it_wrap() -> Iterator[Batch]:
|
|
29
|
+
while True:
|
|
30
|
+
yield {'step': torch.tensor(self.init_step)}
|
|
31
|
+
self.init_step += 1
|
|
32
|
+
return it_wrap()
|
|
33
|
+
|
|
34
|
+
|
|
15
35
|
@add_dependency('num_train_data_path', 'train_data_path_list')
|
|
16
36
|
@add_dependency('num_train_data_path', 'train_data_weights')
|
|
17
37
|
class TaskBase(Conf, SubclassTracer):
|
|
@@ -25,11 +45,11 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
25
45
|
|
|
26
46
|
scanner_type = OptionArg(default='C4Scanner', option_fn=scanner_type_list)
|
|
27
47
|
|
|
28
|
-
train_dataloader_type = OptionArg(default='single file', options=['single file', 'sharded'])
|
|
29
|
-
eval_dataloader_type = OptionArg(default='single file', options=['single file', 'sharded'])
|
|
48
|
+
train_dataloader_type = OptionArg(default='single file', options=['single file', 'sharded', 'empty'])
|
|
49
|
+
eval_dataloader_type = OptionArg(default='single file', options=['single file', 'sharded', 'empty'])
|
|
30
50
|
|
|
31
|
-
_train_dataloader: DataLoader | None | PyTorchDataLoader = None
|
|
32
|
-
_eval_dataloader: DataLoader | None | PyTorchDataLoader = None
|
|
51
|
+
_train_dataloader: DataLoader | None | PyTorchDataLoader | EmptyDataLoader = None
|
|
52
|
+
_eval_dataloader: DataLoader | None | PyTorchDataLoader | EmptyDataLoader = None
|
|
33
53
|
|
|
34
54
|
@monitor_on('num_train_data_path')
|
|
35
55
|
def set_train_path_list(self) -> None:
|
|
@@ -66,7 +86,7 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
66
86
|
num_workers: int,
|
|
67
87
|
rank: int,
|
|
68
88
|
world_size: int
|
|
69
|
-
) -> None | DataLoader | PyTorchDataLoader:
|
|
89
|
+
) -> None | DataLoader | PyTorchDataLoader | EmptyDataLoader:
|
|
70
90
|
if self.num_train_data_path.value() == 0:
|
|
71
91
|
return None
|
|
72
92
|
if self._train_dataloader is not None:
|
|
@@ -113,6 +133,8 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
113
133
|
collate_fn=self.get_collate_fn(),
|
|
114
134
|
drop_last=False
|
|
115
135
|
)
|
|
136
|
+
elif dataloader_type == 'empty':
|
|
137
|
+
self._train_dataloader = EmptyDataLoader(init_step=0)
|
|
116
138
|
else:
|
|
117
139
|
raise ValueError(f'Unknown dataloader type: {dataloader_type}')
|
|
118
140
|
|
|
@@ -131,7 +153,7 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
131
153
|
num_workers: int,
|
|
132
154
|
rank: int,
|
|
133
155
|
world_size: int
|
|
134
|
-
) -> None | DataLoader | PyTorchDataLoader:
|
|
156
|
+
) -> None | DataLoader | PyTorchDataLoader | EmptyDataLoader:
|
|
135
157
|
if self.num_eval_data_path.value() == 0:
|
|
136
158
|
return None
|
|
137
159
|
if self._eval_dataloader is not None:
|
|
@@ -181,6 +203,8 @@ class TaskBase(Conf, SubclassTracer):
|
|
|
181
203
|
collate_fn=self.get_collate_fn(),
|
|
182
204
|
drop_last=False
|
|
183
205
|
)
|
|
206
|
+
elif dataloader_type == 'empty':
|
|
207
|
+
self._eval_dataloader = EmptyDataLoader(init_step=0)
|
|
184
208
|
else:
|
|
185
209
|
raise ValueError(f'Unknown dataloader type: {dataloader_type}')
|
|
186
210
|
|
|
@@ -277,7 +301,7 @@ class Tasks(Conf):
|
|
|
277
301
|
num_workers: int,
|
|
278
302
|
rank: int,
|
|
279
303
|
world_size: int
|
|
280
|
-
) -> list[DataLoader | None | PyTorchDataLoader]:
|
|
304
|
+
) -> list[DataLoader | None | PyTorchDataLoader | EmptyDataLoader]:
|
|
281
305
|
return [
|
|
282
306
|
task.conf._get_train_dataloader(
|
|
283
307
|
batch_size=batch_size,
|
|
@@ -308,7 +332,7 @@ class Tasks(Conf):
|
|
|
308
332
|
num_workers: int,
|
|
309
333
|
rank: int,
|
|
310
334
|
world_size: int
|
|
311
|
-
) -> list[DataLoader | None | PyTorchDataLoader]:
|
|
335
|
+
) -> list[DataLoader | None | PyTorchDataLoader | EmptyDataLoader]:
|
|
312
336
|
return [
|
|
313
337
|
task.conf._get_eval_dataloader(
|
|
314
338
|
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
|