[SWE-Paddle] Fix broadcast gradient in the PaddlePaddle__Paddle-76736 gold patch - #1548
Open
Manfredss wants to merge 2 commits into
Open
[SWE-Paddle] Fix broadcast gradient in the PaddlePaddle__Paddle-76736 gold patch#1548Manfredss wants to merge 2 commits into
Manfredss wants to merge 2 commits into
Conversation
The merged atan2 C++ sink reduces the broadcast gradient straight into x_grad / y_grad, whose dims still carry the un-reduced rank at that point (GeneralBinaryGradInferMeta). The CPU Eigen reduce path uses output->dims() verbatim, so Atan2GradKernel aborts with "arity(dims):2 != D:1" whenever a gradient is reduced along an inner broadcast axis, for example x [2, 1] against y [1, 3]. GPU is unaffected because its reduce computes the output shape itself, which is why the upstream PR passed CI. That made tests/test.sh's test_dygraph_broadcast_gradient_values fail on the gold patch for two verifier rounds while it passes on the base commit, where atan2 still broadcasts in Python before the operator runs. Run SumInferMeta on the gradient tensor before SumKernel, mirroring phi::ReduceAsKernel, and correct the hunk header line count (already off by two before this change). Verified at the pinned base commit: all ten selected nodes pass on CPU with the fixed gold, and the same harness gives 9/10 with the unfixed gold. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
atan2 梯度计算时忘了更新“压扁”后的形状,导致 CPU 上维度检查失败;修复方法是在求和前重新推断正确的形状,修完后 CPU 上就正常了。
@sunzhongkai588 Thx