project-llm-trainer 0.4.4__py3-none-any.whl → 0.4.7__py3-none-any.whl
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.
Potentially problematic release.
This version of project-llm-trainer might be problematic. Click here for more details.
- llm_trainer/ds_checkpoint.py +27 -13
- llm_trainer/generate_utils.py +6 -6
- llm_trainer/trainer.py +2 -2
- {project_llm_trainer-0.4.4.dist-info → project_llm_trainer-0.4.7.dist-info}/METADATA +1 -1
- {project_llm_trainer-0.4.4.dist-info → project_llm_trainer-0.4.7.dist-info}/RECORD +14 -14
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/calc_intermediate_size +0 -0
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/ddp_train +0 -0
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/ds_train +0 -0
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/plot_loss +0 -0
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/plot_lr +0 -0
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/py_train +0 -0
- {project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/smart_train +0 -0
- {project_llm_trainer-0.4.4.dist-info → project_llm_trainer-0.4.7.dist-info}/WHEEL +0 -0
- {project_llm_trainer-0.4.4.dist-info → project_llm_trainer-0.4.7.dist-info}/top_level.txt +0 -0
llm_trainer/ds_checkpoint.py
CHANGED
|
@@ -69,7 +69,7 @@ def load_ds_checkpoint_for_eval(model: nn.Module):
|
|
|
69
69
|
|
|
70
70
|
def _get_ds_full_state_dict_on_rank0(model: DeepSpeedEngine) -> Optional[dict]:
|
|
71
71
|
"""
|
|
72
|
-
|
|
72
|
+
需要在所有rank上调用,然后只有rank0有值
|
|
73
73
|
"""
|
|
74
74
|
|
|
75
75
|
if model.zero_optimization_stage() != 3:
|
|
@@ -77,18 +77,32 @@ def _get_ds_full_state_dict_on_rank0(model: DeepSpeedEngine) -> Optional[dict]:
|
|
|
77
77
|
return {k: v.cpu().clone() for k, v in model.module.state_dict().items()}
|
|
78
78
|
return None
|
|
79
79
|
|
|
80
|
-
# ZeRO-3
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if
|
|
84
|
-
with
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
# --- ZeRO-3 ---
|
|
81
|
+
# 只调用一次 GatheredParameters,传入所有参数
|
|
82
|
+
with deepspeed.zero.GatheredParameters(model.parameters(), modifier_rank=0):
|
|
83
|
+
if TrainerTools().parallel.is_main_process:
|
|
84
|
+
# 在这个 'with' 代码块内,rank 0 上的 model.module 拥有完整的参数
|
|
85
|
+
# 所以我们可以像操作普通模型一样直接调用 state_dict()
|
|
86
|
+
full_state_dict = model.module.state_dict()
|
|
87
|
+
|
|
88
|
+
# 将其克隆到 CPU 并返回
|
|
89
|
+
return {k: v.cpu().clone() for k, v in full_state_dict.items()}
|
|
90
|
+
|
|
91
|
+
# 其他 rank 执行到这里时,上下文结束,直接返回 None
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
# # ZeRO-3
|
|
95
|
+
# state_dict_on_rank_0 = {}
|
|
96
|
+
# for param_name, param in model.module.named_parameters():
|
|
97
|
+
# if hasattr(param, 'ds_id'):
|
|
98
|
+
# with deepspeed.zero.GatheredParameters(param, modifier_rank=0):
|
|
99
|
+
# if TrainerTools().parallel.is_main_process:
|
|
100
|
+
# state_dict_on_rank_0[param_name] = param.data.to(torch.float32).cpu().clone()
|
|
101
|
+
# else:
|
|
102
|
+
# if TrainerTools().parallel.is_main_process:
|
|
103
|
+
# state_dict_on_rank_0[param_name] = param.data.to(torch.float32).cpu().clone()
|
|
104
|
+
#
|
|
105
|
+
# return state_dict_on_rank_0 if TrainerTools().parallel.is_main_process else None
|
|
92
106
|
|
|
93
107
|
|
|
94
108
|
def get_ds_model_params(model: nn.Module):
|
llm_trainer/generate_utils.py
CHANGED
|
@@ -175,7 +175,7 @@ def _generate(
|
|
|
175
175
|
if k and k != 0:
|
|
176
176
|
logits = _top_k_warper(logits, k, device)
|
|
177
177
|
|
|
178
|
-
if p and
|
|
178
|
+
if p and 0 < p <= 1:
|
|
179
179
|
logits = _top_p_warper(logits, p)
|
|
180
180
|
|
|
181
181
|
if multinomial:
|
|
@@ -210,7 +210,7 @@ def _streaming_generate(
|
|
|
210
210
|
max_new_tokens: int,
|
|
211
211
|
temperature: Optional[float] = 1.0,
|
|
212
212
|
k: Optional[int] = None,
|
|
213
|
-
p: Optional[float] =
|
|
213
|
+
p: Optional[float] = None,
|
|
214
214
|
pixel_values: Optional[torch.Tensor] = None,
|
|
215
215
|
tokens_per_image: int = -1,
|
|
216
216
|
suppress_tokens: Optional[List[int]] = None,
|
|
@@ -244,8 +244,8 @@ def streaming_generate(
|
|
|
244
244
|
max_position_embeddings: int,
|
|
245
245
|
max_new_tokens: int,
|
|
246
246
|
temperature: Optional[float] = 1.0,
|
|
247
|
-
k: Optional[int] =
|
|
248
|
-
p: Optional[float] =
|
|
247
|
+
k: Optional[int] = None,
|
|
248
|
+
p: Optional[float] = None,
|
|
249
249
|
pixel_values: Optional[torch.Tensor] = None,
|
|
250
250
|
tokens_per_image: int = -1,
|
|
251
251
|
suppress_tokens: Optional[List[int]] = None,
|
|
@@ -278,7 +278,7 @@ def generate(
|
|
|
278
278
|
max_new_tokens: int,
|
|
279
279
|
temperature: Optional[float] = 1.0,
|
|
280
280
|
k: Optional[int] = None,
|
|
281
|
-
p: Optional[float] =
|
|
281
|
+
p: Optional[float] = None,
|
|
282
282
|
pixel_values: Optional[torch.Tensor] = None,
|
|
283
283
|
tokens_per_image: int = -1,
|
|
284
284
|
suppress_tokens: Optional[List[int]] = None,
|
|
@@ -382,7 +382,7 @@ def batch_generate(
|
|
|
382
382
|
if k and k != 0:
|
|
383
383
|
logits = _top_k_warper(logits, k, device)
|
|
384
384
|
|
|
385
|
-
if p and
|
|
385
|
+
if p and 0 < p <= 1:
|
|
386
386
|
logits = _top_p_warper(logits, p)
|
|
387
387
|
|
|
388
388
|
prob = logits.softmax(dim=-1)
|
llm_trainer/trainer.py
CHANGED
|
@@ -421,7 +421,7 @@ class Trainer:
|
|
|
421
421
|
|
|
422
422
|
if TrainerTools().parallel.is_main_process:
|
|
423
423
|
eval_prompt, eval_image_tag = self._get_eval_data()
|
|
424
|
-
if isinstance(self.
|
|
424
|
+
if isinstance(self.train_config, VLMConfig) and self.pixel_values_provider and eval_image_tag:
|
|
425
425
|
eval_pixel_values = self.pixel_values_provider([eval_image_tag])
|
|
426
426
|
else:
|
|
427
427
|
eval_pixel_values = None
|
|
@@ -445,7 +445,7 @@ class Trainer:
|
|
|
445
445
|
|
|
446
446
|
if TrainerTools().parallel.is_main_process:
|
|
447
447
|
eval_prompt, eval_image_tag = self._get_eval_data()
|
|
448
|
-
if isinstance(self.
|
|
448
|
+
if isinstance(self.train_config, VLMConfig) and self.pixel_values_provider and eval_image_tag:
|
|
449
449
|
eval_pixel_values = self.pixel_values_provider([eval_image_tag])
|
|
450
450
|
else:
|
|
451
451
|
eval_pixel_values = None
|
|
@@ -3,10 +3,10 @@ llm_trainer/checkpoint.py,sha256=yZcExxneN2yzvWxRiK-pstMWs35LV7GiOfqcLq-S6vc,574
|
|
|
3
3
|
llm_trainer/dataset.py,sha256=4QlOo0SFB5816BUYegQjgobUqTUMQvdmZMM_OEAMSjE,4347
|
|
4
4
|
llm_trainer/dcp.py,sha256=PkD97DyrOtoTKn4FJsfL3VqAy4dxufgjdzJEz8-Cnoc,3635
|
|
5
5
|
llm_trainer/dpo_trainer.py,sha256=rC_I5ipesSlP3gFK_SG2GB8NbgJAMu4K7KLxkAS-aRY,13406
|
|
6
|
-
llm_trainer/ds_checkpoint.py,sha256=
|
|
6
|
+
llm_trainer/ds_checkpoint.py,sha256=x_tjgJR47P8gVwV4qAnTUCGwx7eVq2Epw0vOVV7fkYo,4925
|
|
7
7
|
llm_trainer/eval.py,sha256=NDm8PbXLch7xT81xPYPRCNrcrB_Xj5GDJSCxyVwUOp4,1524
|
|
8
8
|
llm_trainer/fsdp_checkpoint.py,sha256=lqZFzHyWyfzuCq_81kQNtJd2qaiMeY1N5BCEMnrJTBw,3192
|
|
9
|
-
llm_trainer/generate_utils.py,sha256=
|
|
9
|
+
llm_trainer/generate_utils.py,sha256=BmjpCrus_jvJ3SM2KS1bQNzJWAFnpJ9mI28iBWXZpvo,15206
|
|
10
10
|
llm_trainer/grpo_trainer.py,sha256=bZPrxhyPQLAnFzWhI7hhA6fpuKVNwj7nOm9k0ku9aK4,15977
|
|
11
11
|
llm_trainer/log.py,sha256=LxqTGRNZUGMTSQCePRpk-rYyxSnSIbT4kOdP8Fbzr0M,462
|
|
12
12
|
llm_trainer/loss.py,sha256=Yv3fsaVuZ5AhnGPJOr5vEMb_tM2urR6mCb4DBbrHHI8,6030
|
|
@@ -20,16 +20,16 @@ llm_trainer/sft_trainer.py,sha256=gxQA7T1o1QGUsHp2CX1Qb_fO5LppBJuNbc0H4ixCYUA,17
|
|
|
20
20
|
llm_trainer/tokenizer.py,sha256=A7TYYUbtPf75kjCvWP7yBui4xZBObMk2aPem62YpwpY,6776
|
|
21
21
|
llm_trainer/tools.py,sha256=O45-20wRmh-nyTfU-U-XtjbKAoe7boEIsUvWT_NaKx4,3041
|
|
22
22
|
llm_trainer/train_configs.py,sha256=arnet3tIzgVnwshod08F1jE7r4I7e-SIgMy55IagPnE,15971
|
|
23
|
-
llm_trainer/trainer.py,sha256=
|
|
23
|
+
llm_trainer/trainer.py,sha256=Zy1oesBfsFlDedZ4hn3gcAkTrpi5fr76bFFQikfAkak,25351
|
|
24
24
|
llm_trainer/utils.py,sha256=-ivhMF0d999va13S1wt2uBvtVw8Nvr3uBzhaUFKL04Q,6826
|
|
25
|
-
project_llm_trainer-0.4.
|
|
26
|
-
project_llm_trainer-0.4.
|
|
27
|
-
project_llm_trainer-0.4.
|
|
28
|
-
project_llm_trainer-0.4.
|
|
29
|
-
project_llm_trainer-0.4.
|
|
30
|
-
project_llm_trainer-0.4.
|
|
31
|
-
project_llm_trainer-0.4.
|
|
32
|
-
project_llm_trainer-0.4.
|
|
33
|
-
project_llm_trainer-0.4.
|
|
34
|
-
project_llm_trainer-0.4.
|
|
35
|
-
project_llm_trainer-0.4.
|
|
25
|
+
project_llm_trainer-0.4.7.data/scripts/calc_intermediate_size,sha256=AggpgNHokJiJMbEtVdOnolqr_4bH3i1UYuZNEAzC2Gc,460
|
|
26
|
+
project_llm_trainer-0.4.7.data/scripts/ddp_train,sha256=x81AasaN2-9TwARFFF1l7iV1LmfMQ0bLw0i_CGbOwSw,299
|
|
27
|
+
project_llm_trainer-0.4.7.data/scripts/ds_train,sha256=qL3qc3TcedBCw98UZUjW07ONcErRawLE1HymW2AmscA,265
|
|
28
|
+
project_llm_trainer-0.4.7.data/scripts/plot_loss,sha256=MzFcdJESlVr1srj4Td6-AxPGUKkfB_QEcJwm0Bd-5fU,910
|
|
29
|
+
project_llm_trainer-0.4.7.data/scripts/plot_lr,sha256=w_7XR_x3KYYyboeOVAeu_I4fveLFI-C0wBmRrNlmWUI,894
|
|
30
|
+
project_llm_trainer-0.4.7.data/scripts/py_train,sha256=tOp9TquORQeU8XN5H7OVIk5O0Ypwi34p_GENxTwgwdk,265
|
|
31
|
+
project_llm_trainer-0.4.7.data/scripts/smart_train,sha256=Pmt4Q0to4Hoz82iB9uFPZuz7uahNUbfE7FR1940EBy8,716
|
|
32
|
+
project_llm_trainer-0.4.7.dist-info/METADATA,sha256=u4_cQkQaH9QKqG_XcWiXzGHD5rnrzqHjvJWQvgVnkZQ,195
|
|
33
|
+
project_llm_trainer-0.4.7.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
34
|
+
project_llm_trainer-0.4.7.dist-info/top_level.txt,sha256=LtRFg28i0QIG7iBCD2t095oSco99LCtkijibS9cMGik,12
|
|
35
|
+
project_llm_trainer-0.4.7.dist-info/RECORD,,
|
{project_llm_trainer-0.4.4.data → project_llm_trainer-0.4.7.data}/scripts/calc_intermediate_size
RENAMED
|
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
|