From 3bee6638e30af497032a19950ca0c6764008cc69 Mon Sep 17 00:00:00 2001 From: nimlgen <138685161+nimlgen@users.noreply.github.com> Date: Fri, 13 Feb 2026 19:08:36 +0300 Subject: [PATCH] external_test_hive_reset (#14729) * external_test_hive_reset * add fault --- test/external/external_test_hive_reset.py | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 test/external/external_test_hive_reset.py diff --git a/test/external/external_test_hive_reset.py b/test/external/external_test_hive_reset.py new file mode 100755 index 0000000000..3399fad8b4 --- /dev/null +++ b/test/external/external_test_hive_reset.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +import subprocess, sys +from tinygrad.helpers import getenv + +LOOPS = getenv("LOOPS", 10) +BROKEN = getenv("BROKEN", 0) + +BROKEN_KERNEL_SCRIPT = """ +from tinygrad.device import Device +from tinygrad.runtime.ops_amd import AMDProgram, AMDDevice +from tinygrad.runtime.support.compiler_amd import compile_hip +dev = Device["AMD"] +assert isinstance(dev, AMDDevice) and dev.is_am(), "Need AM driver (not KFD)" +broken_src = ''' +extern "C" __attribute__((global)) void broken(int* dummy) { + volatile int* bad_ptr = (volatile int*)0xDEAD00000000ULL; + *bad_ptr = 0x42; +} +''' +broken_lib = compile_hip(broken_src, dev.arch) +broken_prg = AMDProgram(dev, "broken", broken_lib) +buf = dev.allocator.alloc(64) +try: + broken_prg(buf, global_size=(1,1,1), local_size=(1,1,1), wait=True) + print(" ERROR: Kernel did not fault!") +except RuntimeError as e: + print(f" Got expected error: {e}") +""" + +for i in range(LOOPS): + print(f"=== Running hive_reset.py ({i+1}/{LOOPS}) ===") + subprocess.run([sys.executable, "extra/amdpci/hive_reset.py"], check=True) + print("=== hive_reset complete ===") + + if BROKEN: + print(f"=== Running broken kernel ({i+1}/{LOOPS}) ===") + ret = subprocess.run([sys.executable, "-c", BROKEN_KERNEL_SCRIPT]) + print(f"=== broken kernel exited with code {ret.returncode} ===") + + print(f"=== Running test_tiny.py ({i+1}/{LOOPS}) ===") + ret = subprocess.run([sys.executable, "test/test_tiny.py", "TestTiny.test_plus"]) + print(f"=== test_tiny.py exited with code {ret.returncode} ===")