The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix XPU iGPU regressions (#9322)
Simon Luic991a5da6586
diff --git a/README.md b/README.mdindex e4cff01a9..fa99a8cbe 100644--- a/README.md+++ b/README.md@@ -39,7 +39,7 @@ ComfyUI lets you design and execute advanced stable diffusion pipelines using a## Get Started#### [Desktop Application](https://www.comfy.org/download)-- The easiest way to get started.+- The easiest way to get started.- Available on Windows & macOS.#### [Windows Portable Package](#installing)@@ -211,27 +211,19 @@ This is the command to install the nightly with ROCm 6.4 which might have some p### Intel GPUs (Windows and Linux)-(Option 1) Intel Arc GPU users can install native PyTorch with torch.xpu support using pip (currently available in PyTorch nightly builds). More information can be found [here](https://pytorch.org/docs/main/notes/get_start_xpu.html)--1. To install PyTorch nightly, use the following command:+(Option 1) Intel Arc GPU users can install native PyTorch with torch.xpu support using pip. More information can be found [here](https://pytorch.org/docs/main/notes/get_start_xpu.html)-```pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/xpu```--2. Launch ComfyUI by running `python main.py`+1. To install PyTorch xpu, use the following command:+```pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu```-(Option 2) Alternatively, Intel GPUs supported by Intel Extension for PyTorch (IPEX) can leverage IPEX for improved performance.--1. For Intel® Arc™ A-Series Graphics utilizing IPEX, create a conda environment and use the commands below:+This is the command to install the Pytorch xpu nightly which might have some performance improvements:-```-conda install libuv-pip install torch==2.3.1.post0+cxx11.abi torchvision==0.18.1.post0+cxx11.abi torchaudio==2.3.1.post0+cxx11.abi intel-extension-for-pytorch==2.3.110.post0+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/cn/-```+```pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/xpu```-For other supported Intel GPUs with IPEX, visit [Installation](https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu) for more information.+(Option 2) Alternatively, Intel GPUs supported by Intel Extension for PyTorch (IPEX) can leverage IPEX for improved performance.-Additional discussion and help can be found [here](https://github.com/comfyanonymous/ComfyUI/discussions/476).+1. visit [Installation](https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu) for more information.### NVIDIA@@ -352,7 +344,7 @@ Generate a self-signed certificate (not appropriate for shared/production use) aUse `--tls-keyfile key.pem --tls-certfile cert.pem` to enable TLS/SSL, the app will now be accessible with `https://...` instead of `http://...`.-> Note: Windows users can use [alexisrolland/docker-openssl](https://github.com/alexisrolland/docker-openssl) or one of the [3rd party binary distributions](https://wiki.openssl.org/index.php/Binaries) to run the command example above.+> Note: Windows users can use [alexisrolland/docker-openssl](https://github.com/alexisrolland/docker-openssl) or one of the [3rd party binary distributions](https://wiki.openssl.org/index.php/Binaries) to run the command example above.<br/><br/>If you use a container, note that the volume mount `-v` can be a relative path so `... -v ".\:/openssl-certs" ...` would create the key & cert files in the current directory of your command prompt or powershell terminal.## Support and dev channeldiff --git a/comfy/cli_args.py b/comfy/cli_args.pyindex 0d760d524..de3e85c08 100644--- a/comfy/cli_args.py+++ b/comfy/cli_args.py@@ -132,6 +132,8 @@ parser.add_argument("--reserve-vram", type=float, default=None, help="Set the amparser.add_argument("--async-offload", action="store_true", help="Use async weight offloading.")+parser.add_argument("--force-non-blocking", action="store_true", help="Force ComfyUI to use non-blocking operations for all applicable tensors. This may improve performance on some non-Nvidia systems but can cause issues with some workflows.")+parser.add_argument("--default-hashing-function", type=str, choices=['md5', 'sha1', 'sha256', 'sha512'], default='sha256', help="Allows you to choose the hash function to use for duplicate filename / contents comparison. Default is sha256.")parser.add_argument("--disable-smart-memory", action="store_true", help="Force ComfyUI to agressively offload to regular ram instead of keeping models in vram when it can.")diff --git a/comfy/model_management.py b/comfy/model_management.pyindex c08f759e5..2a9f18068 100644--- a/comfy/model_management.py+++ b/comfy/model_management.py@@ -78,7 +78,6 @@ try:torch_version = torch.version.__version__temp = torch_version.split(".")torch_version_numeric = (int(temp[0]), int(temp[1]))- xpu_available = (torch_version_numeric[0] < 2 or (torch_version_numeric[0] == 2 and torch_version_numeric[1] <= 4)) and torch.xpu.is_available()except:pass@@ -102,10 +101,14 @@ if args.directml is not None:try:import intel_extension_for_pytorch as ipex # noqa: F401+except:+ pass++try:_ = torch.xpu.device_count()- xpu_available = xpu_available or torch.xpu.is_available()+ xpu_available = torch.xpu.is_available()except:- xpu_available = xpu_available or (hasattr(torch, "xpu") and torch.xpu.is_available())+ xpu_available = Falsetry:if torch.backends.mps.is_available():@@ -946,10 +949,12 @@ def pick_weight_dtype(dtype, fallback_dtype, device=None):return dtypedef device_supports_non_blocking(device):+ if args.force_non_blocking:+ return Trueif is_device_mps(device):return False #pytorch bug? mps doesn't support non blocking- if is_intel_xpu():- return True+ if is_intel_xpu(): #xpu does support non blocking but it is slower on iGPUs for some reason so disable by default until situation changes+ return Falseif args.deterministic: #TODO: figure out why deterministic breaks non blocking from gpu to cpu (previews)return Falseif directml_enabled:@@ -1282,10 +1287,10 @@ def should_use_bf16(device=None, model_params=0, prioritize_performance=True, mareturn Falseif is_intel_xpu():- if torch_version_numeric < (2, 6):+ if torch_version_numeric < (2, 3):return Trueelse:- return torch.xpu.get_device_capability(device)['has_bfloat16_conversions']+ return torch.xpu.is_bf16_supported()if is_ascend_npu():return True