Repository navigation
[XPU] Validate replication_pad2d_backward channel dimension - #4758
Merged
Merged
Conversation
Contributor
Author
|
Verified on Intel Data Center GPU Max 1100 (torch Reproducer — mismatched channel now raises, valid case still works: Regression test |
laifenxiawucha
force-pushed
the
agent/fix-replication-pad2d-channel-guard
branch
from
August 25, 2026 08:37
128a055 to
e732647
Compare
laifenxiawucha
force-pushed
the
agent/fix-replication-pad2d-channel-guard
branch
from
August 25, 2026 08:40
e732647 to
3769b11
Compare
laifenxiawucha
force-pushed
the
agent/fix-replication-pad2d-channel-guard
branch
from
August 31, 2026 03:13
3769b11 to
bfacd47
Compare
replication_pad2d_backward only validated the spatial (width/height) dims of grad_output but not the channel/plane dim. A grad_output whose channel count does not match the input (e.g. 0 channels) passed the checks, a non-empty grad_input was allocated from the input shape, and the kernel then read grad_output out of bounds -> SIGSEGV. Add a channel-dim TORCH_CHECK mirroring the existing 3d backward check and the CPU/CUDA fix in pytorch/pytorch#189463, plus a regression test. Fixes #4754
laifenxiawucha
force-pushed
the
agent/fix-replication-pad2d-channel-guard
branch
from
September 2, 2026 03:30
bfacd47 to
9a7c25a
Compare
CuiYifeng
approved these changes
Oct 8, 2026
ZhaoqiongZ
approved these changes
Oct 13, 2026
Contributor
|
@torchxpubot merge |
Contributor
|
PR has been successfully merged by @ZhaoqiongZ. |
minmingzhu
pushed a commit
to minmingzhu/torch-xpu-ops
that referenced
this pull request
Oct 28, 2026
## Background XPU `replication_pad2d_backward` validates the spatial dimensions of `grad_output` but not its channel dimension. A mismatch can pass validation and lead to an invalid kernel read instead of a user-facing error. ## Upstream - [pytorch/pytorch#189463](pytorch/pytorch#189463) adds the analogous channel validation to upstream CPU/CUDA padding code. XPU has a separate 2-D backward implementation, so it needs the guard here. ## Fix - validate the `grad_output` channel count before launching the XPU kernel - preserve valid backward behavior - add mismatch, valid-input, and CPU-parity coverage ## Before and after | Case | Before | After | |---|---|---| | Channel mismatch | Accepted; may read out of bounds | Raises `gradOutput channel unexpected` | | Matching channels | Works | Still works and matches CPU | ## Testing Linux XPU `op_regression` in [CI run 34858341206](https://github.com/intel/torch-xpu-ops/actions/runs/34858341206): 3 passed, 0 failed. Fixes intel#4754 --------- Co-authored-by: jyz <jyz@intel.com> Co-authored-by: laifenxiawucha <184592536+laifenxiawucha@users.noreply.github.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.
Background
XPU
replication_pad2d_backwardvalidates the spatial dimensions ofgrad_outputbut not its channel dimension. A mismatch can pass validation and lead to an invalid kernel read instead of a user-facing error.Upstream
Fix
grad_outputchannel count before launching the XPU kernelBefore and after
gradOutput channel unexpectedTesting
Linux XPU
op_regressionin CI run 34858341206: 3 passed, 0 failed.Fixes #4754