Skip to content

[XLA] Far-tail truncated normal sampling collapses to the lower bound #128959

Closed

Description

@xyt66665000

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

TensorFlow: 2.23.0-dev20261011

Custom code

Yes

OS platform and distribution

Ubuntu24.04

Mobile device

No response

Python version

3.11.15

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

12.0.140

GPU model and memory

No response

Current behavior?

XLA incorrectly collapses tf.random.stateless_parameterized_truncated_normal to a constant when sampling from the far tail of a normal distribution.

For a standard normal distribution truncated to [6, 7], CPU eager execution produces diverse samples with a mean around 6.16, while XLA returns only 6.0.

The same issue is reproducible on XLA GPU, where all 65,536 samples also equal 6.0.

Standalone code to reproduce the issue

import numpy as np
import tensorflow as tf


def sample(seed):
    x = tf.random.stateless_parameterized_truncated_normal(
        [512, 256], seed,
        means=0.0, stddevs=1.0,
        minvals=6.0, maxvals=7.0,
    )
    return tf.reshape(x[:, ::2], [-1])


seed = tf.constant([123, 456], tf.int32)

with tf.device("/CPU:0"):
    eager = sample(seed).numpy()
    xla = tf.function(sample, jit_compile=True)(seed).numpy()

for name, x in [("eager", eager), ("XLA", xla)]:
    print(name, "mean:", x.mean(), "std:", x.std(),
          "unique:", np.unique(x).size)

Relevant log output

eager mean: 6.15779 std: 0.15109006 unique: 62503
XLA mean: 6.0 std: 0.0 unique: 1

Activity

  1. added
    2.21.0
    on Oct 13, 2026
  2. nileshau-afk commented on Oct 13, 2026

    @nileshau-afk

    Hi @xyt66665000,

    Thank you for reporting this issue and for providing the clear standalone code to reproduce the behavior across eager and XLA execution, wheretf.random.stateless_parameterized_truncated_normal incorrect to a constant lower bound when sampling from the far tail of a normal distribution under XLA (both CPU and GPU), whereas eager execution produces diverse samples as expected.

    We will investigate the issue and provide an update.

  3. Venkat6871 commented on Nov 8, 2026

    @Venkat6871
    Contributor

    Hi @xyt66665000 ,
    Thank you for raising your concern here.
    A fix for this issue has been proposed in this PR. Once it is merged, this issue will be resolved.

    Hi @adi-IL ,
    Thank you for raising the PR to address this issue. We truly appreciate your initiative and the effort in contributing the fix.

  4. added a commit that references this issue on Nov 9, 2026
    d05bf01
  5. google-ml-butler commented on Nov 9, 2026

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

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

Metadata

Metadata

Assignees

Labels

2.21.0awaiting PR mergecomp:xlatype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions