load the LoRA from the mounted bucket instead of re-downloading it from the hub - #1616
load the LoRA from the mounted bucket instead of re-downloading it from the hub#1616EnesYilmazcode wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🔍 Pre-existing mismatch between download path and check path in download_lora
In download_lora, the download destination uses repository_path.as_posix().replace('.', '_') (cloud_bucket_mount_loras.py:157), which transforms dots to underscores. However, the existence check at line 154 and the safetensors glob at line 160 both use the original repository_path (without the dot-to-underscore transformation). This means if a repository ID contains dots (e.g. user/model.v2), files would be downloaded to a different directory than where the code later checks for them. This is a pre-existing issue not introduced by this PR, but it's relevant because the inference code at line 195 also uses the untransformed path LORAS_PATH / lora_id to find safetensors files, which would similarly fail for dot-containing repository IDs.
(Refers to lines 154-160)
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Hello! Due to incoming review requests exceeding internal review capacity, we are no longer accepting external PRs to this repository and we are closing outstanding external PRs. Thank you for your interest in Modal and our documentation and apologies for any wasted time (or tokens). |
The cloud bucket mount LoRAs example downloads each LoRA into the S3 bucket, then at inference time loads it with
self.pipe.load_lora_weights(lora_id, weight_name=file.name). The first argument islora_id, the Hugging Face repo id, so diffusers resolves the weights from the Hub and downloads them a second time intoHF_HUB_CACHEinstead of using the copy already sitting in the mounted bucket. That defeats the point of the example, which is to serve LoRAs from S3 ("we load whichever LoRA the user specifies from the S3 bucket").fileis the local path to the.safetensorsfile inside the mount, found by therglobon the line above. Passing it as the first argument makes diffusers load straight from disk. Traced through the pinneddiffusers==0.26.3:load_lora_weightscallslora_state_dictcalls_get_model_file, whereos.path.isfile(path)is true for the mount file and the path is returned directly (hub_utils.py), so no Hub download happens.weight_name=file.nameis redundant in that branch but harmless, so I kept the change to the single argument.Fixes #1106.
ruff checkandruff format --checkpass on the file (ruff 0.9.6, the version pinned in CI).