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

Update sequence_parallel for predict #8551

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
6 changes: 5 additions & 1 deletion paddlenlp/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
import paddle.nn as nn
from packaging import version
from paddle import framework
from paddle.base import core

try:
from paddle.base import core
except:
core = None

Check warning on line 47 in paddlenlp/trainer/trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/trainer.py#L46-L47

Added lines #L46 - L47 were not covered by tests
from paddle.distributed import fleet
from paddle.distributed.fleet.meta_optimizers.dygraph_optimizer.hybrid_parallel_optimizer import (
HybridParallelOptimizer,
Expand Down
14 changes: 11 additions & 3 deletions paddlenlp/transformers/linear_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

import paddle.distributed.fleet.meta_parallel as mpu
from paddle import nn
from paddle.distributed.fleet.utils import sequence_parallel_utils

try:
from paddle.distributed.fleet.utils import sequence_parallel_utils
except:
sequence_parallel_utils = None

Check warning on line 25 in paddlenlp/transformers/linear_utils.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/linear_utils.py#L24-L25

Added lines #L24 - L25 were not covered by tests

from paddlenlp.transformers.mc2_parallel_linear import (
MC2ColumnSeqParallelLinear,
Expand All @@ -29,8 +33,12 @@
Linear = nn.Linear
ColumnParallelLinear = mpu.ColumnParallelLinear
RowParallelLinear = mpu.RowParallelLinear
ColumnSequenceParallelLinear = sequence_parallel_utils.ColumnSequenceParallelLinear
RowSequenceParallelLinear = sequence_parallel_utils.RowSequenceParallelLinear
try:
ColumnSequenceParallelLinear = sequence_parallel_utils.ColumnSequenceParallelLinear
RowSequenceParallelLinear = sequence_parallel_utils.RowSequenceParallelLinear
except:
ColumnSequenceParallelLinear = None
RowSequenceParallelLinear = None

Check warning on line 41 in paddlenlp/transformers/linear_utils.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/linear_utils.py#L39-L41

Added lines #L39 - L41 were not covered by tests

if get_env_device() == "npu":
if MC2ColumnSeqParallelLinear is not None and MC2RowSeqParallelLinear is not None:
Expand Down
Loading