Spaces:
Sleeping
Sleeping
Update app.py
Browse files633 unmodified lines634635636637638639640641642643644645646647648649650651633 unmodified lines# to call on every request. Filtered to `LOADED_LORAS`: a slider for a LoRA that failed at startup has no# adapter behind it, and `set_adapters` would raise if asked to activate a name that was never attached.if LOADED_LORAS:# Filtered to strength > 0, not just "loaded": PEFT computes every adapter in the active list on every# forward regardless of its weight (no early-exit for scale 0), so an adapter left active at 0.0 still# costs a real lora_A/lora_B matmul per targeted Linear, every block, every step — overhead that scales# with how many LoRAs are loaded, not how many are actually in use for a given request. Called# unconditionally, even with an empty list, rather than only `if active:` — skipping the call when every# slider is 0 would leave whichever adapters the *previous* request activated still live.active = {name: strengthfor name, strength in lora_strengths.items()if name in LOADED_LORAS and strength > 0}PIPE.transformer.set_adapters(list(active), weights=list(active.values()))if PLACEMENT == "lazy":PIPE.to("cuda")633 unmodified lines634635636637638639640641642633 unmodified lines# to call on every request. Filtered to `LOADED_LORAS`: a slider for a LoRA that failed at startup has no# adapter behind it, and `set_adapters` would raise if asked to activate a name that was never attached.if LOADED_LORAS:active = {name: strength for name, strength in lora_strengths.items() if name in LOADED_LORAS}if active:PIPE.transformer.set_adapters(list(active), weights=list(active.values()))if PLACEMENT == "lazy":PIPE.to("cuda")
app.py+3-12