[Feature] npu support enable_torch_compile for torchair backend (#13410)

Co-authored-by: ZhengdQin <zhengdqin@gmail.com>
This commit is contained in:
XDaoHong
2025-12-16 09:23:51 +08:00
committed by GitHub
parent 3ffa260474
commit 4733fcff1f
7 changed files with 243 additions and 50 deletions

View File

@@ -1933,16 +1933,7 @@ def get_device_capability(device_id: int = 0) -> Tuple[int, int]:
return major, minor
def get_npu_compiler_config():
config = {
"frozen_parameter": True,
"tiling_schedule_optimize": True,
"topology_sorting_strategy": "StableRDFS",
}
return config
def get_compiler_backend() -> str:
def get_compiler_backend(mode=None) -> str:
if hasattr(torch, "hpu") and torch.hpu.is_available():
return "hpu_backend"
@@ -1957,10 +1948,10 @@ def get_compiler_backend() -> str:
"Please install torchair for torch.compile support on NPU."
)
compiler_config = CompilerConfig()
predefined_config = get_npu_compiler_config()
for k, v in predefined_config.items():
setattr(compiler_config.experimental_config, k, v)
compiler_config.mode = "max-autotune"
if mode == "npugraph_ex":
compiler_config.mode = "reduce-overhead"
compiler_config.debug.run_eagerly = True
npu_backend = torchair.get_npu_backend(compiler_config=compiler_config)
return npu_backend