Skip to content

Commit

Permalink
Sanity check: gracefully deal with a failed load_lora_weights request
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk-dev committed Jul 16, 2024
1 parent c62d2dc commit ca021f7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions runner/app/pipelines/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,15 @@ def load_loras(pipeline: any, requested_loras: str):
"Clipping strength of LoRa " + adapter + " to 0.0, as it's requested strength (" + val + ") is negative"
)
strength = 0.0
# TODO: Sanity check: adapter name should exist on HuggingFace and have weights to load in
# Load in the LoRa weights
# TODO: Make sure that load_lora_weights is a noop if the LoRas are already loaded
pipeline.load_lora_weights(adapter, adapter_name=adapter)
# Load in LoRa weights if its repository exists on HuggingFace
try:
# TODO: If we decide to keep LoRas loaded (and only set their weight to 0), make sure that reloading them causes no performance hit or other issues
pipeline.load_lora_weights(adapter, adapter_name=adapter)
except (ValueError, RuntimeError, TypeError):
logger.warning(
"Unable to load LoRas for adapter '" + adapter + "'"
)
continue
# Remember adapter name and their associated strength
adapters.append(adapter)
strengths.append(strength)
Expand Down

0 comments on commit ca021f7

Please sign in to comment.