mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-16 01:36:41 +08:00
Change bf16 check and switch non-blocking to off default with option to force to regain speed on certain classes of iGPUs and refactor xpu check.
This commit is contained in:
parent
966f3a5206
commit
3a1b18a5be
@ -132,6 +132,8 @@ parser.add_argument("--reserve-vram", type=float, default=None, help="Set the am
|
|||||||
|
|
||||||
parser.add_argument("--async-offload", action="store_true", help="Use async weight offloading.")
|
parser.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("--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.")
|
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.")
|
||||||
|
|||||||
@ -78,7 +78,6 @@ try:
|
|||||||
torch_version = torch.version.__version__
|
torch_version = torch.version.__version__
|
||||||
temp = torch_version.split(".")
|
temp = torch_version.split(".")
|
||||||
torch_version_numeric = (int(temp[0]), int(temp[1]))
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -102,10 +101,14 @@ if args.directml is not None:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import intel_extension_for_pytorch as ipex # noqa: F401
|
import intel_extension_for_pytorch as ipex # noqa: F401
|
||||||
_ = torch.xpu.device_count()
|
|
||||||
xpu_available = xpu_available or torch.xpu.is_available()
|
|
||||||
except:
|
except:
|
||||||
xpu_available = xpu_available or (hasattr(torch, "xpu") and torch.xpu.is_available())
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
_ = torch.xpu.device_count()
|
||||||
|
xpu_available = torch.xpu.is_available()
|
||||||
|
except:
|
||||||
|
xpu_available = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if torch.backends.mps.is_available():
|
if torch.backends.mps.is_available():
|
||||||
@ -946,9 +949,11 @@ def pick_weight_dtype(dtype, fallback_dtype, device=None):
|
|||||||
return dtype
|
return dtype
|
||||||
|
|
||||||
def device_supports_non_blocking(device):
|
def device_supports_non_blocking(device):
|
||||||
|
if args.force_non_blocking:
|
||||||
|
return True
|
||||||
if is_device_mps(device):
|
if is_device_mps(device):
|
||||||
return False #pytorch bug? mps doesn't support non blocking
|
return False #pytorch bug? mps doesn't support non blocking
|
||||||
if is_intel_xpu():
|
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 True
|
return True
|
||||||
if args.deterministic: #TODO: figure out why deterministic breaks non blocking from gpu to cpu (previews)
|
if args.deterministic: #TODO: figure out why deterministic breaks non blocking from gpu to cpu (previews)
|
||||||
return False
|
return False
|
||||||
@ -1282,10 +1287,10 @@ def should_use_bf16(device=None, model_params=0, prioritize_performance=True, ma
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if is_intel_xpu():
|
if is_intel_xpu():
|
||||||
if torch_version_numeric < (2, 6):
|
if torch_version_numeric < (2, 3):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return torch.xpu.get_device_capability(device)['has_bfloat16_conversions']
|
return torch.xpu.is_bf16_supported()
|
||||||
|
|
||||||
if is_ascend_npu():
|
if is_ascend_npu():
|
||||||
return True
|
return True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user