Skip to content

Commit

Permalink
fix some bug in dpo
Browse files Browse the repository at this point in the history
  • Loading branch information
huxinye committed Sep 18, 2024
1 parent c4ef7da commit cc28617
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions llm/alignment/dpo/dpo_argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ class DPOModelArgument:
default=False,
metadata={"help": "whether to use sequence parallel"},
)
tensor_parallel_output: Optional[bool] = field(
default=True,
metadata={"help": "whether to output logits in distributed status"},
)
2 changes: 1 addition & 1 deletion llm/alignment/dpo/run_dpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def main():
tensor_parallel_rank=training_args.tensor_parallel_rank,
recompute_granularity=model_args.recompute_granularity,
use_flash_attention=model_args.use_flash_attention,
tensor_parallel_output=True,
tensor_parallel_output=model_args.tensor_parallel_output,
)
if training_args.pipeline_parallel_degree > 1:
raise ValueError("DPO does not support pipeline parallelism yet.")
Expand Down
4 changes: 1 addition & 3 deletions paddlenlp/transformers/gemma/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,9 +1558,7 @@ def forward(

# if labels is None,means we need full output, instead of tensor_parallel_output
# tensor_parallel_output is togather with ParallelCrossEntropy
tensor_parallel_output = (
self.config.tensor_parallel_output and labels is not None and self.config.tensor_parallel_degree > 1
)
tensor_parallel_output = self.config.tensor_parallel_output and self.config.tensor_parallel_degree > 1

logits = self.lm_head(hidden_states, tensor_parallel_output=tensor_parallel_output)

Expand Down

0 comments on commit cc28617

Please sign in to comment.