From 1d51ae3baacdd45b3834575625039db3880cd101 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 18 Oct 2024 14:46:43 +0300 Subject: [PATCH] Intel fix torch.compile --- modules/intel/ipex/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/intel/ipex/__init__.py b/modules/intel/ipex/__init__.py index a8fd9e5ce..e1c476e7e 100644 --- a/modules/intel/ipex/__init__.py +++ b/modules/intel/ipex/__init__.py @@ -16,7 +16,9 @@ def ipex_init(): # pylint: disable=too-many-statements if hasattr(torch, "cuda") and hasattr(torch.cuda, "is_xpu_hijacked") and torch.cuda.is_xpu_hijacked: return True, "Skipping IPEX hijack" else: - try: + try: # force xpu device on torch compile and triton + torch._inductor.utils.GPU_TYPES = ["xpu"] + torch._inductor.utils.get_gpu_type = lambda *args, **kwargs: "xpu" from triton import backends as triton_backends # pylint: disable=import-error triton_backends.backends["nvidia"].driver.is_active = lambda *args, **kwargs: False except Exception: @@ -198,7 +200,7 @@ def ipex_init(): # pylint: disable=too-many-statements torch.backends.cuda.is_built = lambda *args, **kwargs: True torch.version.cuda = "12.1" torch.cuda.get_arch_list = lambda: ["ats-m150", "pvc"] - torch.cuda.get_device_capability = lambda *args, **kwargs: [12,1] + torch.cuda.get_device_capability = lambda *args, **kwargs: (12,1) torch.cuda.get_device_properties.major = 12 torch.cuda.get_device_properties.minor = 1 torch.cuda.ipc_collect = lambda *args, **kwargs: None