From dec2f50aee5d3f2ce342f071b44cd8a3beb0cd6a Mon Sep 17 00:00:00 2001 From: Christopher Milan Date: Fri, 5 Dec 2025 09:36:35 -0800 Subject: [PATCH] reenable process replay for lvp (#13592) --- .github/workflows/test.yml | 2 -- tinygrad/renderer/nir.py | 7 ++++++- tinygrad/runtime/support/compiler_mesa.py | 8 +++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c70bd7d98..4b7c2a7d4e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -719,7 +719,6 @@ jobs: - name: Run TRANSCENDENTAL math run: TRANSCENDENTAL=2 python -m pytest -n=auto test/test_ops.py::TestOps::test_sin test/test_ops.py::TestOps::test_cos test/test_ops.py::TestOps::test_tan test/test_ops.py::TestOps::test_exp test/test_ops.py::TestOps::test_log --durations=20 - name: Run process replay tests - if: matrix.backend != 'lvp' # TODO: LVP is disabled due to renderer errors, bring this back uses: ./.github/actions/process-replay amdremote: @@ -936,7 +935,6 @@ jobs: - name: Run pytest (${{ matrix.backend }}) run: python3 -m pytest -n=auto test/ --ignore=test/models --ignore=test/unit --durations=20 - name: Run process replay tests - if: matrix.backend != 'lvp' # TODO: LVP is disabled due to renderer errors, bring this back uses: ./.github/actions/process-replay - name: Run macOS-specific unit test if: matrix.backend == 'cpu' diff --git a/tinygrad/renderer/nir.py b/tinygrad/renderer/nir.py index 86de4dc62e..22cba1b62d 100644 --- a/tinygrad/renderer/nir.py +++ b/tinygrad/renderer/nir.py @@ -5,7 +5,7 @@ from tinygrad.renderer import Renderer from tinygrad.renderer.cstyle import CUDARenderer from tinygrad.uop.ops import GroupOp, Ops, UOp, PatternMatcher, UPat, range_str from tinygrad.runtime.autogen import mesa -import base64, ctypes, ctypes.util, struct, functools, inspect +import base64, ctypes, ctypes.util, struct, functools, inspect, contextlib def g(s:str): return getattr(mesa, s) def nsrc(d:mesa.nir_def) -> mesa.nir_src: return mesa.nir_src(ssa=ctypes.pointer(d)) @@ -151,6 +151,11 @@ class NIRRenderer(Renderer): (UPat(Ops.ENDIF, name="x"), lambda ctx,x: (lambda _: mesa.nir_def())(mesa.nir_pop_if(ctx.b, ctx.r[x.src[0]]))) ]) + def __init__(self): mesa.glsl_type_singleton_init_or_ref() + + def __del__(self): + with contextlib.suppress(AttributeError): mesa.glsl_type_singleton_decref() + @property def nir_options(self): raise NotImplementedError("needs nir_options") def param(self, b:mesa.nir_builder, dtype:DType, sz:int) -> mesa.nir_def: raise NotImplementedError("needs param") diff --git a/tinygrad/runtime/support/compiler_mesa.py b/tinygrad/runtime/support/compiler_mesa.py index d0c9f2cfba..8f97e12ed4 100644 --- a/tinygrad/runtime/support/compiler_mesa.py +++ b/tinygrad/runtime/support/compiler_mesa.py @@ -1,4 +1,4 @@ -import base64, ctypes, pathlib, tempfile, hashlib, contextlib +import base64, ctypes, pathlib, tempfile, hashlib from tinygrad.device import Compiler from tinygrad.helpers import cpu_objdump, system from tinygrad.runtime.autogen import mesa @@ -15,12 +15,10 @@ class NIRCompiler(Compiler): def __init__(self, cache_key): mesa.glsl_type_singleton_init_or_ref() super().__init__(cache_key) - def __del__(self): - with contextlib.suppress(AttributeError): mesa.glsl_type_singleton_decref() + def __del__(self): mesa.glsl_type_singleton_decref() class LVPCompiler(CPULLVMCompiler, NIRCompiler): def __init__(self, cache_key="lvp"): - assert mesa.dll is not None CPULLVMCompiler.__init__(self) NIRCompiler.__init__(self, f"compile_{cache_key}") @@ -67,7 +65,7 @@ class NAKCompiler(NIRCompiler): super().__init__(f"compile_{cache_key}_{arch}") def __del__(self): - with contextlib.suppress(AttributeError): mesa.nak_compiler_destroy(self.cc) + mesa.nak_compiler_destroy(self.cc) super().__del__() def __reduce__(self): return NAKCompiler, (self.arch, self.warps_per_sm)