[cherry-pick] Fix put_along_axis grad kernel crash for integer div-by-zero…#78621
Open
wangbingguang2026 wants to merge 1 commit intoPaddlePaddle:release/3.3from
Open
Conversation
… and 0-size input (PaddlePaddle#78482) * [BugFix] Fix put_along_axis grad kernel crash for integer div-by-zero and 0-size input Fix two crash bugs in put_along_axis backward: 1. SIGFPE in reduce="mul" grad when integer divisor is zero (CPU & GPU) 2. Out-of-bounds memory access in CPU grad kernel when input has 0-size dim Add unit tests covering both scenarios. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [BugFix] Fix codestyle and test issues in put_along_axis fix - clang-format: break long line in gather_scatter_functor.cu - ruff-format: reformat test_put_along_axis_op.py - Fix test_uint8_cpu: integer types do not support autograd (sum_grad kernel not registered for uint8/int32/int64), change to forward-only verification to avoid NotFoundError in CI Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [BugFix] Add float32 backward test for put_along_axis div-by-zero guard Add TestPutAlongAxisMulFloat32DivByZeroGrad to exercise the new zero-divisor guards in gather_scatter_functor.cc/.cu: - test_x_grad_with_zero_in_x: covers x==0 branch in input_grad kernel - test_value_grad_with_zero_in_value: covers value==0 branch in value_grad kernel Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * [BugFix] Force CPU placement in float32 div-by-zero grad test for coverage The TestPutAlongAxisMulFloat32DivByZeroGrad test was not covering gather_scatter_functor.cc because tensors defaulted to GPU on CI machines. Add explicit place=paddle.CPUPlace() to ensure the CPU backward kernel path is exercised. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [BugFix] Improve patch coverage for put_along_axis grad fix 1. gather_scatter_functor.cc: split multi-line expression into separate statements so gcov can attribute execution counts to each line. 2. test_put_along_axis_op.py: add place=CPUPlace() and loss.backward() to TestPutAlongAxisZeroSizeInputGrad so the CPU grad kernel's numel==0 early-return path is exercised in Coverage CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [BugFix] Add zero-size x with non-empty indices test for grad kernel coverage The existing zero-size tests all had indices.numel()==0, which triggers a Python-level early return and never reaches the C++ grad kernel. Add a test case with x_shape=[2,0,3] (x.numel()==0) but idx_shape=[2,1,3] (indices.numel()!=0) so the C++ kernel's numel==0 early-return guard (lines 38-45) is actually exercised. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
|
你的PR提交成功,感谢你对开源项目的贡献! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/3.3 #78621 +/- ##
===============================================
Coverage ? 100.00%
===============================================
Files ? 2
Lines ? 16
Branches ? 0
===============================================
Hits ? 16
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Operator Mechanism
PR Types
Bug fixes
Description
devPR:#78482
是否引起精度变化
否