Skip to content

[SWE-Paddle] Fix broadcast gradient in the PaddlePaddle__Paddle-76736 gold patch - #1548

Open
Manfredss wants to merge 2 commits into
PaddlePaddle:masterfrom
Manfredss:swe-paddle-76736-fix
Open

[SWE-Paddle] Fix broadcast gradient in the PaddlePaddle__Paddle-76736 gold patch#1548
Manfredss wants to merge 2 commits into
PaddlePaddle:masterfrom
Manfredss:swe-paddle-76736-fix

Conversation

@Manfredss

@Manfredss Manfredss commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

atan2 梯度计算时忘了更新“压扁”后的形状,导致 CPU 上维度检查失败;修复方法是在求和前重新推断正确的形状,修完后 CPU 上就正常了。

@sunzhongkai588 Thx

Manfredss and others added 2 commits August 25, 2026 16:43
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant