Skip to content

GPU tf.math.zeta returns NaN for finite s and infinite q #121501

Description

@ALinrunrun

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

tf-nightly 2.22.0.dev20260616

Custom code

Yes

OS platform and distribution

Linux-6.17.0-29-generic-x86_64-with-glibc2.39

Mobile device

No response

Python version

3.11.15

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

On GPU, tf.math.zeta returns NaN when s = 2.0 and q = inf.

The problematic input is tf.math.zeta([2.0], [inf]). TensorFlow GPU returns NaN, but the expected result is 0.0.

Expected behavior

tf.math.zeta([2.0], [inf]) should return 0.0.

Expected full result:

[0.0]

Standalone code to reproduce the issue

#!/usr/bin/env python3
import os
import sys

os.environ.setdefault("TF_CPP_MIN_LOG_LEVEL", "3")
os.environ.setdefault("TF_ENABLE_ONEDNN_OPTS", "0")

import numpy as np
import tensorflow as tf

s = np.array([2.0], dtype=np.float32)
q = np.array([np.inf], dtype=np.float32)
correct = np.array([0.0], dtype=np.float32)

gpus = tf.config.list_logical_devices("GPU")
if not gpus:
    print("missing target: TensorFlow GPU is not available")
    sys.exit(2)

with tf.device("/GPU:0"):
    wrong = tf.math.zeta(tf.constant(s), tf.constant(q)).numpy()

print("wrong:", wrong.tolist())
print("correct:", correct.tolist())

if not np.array_equal(wrong, correct, equal_nan=True):
    sys.exit(0)

sys.exit(1)

Relevant log output

wrong: [nan]
correct: [0.0]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions