Skip to content
New issue

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

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

Already on GitHub? # to your account

fixed the init problem in tensor parallel #9452

Merged
merged 1 commit into from
Nov 21, 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
13 changes: 11 additions & 2 deletions paddlenlp/ops/distributed/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

try:
from paddle.distributed.fleet import fleet
from paddle.distributed.fleet.meta_parallel import get_rng_state_tracker
except Exception:
import warnings

Expand Down Expand Up @@ -88,8 +89,16 @@
self._weight_attr = weight_attr
self._name = name

self.weight = self.create_parameter(attr=self._weight_attr, shape=self._size, dtype=self._dtype, is_bias=False)
self.weight.is_distributed = True
if self.is_mp and paddle.in_dynamic_mode():
with get_rng_state_tracker().rng_state():
self.weight = self.create_parameter(

Check warning on line 94 in paddlenlp/ops/distributed/parallel.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/ops/distributed/parallel.py#L92-L94

Added lines #L92 - L94 were not covered by tests
attr=self._weight_attr, shape=self._size, dtype=self._dtype, is_bias=False
)
else:
self.weight = self.create_parameter(

Check warning on line 98 in paddlenlp/ops/distributed/parallel.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/ops/distributed/parallel.py#L98

Added line #L98 was not covered by tests
attr=self._weight_attr, shape=self._size, dtype=self._dtype, is_bias=False
)
self.weight.is_distributed = True if self.is_mp else False

Check warning on line 101 in paddlenlp/ops/distributed/parallel.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/ops/distributed/parallel.py#L101

Added line #L101 was not covered by tests

startup_block = paddle.static.default_startup_program().global_block()
main_block = paddle.static.default_main_program().global_block()
Expand Down
1 change: 1 addition & 0 deletions paddlenlp/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,7 @@
if self.args.amp_master_grad:
mix_precision_utils.MixPrecisionLayer(model, dtype=self.amp_dtype) # return value has no use
model = fleet.distributed_model(model)

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

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/trainer.py#L2079

Added line #L2079 was not covered by tests
if self.args.amp_master_grad:
self.optimizer = mix_precision_utils.MixPrecisionOptimizer(self.optimizer)
self.optimizer = fleet.distributed_optimizer(self.optimizer)
Expand Down
Loading