From 35917a78a5f375437510195e4eba449dd84239c3 Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Wed, 8 Apr 2026 10:54:09 -0700 Subject: [PATCH] Fix tl.rand range assertion: [0, 1) not [0, 1] tl.rand returns values in the half-open interval [0, 1), not the closed interval [0, 1]. The test assertion used x <= 1, which would have accepted 1.0 as a valid output. Philox-based float generation masks the upper mantissa bits and sets the exponent to produce values strictly less than 1.0. A value of exactly 1.0 indicates a bug (e.g. broken seed delivery returning all-ones from the uint-to-float conversion). --- python/test/unit/language/test_random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/test/unit/language/test_random.py b/python/test/unit/language/test_random.py index 79a4e3842f86..7341e1594c18 100644 --- a/python/test/unit/language/test_random.py +++ b/python/test/unit/language/test_random.py @@ -189,7 +189,7 @@ def const_kernel(X, N, seed: tl.constexpr, dtype: tl.constexpr): const_kernel[grid](x, N, seed=seed, dtype=getattr(tl, dtype)) else: kernel[grid](x, N, seed, dtype=getattr(tl, dtype)) - assert all((x >= 0) & (x <= 1)) + assert all((x >= 0) & (x < 1)) assert scipy.stats.kstest(x.tolist(), 'uniform', args=(0, 1)).statistic < 0.01