Fix eager AMX backend probe imports (#34496)
Co-authored-by: Xiaoyu Zhang <1182563586@qq.com>
This commit is contained in:
co-authored by
Xiaoyu Zhang
parent
ba1d980b35
commit
827552bc1d
@@ -398,14 +398,15 @@ def get_bool_env_var(name: str, default: str = "false") -> bool:
|
||||
return value in truthy_values
|
||||
|
||||
|
||||
try:
|
||||
import sgl_kernel # noqa: F401
|
||||
@lru_cache(maxsize=1)
|
||||
def _is_intel_amx_backend_available():
|
||||
try:
|
||||
import sgl_kernel # noqa: F401
|
||||
|
||||
return hasattr(torch.ops.sgl_kernel, "convert_weight_packed")
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
is_intel_amx_backend_available = hasattr(
|
||||
torch.ops.sgl_kernel, "convert_weight_packed"
|
||||
)
|
||||
except:
|
||||
is_intel_amx_backend_available = False
|
||||
|
||||
try:
|
||||
# move torch.cpu._is_amx_tile_supported() from cpu_has_amx_support
|
||||
@@ -416,7 +417,7 @@ except:
|
||||
|
||||
|
||||
def cpu_has_amx_support():
|
||||
return is_amx_tile_supported and is_intel_amx_backend_available
|
||||
return is_amx_tile_supported and _is_intel_amx_backend_available()
|
||||
|
||||
|
||||
def use_intel_amx_backend(layer):
|
||||
|
||||
@@ -316,14 +316,15 @@ def is_sm121() -> bool:
|
||||
return is_cuda() and torch.cuda.get_device_capability() == (12, 1)
|
||||
|
||||
|
||||
try:
|
||||
import sgl_kernel # noqa: F401
|
||||
@lru_cache(maxsize=1)
|
||||
def _is_intel_amx_backend_available():
|
||||
try:
|
||||
import sgl_kernel # noqa: F401
|
||||
|
||||
return hasattr(torch.ops.sgl_kernel, "convert_weight_packed")
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
is_intel_amx_backend_available = hasattr(
|
||||
torch.ops.sgl_kernel, "convert_weight_packed"
|
||||
)
|
||||
except:
|
||||
is_intel_amx_backend_available = False
|
||||
|
||||
try:
|
||||
# move torch.cpu._is_amx_tile_supported() from cpu_has_amx_support
|
||||
@@ -334,7 +335,7 @@ except:
|
||||
|
||||
|
||||
def cpu_has_amx_support():
|
||||
return is_amx_tile_supported and is_intel_amx_backend_available
|
||||
return is_amx_tile_supported and _is_intel_amx_backend_available()
|
||||
|
||||
|
||||
def use_intel_amx_backend(layer):
|
||||
|
||||
Reference in New Issue
Block a user