mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
a3cb5da130
* allow model patcher to optimize away the unpatching step when feasible * remove lazy_offloading functionality * allow model patcher to optimize away the unpatching step when feasible * remove lazy_offloading functionality * do not save original weights if there is a CPU copy of state dict * Update invokeai/backend/model_manager/load/load_base.py Co-authored-by: Ryan Dick <ryanjdick3@gmail.com> * documentation fixes requested during penultimate review * add non-blocking=True parameters to several torch.nn.Module.to() calls, for slight performance increases * fix ruff errors * prevent crash on non-cuda-enabled systems --------- Co-authored-by: Lincoln Stein <lstein@gmail.com> Co-authored-by: Kent Keirsey <31807370+hipsterusername@users.noreply.github.com> Co-authored-by: Ryan Dick <ryanjdick3@gmail.com>
30 lines
864 B
Python
30 lines
864 B
Python
"""Base class for 'Raw' models.
|
|
|
|
The RawModel class is the base class of LoRAModelRaw and TextualInversionModelRaw,
|
|
and is used for type checking of calls to the model patcher. Its main purpose
|
|
is to avoid a circular import issues when lora.py tries to import BaseModelType
|
|
from invokeai.backend.model_manager.config, and the latter tries to import LoRAModelRaw
|
|
from lora.py.
|
|
|
|
The term 'raw' was introduced to describe a wrapper around a torch.nn.Module
|
|
that adds additional methods and attributes.
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Optional
|
|
|
|
import torch
|
|
|
|
|
|
class RawModel(ABC):
|
|
"""Abstract base class for 'Raw' model wrappers."""
|
|
|
|
@abstractmethod
|
|
def to(
|
|
self,
|
|
device: Optional[torch.device] = None,
|
|
dtype: Optional[torch.dtype] = None,
|
|
non_blocking: bool = False,
|
|
) -> None:
|
|
pass
|