paddle.expm1 backward returns 0.0 for finite float64 gradient at x=-40
Author: ALinrunrunCreated Aug 6, 2026Updated Aug 6, 2026
Labelsstatus/new-issuetype/bug-report
bug描述 Describe the Bug
paddle.expm1 has an incorrect backward result for float64 input x = -40.0.
Mathematically, the derivative of expm1(x) is exp(x). Therefore:
d/dx expm1(-40.0) = exp(-40.0) = 4.248354255291589e-18This is a finite, normal float64 value. However, Paddle autograd returns 0.0.
Environment
- PaddlePaddle version: 3.3.1
- NumPy version: 2.2.6
- dtype:
float64 - Device: CPU
Minimal reproducible code
import numpy as np
import paddle
paddle.set_device("cpu")
x = paddle.to_tensor(
-40.0,
dtype="float64",
stop_gradient=False,
)
y = paddle.expm1(x)
y.backward()
wrong = float(x.grad)
expected = float(np.exp(np.float64(-40.0)))
print("wrong:", wrong)
print("expected:", expected)Actual behavior
wrong: 0.0Expected behavior
expected: 4.248354255291589e-18paddle.expm1 backward should return exp(x).
For x = -40.0, the correct gradient is finite and representable in float64, but Paddle returns 0.0.
其他补充信息 Additional Supplementary Information
No response
Source: PaddlePaddle/Paddle