#!/usr/bin/env python3 """Test that invalid instructions raise exceptions through the mock GPU stack.""" import unittest, subprocess, os, time class TestMockGPUInvalidInstruction(unittest.TestCase): def test_unsupported_instruction_raises(self): """Test that unsupported instructions raise immediately through the full MOCKGPU stack.""" test_code = ''' import struct from tinygrad import Device, Tensor from tinygrad.engine.realize import get_runner from tinygrad.runtime.ops_amd import AMDProgram dev = Device["AMD"] a = Tensor([1.0]).realize() b = a + 1 si = b.schedule()[-1] runner = get_runner(dev.device, si.ast) prg = runner._prg lib = bytearray(prg.lib) # Find s_endpgm (0xBFB00000) and replace with invalid SOPP op=127 (0xBFFF0000) found = False for i in range(0, len(lib) - 4, 4): if struct.unpack("