From e8945c74de80ad2c7312eac027bc72c3d9fd1de5 Mon Sep 17 00:00:00 2001 From: Sieds Lykles <93992551+S-Lykles@users.noreply.github.com> Date: Wed, 24 Sep 2025 07:06:22 +0200 Subject: [PATCH] fix infinite symbolic loop with VCONST (#12285) --- tinygrad/uop/symbolic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinygrad/uop/symbolic.py b/tinygrad/uop/symbolic.py index d38fc4802d..90ebf5afd6 100644 --- a/tinygrad/uop/symbolic.py +++ b/tinygrad/uop/symbolic.py @@ -229,7 +229,7 @@ def factor_remainder(d: UOp, x: UOp, y: UOp) -> UOp|None: def nest_div_by_smallest_factor(d: UOp, x: UOp, y: UOp) -> UOp|None: # we try and nest the div and see if it allows the numerator to be simplified if ((c := y.arg) < 0): return None - factors = [u.const_factor() for u in x.pop_const()[0].split_uop(Ops.ADD)] + factors = [u.const_factor() for u in x.split_uop(Ops.ADD) if u.op not in (Ops.CONST, Ops.VCONST)] div = min([y.arg]+[abs(f) for f in factors if abs(f) > 1 and (c%f)==0]) newxs = fold_divmod_congruence(newx:=(x//div), x, y.const_like(div)) if newxs is None: newxs = factor_remainder(newx, x, y.const_like(div))