Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use training_args to contorl split input #9944

Open
wants to merge 1 commit into
base: incubate/paddlenlp-fleety
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions paddlenlp/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,17 @@ def _inner_training_loop(
self.control = self.callback_handler.on_epoch_begin(args, self.state, self.control)

for step, inputs in enumerate(epoch_iterator):
if self.args.use_hybrid_parallel and self.args.sep_parallel_degree > 1:
if (
self.args.use_hybrid_parallel
and self.args.sep_parallel_degree > 1
and self.args.split_inputs_sequence_dim
):
inputs = split_inputs_sequence_dim(inputs)
if self.args.use_hybrid_parallel and self.args.context_parallel_degree > 1:
if (
self.args.use_hybrid_parallel
and self.args.context_parallel_degree > 1
and self.args.split_inputs_sequence_dim
):
inputs = split_inputs_sequence_dim_load_balance(inputs)
if self.args.ignore_data_skip:
self.timers and self.timers("read-data").stop()
Expand Down
8 changes: 8 additions & 0 deletions paddlenlp/trainer/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,14 @@ class TrainingArguments:
)
},
)
split_inputs_sequence_dim: bool = field(
default=True,
metadata={
"help": (
"The paddle sequence parallel strategy can reduce the GPU memory of activation to 1/sep .If it is true, trainer will cut input in sequence dim "
)
},
)
context_parallel_degree: int = field(
default=-1,
metadata={
Expand Down
Loading