mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-16 08:33:29 +00:00
Satisfy ruff linting
This commit is contained in:
parent
5080105c23
commit
6dca17bd2d
@ -72,7 +72,7 @@ class ControlIsolation:
|
|||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.control.previous_controlnet = None
|
self.control.previous_controlnet = None
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
self.control.previous_controlnet = self.orig_previous_controlnet
|
self.control.previous_controlnet = self.orig_previous_controlnet
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class ControlBase:
|
|||||||
def deepclone_multigpu(self, load_device, autoregister=False):
|
def deepclone_multigpu(self, load_device, autoregister=False):
|
||||||
'''
|
'''
|
||||||
Create deep clone of Control object where model(s) is set to other devices.
|
Create deep clone of Control object where model(s) is set to other devices.
|
||||||
|
|
||||||
When autoregister is set to True, the deep clone is also added to multigpu_clones dict.
|
When autoregister is set to True, the deep clone is also added to multigpu_clones dict.
|
||||||
'''
|
'''
|
||||||
raise NotImplementedError("Classes inheriting from ControlBase should define their own deepclone_multigpu funtion.")
|
raise NotImplementedError("Classes inheriting from ControlBase should define their own deepclone_multigpu funtion.")
|
||||||
@ -846,7 +846,7 @@ class T2IAdapter(ControlBase):
|
|||||||
c = T2IAdapter(self.t2i_model, self.channels_in, self.compression_ratio, self.upscale_algorithm)
|
c = T2IAdapter(self.t2i_model, self.channels_in, self.compression_ratio, self.upscale_algorithm)
|
||||||
self.copy_to(c)
|
self.copy_to(c)
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def deepclone_multigpu(self, load_device, autoregister=False):
|
def deepclone_multigpu(self, load_device, autoregister=False):
|
||||||
c = self.copy()
|
c = self.copy()
|
||||||
c.t2i_model = copy.deepcopy(c.t2i_model)
|
c.t2i_model = copy.deepcopy(c.t2i_model)
|
||||||
|
@ -30,7 +30,6 @@ import gc
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from comfy.model_patcher import ModelPatcher
|
from comfy.model_patcher import ModelPatcher
|
||||||
from comfy.model_base import BaseModel
|
|
||||||
|
|
||||||
class VRAMState(Enum):
|
class VRAMState(Enum):
|
||||||
DISABLED = 0 #No vram present: no need to move models to vram
|
DISABLED = 0 #No vram present: no need to move models to vram
|
||||||
|
@ -18,7 +18,7 @@ class GPUOptions:
|
|||||||
|
|
||||||
def clone(self):
|
def clone(self):
|
||||||
return GPUOptions(self.device_index, self.relative_speed)
|
return GPUOptions(self.device_index, self.relative_speed)
|
||||||
|
|
||||||
def create_dict(self):
|
def create_dict(self):
|
||||||
return {
|
return {
|
||||||
"relative_speed": self.relative_speed
|
"relative_speed": self.relative_speed
|
||||||
@ -86,7 +86,7 @@ def create_multigpu_deepclones(model: ModelPatcher, max_gpus: int, gpu_options:
|
|||||||
device_patcher = lm.clone()
|
device_patcher = lm.clone()
|
||||||
logging.info(f"Reusing loaded deepclone of {device_patcher.model.__class__.__name__} for {device}")
|
logging.info(f"Reusing loaded deepclone of {device_patcher.model.__class__.__name__} for {device}")
|
||||||
break
|
break
|
||||||
if device_patcher is None:
|
if device_patcher is None:
|
||||||
device_patcher = model.deepclone_multigpu(new_load_device=device)
|
device_patcher = model.deepclone_multigpu(new_load_device=device)
|
||||||
device_patcher.is_multigpu_base_clone = True
|
device_patcher.is_multigpu_base_clone = True
|
||||||
multigpu_models = model.get_additional_models_with_key("multigpu")
|
multigpu_models = model.get_additional_models_with_key("multigpu")
|
||||||
@ -138,7 +138,7 @@ def load_balance_devices(model_options: dict[str], total_work: int, return_idle_
|
|||||||
# if need to compare work idle time, need to normalize to a common total work
|
# if need to compare work idle time, need to normalize to a common total work
|
||||||
if work_normalized:
|
if work_normalized:
|
||||||
idle_time *= (work_normalized/total_work)
|
idle_time *= (work_normalized/total_work)
|
||||||
|
|
||||||
return LoadBalance(dict_work_per_device, idle_time)
|
return LoadBalance(dict_work_per_device, idle_time)
|
||||||
|
|
||||||
def round_preserved(values: list[float]):
|
def round_preserved(values: list[float]):
|
||||||
|
@ -384,7 +384,7 @@ def _calc_cond_batch_multigpu(model: BaseModel, conds: list[list[dict]], x_in: t
|
|||||||
|
|
||||||
devices = [dev_m for dev_m in model_options['multigpu_clones'].keys()]
|
devices = [dev_m for dev_m in model_options['multigpu_clones'].keys()]
|
||||||
device_batched_hooked_to_run: dict[torch.device, list[tuple[comfy.hooks.HookGroup, tuple]]] = {}
|
device_batched_hooked_to_run: dict[torch.device, list[tuple[comfy.hooks.HookGroup, tuple]]] = {}
|
||||||
|
|
||||||
total_conds = 0
|
total_conds = 0
|
||||||
for to_run in hooked_to_run.values():
|
for to_run in hooked_to_run.values():
|
||||||
total_conds += len(to_run)
|
total_conds += len(to_run)
|
||||||
@ -504,7 +504,7 @@ def _calc_cond_batch_multigpu(model: BaseModel, conds: list[list[dict]], x_in: t
|
|||||||
new_thread = threading.Thread(target=_handle_batch, args=(device, batch_tuple, results))
|
new_thread = threading.Thread(target=_handle_batch, args=(device, batch_tuple, results))
|
||||||
threads.append(new_thread)
|
threads.append(new_thread)
|
||||||
new_thread.start()
|
new_thread.start()
|
||||||
|
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import logging
|
|
||||||
from inspect import cleandoc
|
from inspect import cleandoc
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
@ -11,7 +10,7 @@ import comfy.multigpu
|
|||||||
class MultiGPUWorkUnitsNode:
|
class MultiGPUWorkUnitsNode:
|
||||||
"""
|
"""
|
||||||
Prepares model to have sampling accelerated via splitting work units.
|
Prepares model to have sampling accelerated via splitting work units.
|
||||||
|
|
||||||
Should be placed after nodes that modify the model object itself, such as compile or attention-switch nodes.
|
Should be placed after nodes that modify the model object itself, such as compile or attention-switch nodes.
|
||||||
|
|
||||||
Other than those exceptions, this node can be placed in any order.
|
Other than those exceptions, this node can be placed in any order.
|
||||||
@ -30,7 +29,7 @@ class MultiGPUWorkUnitsNode:
|
|||||||
"gpu_options": ("GPU_OPTIONS",)
|
"gpu_options": ("GPU_OPTIONS",)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("MODEL",)
|
RETURN_TYPES = ("MODEL",)
|
||||||
FUNCTION = "init_multigpu"
|
FUNCTION = "init_multigpu"
|
||||||
CATEGORY = "advanced/multigpu"
|
CATEGORY = "advanced/multigpu"
|
||||||
|
Loading…
Reference in New Issue
Block a user