From 01e3eb6e3697c0bdef7ac228e944634dfa00a134 Mon Sep 17 00:00:00 2001 From: softcookiepp Date: Mon, 2 Nov 2026 14:25:51 -0800 Subject: [PATCH] flagged the loader as not implemented, for now --- __init__.py | 1 - prestartup_script.py | 7 +++++++ torchvulkan_loader.py | 1 + vulkan_monkeypatch.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 prestartup_script.py create mode 100644 vulkan_monkeypatch.py diff --git a/__init__.py b/__init__.py index 889a6ef..020e730 100644 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,6 @@ from .common import * from .torchvulkan_loader import * - # Map all your custom nodes classes with the names that will be displayed in the UI. NODE_CLASS_MAPPINGS = { "Torchvulkan Loader": TorchVulkanLoader diff --git a/prestartup_script.py b/prestartup_script.py new file mode 100644 index 0000000..2b04b64 --- /dev/null +++ b/prestartup_script.py @@ -0,0 +1,7 @@ +import comfy +import torchvulkan +import torch + +global cpu_state +cpu_state = None + diff --git a/torchvulkan_loader.py b/torchvulkan_loader.py index 54ff4ac..eadbba8 100644 --- a/torchvulkan_loader.py +++ b/torchvulkan_loader.py @@ -25,6 +25,7 @@ class TorchVulkanLoader: CATEGORY = "Backends" def load_to_torchvulkan(self, device, model = None, clip = None, vae = None): + raise NotImplementedError device = torch.device(f"vulkan:{device}") if model: model.to(device) if clip: clip.to(device) diff --git a/vulkan_monkeypatch.py b/vulkan_monkeypatch.py new file mode 100644 index 0000000..37aaac7 --- /dev/null +++ b/vulkan_monkeypatch.py @@ -0,0 +1,28 @@ +import comfy +import comfy.model_management + +# Patched version of comfy.model_management.get_torch_device that allows vulkan devices to be treated as default +def get_torch_device_patched(): + global directml_enabled + global cpu_state + if directml_enabled: + global directml_device + return directml_device + if cpu_state == CPUState.MPS: + return torch.device("mps") + if cpu_state == CPUState.CPU: + return torch.device("cpu") + else: + if True: + # for now, just see if this works c: + return torch.device(f"vulkan:0") + else: + if is_intel_xpu(): + return torch.device("xpu", torch.xpu.current_device()) + elif is_ascend_npu(): + return torch.device("npu", torch.npu.current_device()) + elif is_mlu(): + return torch.device("mlu", torch.mlu.current_device()) + else: + return torch.device(torch.cuda.current_device()) +comfy.model_management.get_torch_device = get_torch_device_patched