This commit is contained in:
Haoming 2026-05-02 21:36:05 +08:00
parent 612fe1c8a8
commit 37413303f9
2 changed files with 4 additions and 20 deletions

View File

@ -76,7 +76,6 @@ parser.add_argument("--disable-flash", action="store_true", help="disable flash_
parser.add_argument("--disable-xformers", action="store_true", help="disable xformers")
parser.add_argument("--directml", type=int, nargs="?", metavar="DIRECTML_DEVICE", const=-1, help="Use torch-directml")
parser.add_argument("--disable-ipex-optimize", action="store_true", help="Disable ipex.optimize default when loading models with Intel's Extension for PyTorch")
parser.add_argument("--deterministic", action="store_true", help="Use slower deterministic algorithms when possible")
vram_group = parser.add_mutually_exclusive_group()

View File

@ -110,10 +110,6 @@ if args.directml is not None:
logger.info("Using directml with device: {}".format(torch_directml.device_name(device_index)))
lowvram_available = False
try:
import intel_extension_for_pytorch as ipex # noqa: F401
except Exception:
ipex = None
try:
_ = torch.xpu.device_count()
@ -478,13 +474,6 @@ class LoadedModel:
real_model = self.model.model
if is_intel_xpu() and not args.disable_ipex_optimize and ipex is not None and real_model is not None:
with torch.no_grad():
real_model = ipex.optimize(real_model.eval(), inplace=True, graph_mode=True, concat_linear=True)
global signal_empty_cache
signal_empty_cache = True
bake_gguf_model(real_model)
self.real_model = weakref.ref(real_model)
@ -1175,10 +1164,7 @@ def should_use_fp16(device: torch.device = None, model_params: int = 0, prioriti
return False
if is_intel_xpu():
if torch_version_numeric < (2, 3):
return True
else:
return torch.xpu.get_device_properties(device).has_fp16
return torch.xpu.get_device_properties(device).has_fp16
if torch.version.hip:
return True
@ -1233,10 +1219,7 @@ def should_use_bf16(device: torch.device = None, model_params: int = 0, prioriti
return False
if is_intel_xpu():
if torch_version_numeric < (2, 3):
return True
else:
return torch.xpu.is_bf16_supported()
return torch.xpu.is_bf16_supported()
if is_amd():
arch = torch.cuda.get_device_properties(device).gcnArchName
@ -1350,8 +1333,10 @@ def soft_empty_cache(force=False):
if cpu_state is CPUState.MPS:
torch.mps.empty_cache()
elif is_intel_xpu():
torch.xpu.synchronize()
torch.xpu.empty_cache()
elif torch.cuda.is_available():
torch.cuda.synchronize()
torch.cuda.empty_cache()
torch.cuda.ipc_collect()