[Bugfix][Diffusion] Fuse distilled LoRA weights before HSDP sharding (#6948)
Signed-off-by: samithuang <285365963@qq.com> Signed-off-by: Samit <285365963@qq.com>
This commit is contained in:
1 parent
ae70479619
commit
44d3ae100a
9 files changed
+311
-1
No files matched your search
@@ -209,6 +209,7 @@ class LoraLoaderMixin:
|
||||
# Set by the pipeline this mixin is combined with; annotated, not assigned.
|
||||
transformer: torch.nn.Module
|
||||
_lora_loaded: dict[str | None, dict[str, torch.Tensor]]
|
||||
_lora_is_fused: bool
|
||||
|
||||
# Lazy initialization to avoid MRO issues: __init__ may not be called
|
||||
# when mixin with nn.Module
|
||||
@@ -222,6 +223,18 @@ class LoraLoaderMixin:
|
||||
def lora_loaded(self, value):
|
||||
self._lora_loaded = value
|
||||
|
||||
@property
|
||||
def lora_is_fused(self) -> bool:
|
||||
"""True when LoRA weights are fused into base weights.
|
||||
|
||||
Mixin loads are in-place fusions, so non-empty `_lora_loaded` implies fused.
|
||||
"""
|
||||
return getattr(self, "_lora_is_fused", False) or bool(getattr(self, "_lora_loaded", None))
|
||||
|
||||
@lora_is_fused.setter
|
||||
def lora_is_fused(self, value: bool):
|
||||
self._lora_is_fused = value
|
||||
|
||||
@classmethod
|
||||
def load_lora_into_module(
|
||||
cls,
|
||||
|
||||
Reference in new issue
Block a user