🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

paddle.nn.functional.silu backward returns -Inf for finite float64 gradient at x=-709 #79630

Open

Description

@ALinrunrun

bug描述 Describe the Bug

paddle.nn.functional.silu has an incorrect backward result for float64 input x = -709.0.

For SiLU, the function is:

silu(x) = x * sigmoid(x)

Its derivative is:

silu'(x) = sigmoid(x) + x * sigmoid(x) * (1 - sigmoid(x))

At x = -709.0, the correct derivative is approximately:

-8.614807714413836e-306

This is a finite, normal float64 value. However, Paddle autograd returns -Inf.

Environment

  • PaddlePaddle version: 3.3.1
  • NumPy version: 2.2.6
  • dtype: float64
  • Device: CPU

Minimal reproducible code

import paddle
import paddle.nn.functional as F

paddle.set_device("cpu")

x = paddle.to_tensor(
    -709.0,
    dtype="float64",
    stop_gradient=False,
)

y = F.silu(x)
y.backward()

wrong = float(x.grad)
expected = -8.614807714413836e-306

print("wrong:", wrong)
print("expected:", expected)

Actual behavior

wrong: -inf

Expected behavior

expected: -8.614807714413836e-306

paddle.nn.functional.silu backward should return a finite float64 gradient for x = -709.0.

Instead, Paddle returns -Inf, even though the correct gradient is finite and representable in float64.

其他补充信息 Additional Supplementary Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions