From 141f8f63479fa60b4dca8e04ebbca43384fb5041 Mon Sep 17 00:00:00 2001 From: erweiw Date: Tue, 3 Mar 2026 11:59:37 -0800 Subject: [PATCH] Raise error when AIR_TRANSFORM_TILING_SCRIPT file is not found When AIR_TRANSFORM_TILING_SCRIPT is set to a relative path and the working directory doesn't contain that file, the driver silently falls back to a default transform IR that produces under-transformed MLIR. The downstream aircc pass pipeline then fails with an opaque "MLIRError: Failure while executing pass pipeline". Replace the silent fallback with a clear FileNotFoundError that includes the current working directory, so users know to either use an absolute path or cd into the example directory. Co-Authored-By: Claude Opus 4.6 --- amd_triton_npu/backend/driver.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/amd_triton_npu/backend/driver.py b/amd_triton_npu/backend/driver.py index ec846f1..d136e3a 100644 --- a/amd_triton_npu/backend/driver.py +++ b/amd_triton_npu/backend/driver.py @@ -210,16 +210,15 @@ def _get_transform_ir_string(): custom_script_path = os.getenv("AIR_TRANSFORM_TILING_SCRIPT") if custom_script_path: - try: - with open(custom_script_path, "r") as f: - print(f"Using custom tiling script from: {custom_script_path}") - return f.read() - except FileNotFoundError: - print(f"Warning: Custom tiling script file not found: {custom_script_path}") - print("Falling back to default tiling recipe.") - except Exception as e: - print(f"Error reading custom tiling script {custom_script_path}: {e}") - print("Falling back to default tiling recipe.") + if not os.path.isfile(custom_script_path): + raise FileNotFoundError( + f"AIR_TRANSFORM_TILING_SCRIPT is set to '{custom_script_path}' " + f"but the file was not found (cwd: {os.getcwd()}). " + f"Use an absolute path or run from the directory containing the script." + ) + with open(custom_script_path, "r") as f: + print(f"Using custom tiling script from: {custom_script_path}") + return f.read() # Default hardcoded transform IR string matmul_tiling_size_l1_m = 32