Skip to content

Commit 9de8e09

Browse files
erwei-xilinxclaude
andcommitted
Address PR review comments
- Treat None as "unset" in air_project_path setter (reverts to env var / default instead of crashing with Path(None)) - Use __dict__.copy() in config_context() so new fields are automatically saved/restored - Mention both config property and env var in error messages for output_format and transform_tiling_script - Incorporate PR #44 logging changes (rebase on top of feature/logging-knob-issue-40) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9bd25b4 commit 9de8e09

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

amd_triton_npu/backend/config.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ def air_project_path(self) -> Path:
148148

149149
@air_project_path.setter
150150
def air_project_path(self, value):
151+
if value is None:
152+
self._air_project_path = _UNSET
153+
return
151154
self._air_project_path = value
152155

153156
# ---- utilities ----
@@ -198,16 +201,10 @@ def config_context(**kwargs):
198201
with config_context(compile_only=True):
199202
kernel[grid](a, b, c)
200203
"""
201-
saved = {
202-
"_compile_only": npu_config._compile_only,
203-
"_transform_tiling_script": npu_config._transform_tiling_script,
204-
"_bf16_emulation": npu_config._bf16_emulation,
205-
"_output_format": npu_config._output_format,
206-
"_air_project_path": npu_config._air_project_path,
207-
}
204+
saved = npu_config.__dict__.copy()
208205
try:
209206
set_config(**kwargs)
210207
yield npu_config
211208
finally:
212-
for attr, val in saved.items():
213-
object.__setattr__(npu_config, attr, val)
209+
npu_config.__dict__.clear()
210+
npu_config.__dict__.update(saved)

amd_triton_npu/backend/driver.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ def _get_output_format():
220220
if configured_format == "elf" and npu_version == "npu1":
221221
raise RuntimeError(
222222
"ELF output format is not supported on npu1 (AIE2) devices. "
223-
"Use 'xclbin' or set npu_config.output_format = None."
223+
"Unset or change AMD_TRITON_NPU_OUTPUT_FORMAT, or set "
224+
"npu_config.output_format to 'xclbin' or None."
224225
)
225226
return configured_format
226227
# Auto-detect: ELF for npu2, xclbin for npu1
@@ -427,9 +428,10 @@ def _get_transform_ir_string():
427428
if custom_script_path:
428429
if not os.path.isfile(custom_script_path):
429430
raise FileNotFoundError(
430-
f"transform_tiling_script is set to '{custom_script_path}' "
431-
f"but the file was not found (cwd: {os.getcwd()}). "
432-
f"Use an absolute path or run from the directory containing the script."
431+
f"transform_tiling_script / AIR_TRANSFORM_TILING_SCRIPT is set to "
432+
f"'{custom_script_path}' but the file was not found "
433+
f"(cwd: {os.getcwd()}). Use an absolute path or run from the "
434+
f"directory containing the script."
433435
)
434436
with open(custom_script_path, "r") as f:
435437
logger.debug("Using custom tiling script from: %s", custom_script_path)

0 commit comments

Comments
 (0)