Spaces:
Running on Zero
Running on Zero
fix(lora): force pipe load before unload_lora() when DiT is still cold
Browse filesCold pipe + apply_stack() called from backend.dispatch() before
pipe.generate() runs _ensure_loaded() — pipe._dit is None and
dit.unload_lora() crashes with AttributeError. Empty stack short-circuits
when the DiT is missing; non-empty stack forces _ensure_loaded() so the
LoRA has a DiT to attach to.
- lora_stack.py +13 -2
lora_stack.py
CHANGED
|
@@ -160,10 +160,21 @@ def apply_stack(pipe, stack: list[dict]) -> None:
|
|
| 160 |
Apple-Silicon fork supports only one active LoRA at a time
|
| 161 |
(see module docstring). Behaviour:
|
| 162 |
|
| 163 |
-
- ``stack == []``: disable + unload the current LoRA
|
| 164 |
-
|
|
|
|
|
|
|
| 165 |
- ``len(stack) >= 2``: load the first, warn that the rest is ignored.
|
| 166 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
dit = pipe._dit # internal AceStepHandler reference
|
| 168 |
if not stack:
|
| 169 |
dit.unload_lora()
|
|
|
|
| 160 |
Apple-Silicon fork supports only one active LoRA at a time
|
| 161 |
(see module docstring). Behaviour:
|
| 162 |
|
| 163 |
+
- ``stack == []``: disable + unload the current LoRA (no-op if the
|
| 164 |
+
pipe hasn't been loaded yet — nothing to unload).
|
| 165 |
+
- ``len(stack) == 1``: load + set scale + enable. Forces a pipeline
|
| 166 |
+
load if it hasn't happened yet, since the LoRA targets the DiT.
|
| 167 |
- ``len(stack) >= 2``: load the first, warn that the rest is ignored.
|
| 168 |
"""
|
| 169 |
+
# Empty stack + cold pipe: no DiT to touch, nothing to unload.
|
| 170 |
+
if not stack and pipe._dit is None:
|
| 171 |
+
return
|
| 172 |
+
|
| 173 |
+
# Non-empty stack but cold pipe: force the lazy-load so we have a DiT
|
| 174 |
+
# to attach the LoRA to.
|
| 175 |
+
if stack and pipe._dit is None:
|
| 176 |
+
pipe._ensure_loaded()
|
| 177 |
+
|
| 178 |
dit = pipe._dit # internal AceStepHandler reference
|
| 179 |
if not stack:
|
| 180 |
dit.unload_lora()
|