[Auto-parallel] 增强stage对层间传递stop_grad=True的参数的支持#73459
Merged
xuxinyi389 merged 5 commits intoPaddlePaddle:developfrom Aug 4, 2025
Merged
[Auto-parallel] 增强stage对层间传递stop_grad=True的参数的支持#73459xuxinyi389 merged 5 commits intoPaddlePaddle:developfrom
xuxinyi389 merged 5 commits intoPaddlePaddle:developfrom
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
xuxinyi389
reviewed
Jun 19, 2025
| # We assume we always send to stage + 1 | ||
| if not self.is_last: | ||
| self.act_send_info[idx] = [self.stage_index + 1] | ||
| if not outputs_meta[idx].stop_gradient: |
|
Sorry to inform you that ea80cdb's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #73459 +/- ##
===========================================
Coverage ? 100.00%
===========================================
Files ? 2
Lines ? 12
Branches ? 0
===========================================
Hits ? 12
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
xuxinyi389
reviewed
Aug 3, 2025
| flat_args = _flatten_args(input_args) | ||
| flat_kwargs = _flatten_args(composite_kwargs) | ||
| flatten_input_tensors = flat_args + flat_kwargs | ||
| grad_required_output_tuple = tuple( |
Contributor
There was a problem hiding this comment.
命名似有问题,grad开头,给人误解为是grad数据。命名为 requires_grad_output_tuple更好
xuxinyi389
reviewed
Aug 3, 2025
| for out in output_tuple | ||
| if isinstance(out, paddle.Tensor) and not out.stop_gradient | ||
| ) | ||
| grad_required_flatten_input_tensors = [ |
Contributor
Author
|
/re-run all-failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Auto Parallel
PR Types
Improvements
Description
use_flash_attention设置为false时,此时跑llama2_13b_hybrid_pp会报错,主要原因在于forward输出到下一个stage的output数,和backward时从下一个stage接收到的gard数不相等,导致backward无法正确计算。
由于在EmbeddingLayer中计算出来的参数需要在forward过程中不断传递,并在每个DecoderLayer中做相关计算,但是注意,除了hidden_states,其它参数在EmbeddingLayer计算之后,只在层间传递,辅助计算。
在每层获取输出时,对其过滤,对于stop_grad为True的参数,进行过滤,并适配相关代码,只在层间传递,不做backward