From f22fa6a5bee534839e2fad5d98c82a83ca93b296 Mon Sep 17 00:00:00 2001 From: chenyu Date: Thu, 22 Jan 2026 13:07:55 -0500 Subject: [PATCH] test rand is lazy (#14289) --- test/test_randomness.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_randomness.py b/test/test_randomness.py index d3d888fd34..d8554bef9b 100644 --- a/test/test_randomness.py +++ b/test/test_randomness.py @@ -69,6 +69,13 @@ class TestRandomness(unittest.TestCase): self.assertFalse(normal_test(Tensor.rand)) self.assertTrue(equal_distribution(Tensor.rand, torch.rand, lambda x: np.random.rand(*x))) + def test_rand_is_lazy(self): + Tensor.manual_seed(0) + r = Tensor.rand(10) + self.assertFalse(r.uop.is_realized, "rand should be lazy - tensor should not be realized") + r.realize() + self.assertTrue(r.uop.is_realized, "tensor should be realized after .realize()") + @unittest.skipUnless(is_dtype_supported(dtypes.float16) and is_dtype_supported(dtypes.ulong), "need float16 and ulong support") def test_rand_float16(self): N = 128