From cd0bf16e12a94f73364a9168aed49739ea014011 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Sat, 7 Nov 2026 17:16:03 -0500 Subject: [PATCH] [TEST] Keep the descriptor-builtins scope test from poisoning the builtin cache test_scope_restores_tensor_descriptor_base_builtins fakes inspect.getmembers and tl.core.is_builtin, then takes a snapshot scope. The frontend caches each language object's builtin names on first use, so when this test was the first to snapshot in the process it cached almost no names, and every later patch_lang/unpatch_lang left triton.language's builtins (load, store, atomic_*, arange, ...) patched by the interpreter. Run after it, test_patch_lang_restores_core_reduce_scan_from_tl_kernel and any later host compile then saw the patched language. Give the test an empty cache of its own, restored with the other monkeypatches. --- tests/unit/test_patch_scope.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/test_patch_scope.py b/tests/unit/test_patch_scope.py index fc533bf4..42316d68 100644 --- a/tests/unit/test_patch_scope.py +++ b/tests/unit/test_patch_scope.py @@ -100,6 +100,10 @@ def _getmembers(obj): monkeypatch.setattr( triton_frontend.tl.core, "is_builtin", lambda member: member is sentinel ) + # The frontend caches each object's builtin names on first use; under the + # fake getmembers it would cache almost none, and every later unpatch_lang + # in the process would then leave triton.language patched. + monkeypatch.setattr(triton_frontend.frontend, "_triton_builtin_attr_cache", {}) scope = triton_frontend.frontend._triton_snapshot_scope(_dummy_kernel) replacement = lambda *_args, **_kwargs: None