Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2d5b8c

Browse files
authored
[bugfix] Fix duplicate logging in Megatron GRPO (#6782)
1 parentb5c7887 commitc2d5b8c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎swift/megatron/trainers/grpo_trainer.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,8 @@ def _pad_or_trim_last_dim(tensor: Optional[torch.Tensor], target_len: int) -> Op
12781278
reporting_metric= {**avg_metric,**custom_metrics}
12791279

12801280
# log_completions
1281-
ifself.log_completionsandself.is_main_processand (self._step-1)%self.steps_per_generation==0:
1281+
if (self.log_completionsandself.is_main_processand (self._step-1)%self.steps_per_generation==0
1282+
andself._step!=self._last_logged_step):
12821283
table= {
12831284
'gen_step': [self._step-1]*len(self._logs['prompt']),
12841285
'prompt':list(self._logs['prompt']),
@@ -1297,6 +1298,7 @@ def _pad_or_trim_last_dim(tensor: Optional[torch.Tensor], target_len: int) -> Op
12971298
# wandb_writer.define_metric('completions', step_metric='gen_step')
12981299
# self.init_custom_metric = True
12991300
wandb_writer.log({'completions':wandb.Table(dataframe=df)})
1301+
self._last_logged_step=self._step
13001302

13011303
returnloss,reporting_metric
13021304

@@ -1486,6 +1488,7 @@ def _prepare_metrics(self):
14861488
self.wandb_log_unique_prompts=args.wandb_log_unique_prompts
14871489
self.jsonl_writer=JsonlWriter(os.path.join(args.save,'completions.jsonl'),write_on_rank='last')
14881490
self.init_custom_metric=False
1491+
self._last_logged_step=-1
14891492
self._logs= {
14901493
'prompt':deque(maxlen=args.generation_batch_size),
14911494
'completion':deque(maxlen=args.generation_batch_size),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp