PyTorch GPU pad backward can corrupt memory on huge padding
A reported int32 overflow lets replication_pad3d_backward write outside its CUDA allocation, while the CPU path rejects the same input.
A bug report against PyTorch 2.13 says the CUDA implementation of three-dimensional replication-pad backward can silently corrupt device memory when each padding value is exactly 2^31, one past the largest signed 32-bit integer.
The front end does not check that padding fits in that range before the kernel runs. The oversized values wrap in 32-bit arithmetic, so the derived output width becomes a large negative number and the kernel still launches. Under a CUDA memory checker, that launch produced dozens of out-of-bounds atomic writes into global memory. A bare run surfaces a CUDA error only when the launch is synchronized.
The same tensor shapes and padding on CPU raise a runtime error instead of writing memory. That message already prints the wrapped negative width, which indicates the host size math also happens after the truncation. The two backends therefore disagree: CPU fails, GPU can corrupt.
The report asks for a single front-end check that rejects padding outside the int32 range on both backends before any kernel starts. Ordinary padding sizes are far below 2^31, so this is not a typical training failure, but it is a memory-safety hole for any caller that can pass untrusted padding into the operation.