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

Support pp + no_recompute_layer. #9373

Merged
merged 1 commit into from
Nov 6, 2024
Merged
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
9 changes: 6 additions & 3 deletions paddlenlp/transformers/llama/modeling_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ def forward(self, args):
attn_mask_startend_row_indices = None

has_gradient = not hidden_states.stop_gradient
if self.enable_recompute and self.config.recompute_granularity == "full" and has_gradient:
if (
self.enable_recompute
and self.layerwise_recompute
and self.config.recompute_granularity == "full"
and has_gradient
):
if attention_mask is not None or alibi is not None or attn_mask_startend_row_indices is not None:
hidden_states = recompute(
super().forward,
Expand Down Expand Up @@ -340,8 +345,6 @@ def __init__(self, config):
self.recompute_granularity = self.config.recompute_granularity
self.pp_recompute_interval = self.config.pp_recompute_interval
self.no_recompute_layers = config.no_recompute_layers if config.no_recompute_layers is not None else []
if self.recompute_granularity == "full":
assert len(self.no_recompute_layers) == 0, "for pp with full recompute, no_recompute_layers is not support"

virtual_pp_degree = getattr(self.config, "virtual_pp_degree", 1)

Expand Down
Loading