From 368a692e1ae8149336ec266e2e3c8b380247ec0f Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Mon, 2 Feb 2026 10:30:56 +0800 Subject: [PATCH] make SPEC=2 work for everything (#14476) * make SPEC=2 work for everything * that's a horrible fix --- tinygrad/uop/ops.py | 1 + tinygrad/uop/spec.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tinygrad/uop/ops.py b/tinygrad/uop/ops.py index 6842e44b37..c8d7d11181 100644 --- a/tinygrad/uop/ops.py +++ b/tinygrad/uop/ops.py @@ -1436,6 +1436,7 @@ def pyrender(ast:UOp) -> str: for s in u.src: to_render.add(s) if u.op is Ops.STORE: to_render.add(u.src[1]) if u.op in {Ops.REDUCE, Ops.REDUCE_AXIS}: to_render.add(u.src[0]) + if u.op in {Ops.CUSTOM_KERNEL, Ops.CALL}: raise NotImplementedError("custom_kernel / call can't be pyrendered") if u.op in not_rendered: continue # checking the consumers is not enough, you have to make sure it's not used twice by the one consumer if len(cmap[u]) == 1 and len([x for x in list(cmap[u].keys())[0].src if x is u]) == 1 and u.op not in always_rendered: continue diff --git a/tinygrad/uop/spec.py b/tinygrad/uop/spec.py index 20b7512445..7d2808ff0a 100644 --- a/tinygrad/uop/spec.py +++ b/tinygrad/uop/spec.py @@ -313,8 +313,9 @@ def eval_pyrender(code:str) -> UOp: return lcls['ast'] def test_pyrender(test_ast:UOp, assert_parents=True): - code = pyrender(test_ast) - ast:UOp = eval_pyrender(code) + try: code = pyrender(test_ast) + except NotImplementedError: return None # this is okay, not all ops can be pyrendered + ast = eval_pyrender(code) if ast is not test_ast: if assert_parents: for u in test_ast.toposort(): test_pyrender(u, assert_parents=False)