From e6f5bb9c0949d60895455b90efaf4f636b5396c7 Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Sat, 15 Aug 2026 10:00:21 +0800 Subject: [PATCH] simple test for Invalid clone cache miss regression (#17541) * simple test for Invalid clone cache miss regression * xfail * _ --- test/unit/test_schedule_cache.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/unit/test_schedule_cache.py b/test/unit/test_schedule_cache.py index 078d512148..c304eab636 100644 --- a/test/unit/test_schedule_cache.py +++ b/test/unit/test_schedule_cache.py @@ -1,6 +1,6 @@ import unittest import functools -from tinygrad import Tensor, Variable, UOp +from tinygrad import Tensor, Variable, UOp, function from tinygrad.uop.ops import KernelInfo from tinygrad.schedule import schedule_cache @@ -65,5 +65,24 @@ class TestScheduleCache(unittest.TestCase): print(num) self.assertEqual(len(schedule_cache), start_len_schedule_cache) + @unittest.expectedFailure + def test_simple_precompile(self): + @function(precompile=True) + def f(x:Tensor) -> Tensor: + out = Tensor.invalids(*x.shape, dtype=x.dtype, device=x.device) + out = Tensor.custom_kernel(out, fxn=functools.partial(custom_set0_kernel, num=10))[0] + return out + x + + # warmup + x = Tensor.ones(1).realize() + _ = f(x).realize() + + # use the cache next time function is called + start_len_schedule_cache = len(schedule_cache) + for _ in range(3): + num = f(x).realize() + self.assertEqual(num.item(), 11) + self.assertEqual(len(schedule_cache), start_len_schedule_cache) + if __name__ == "__main__": unittest.main()