Closed jquintanilla4 closed 11 months ago
Thanks for the detailed bug report @jquintanilla4! I haven't got the time to check it today (working on 0.20.0
release) so I'll have a look tomorrow :)
Hey @jquintanilla4 after having looked into it, there doesn't seem to be any duplicated file in your cache system, am I right? Or is it expected that weights from model stable-diffusion-xl-base-1.0 and sdxl-turbo happen to be the same? Because yes, this is a known limitations. Exact same files that are shared between repos are not shared in the local cache as we keep files separated in repos.
As an example here's the last two checkpoints when i run the huggingface-cli scan-cache command:
Regarding the delete-cache
command, this is expected since you only have 1 revision per model (snapshot f4b0486b498f84668e828044de1d0c8ba486e05b
for xl-base-1.0 and snapshot 462165984030d82259a11f4367a4eed129e94a7b
for sdxl turbo). The delete-cache
command is a tool meant to help cleaning the cache when several revisions of the same model have been downloaded.
When I use HF diffusers to download a model/checkpoint from HF using the .from_pretrained() method, it downloads the same model/checkpoint over and over, usually on different days or different times of the day. Between those repeated downloads, there's no updates to the checkpoint/model I try to download.
Do you have an example for this? If you're using different models, they will be downloaded which will eventually take space on your disk. But if the model file already exists in the cache, it is not re-downloaded. You might see a progress bars when download a repo but it should be almost instant (just the time to check files did not change).
The only possibility for duplicated files is if you download to a local folder in multiple locations and that symlinks are deactivated. Symlinks are deactivated on windows (if not admin/not developer mode) or if you passed local_dir_use_symlinks=False
. If that's the case, duplication is expected but we can't do much about it.
I hope this answers your question. I might be missing something and if this is the case, please let me know!
Just to make sure I'm understanding you're reply correctly... are you saying that huggingface hub cache keeps multiple copies of the same model/checkpoint if they're used by different local repos?
So for example, I am using SDXL Turbo on two different projects/repos:
So once those checkpoints are downloaded for their respective repos, then it shouldn't download again, because from that point forward they should load from cache. correct?
@Wauplin
@jquintanilla4 The generic answer is "checkpoints from a same model repository on the Hub are downloaded only once in the cache".
There are some flaws to this logic in some specific cases:
│ ├── [ 79] model.fp16.safetensors -> ../../../blobs/ec310df2af79c318e24d20511b601a591ca8cd4f1fce1d8dff822a356bcdb1f4
in your report)Apart from those corner cases, you can always expect checkpoint files to be reused without re-downloading/duplicates when calling .from_pretrained
from different projects. And this is the case if you look at your report (tree -alh ~/.cache/huggingface/hub/models--stabilityai--sdxl-turbo
). For more details on how the cache works internally, I invite you to read this guide. :hugs:
Your response makes sense. That's how I expected the cache system to work. But then how did I end up with 20GB sized SDXL turbo directory when the checkpoint itself is only ~6GB?
Am I missing something? Am I being super dense?
From your explanation, If I understand it correctly. It should only be ~6GB, unless there was an update to the checkpoint and there after I would have a copy in the cache system for each corresponding version.
Thanks for the link. I've read that before I created the issue and commented on the other issue in diffusers. But I'm still confused as to why I have such an oversized directory for SDXL turbo and SDXL.
Honestly feeling a little dumb 😅. Thanks for your patience.
If you think my cache is working correctly. I can close this issue.
Your response makes sense. That's how I expected the cache system to work. But then how did I end up with 20GB sized SDXL turbo directory when the checkpoint itself is only ~6GB?
I think the question is more related to diffusers
here.
If you look at your cache, you have much more than a 6GB file. For example, ./unet/diffusion_pytorch_model.safetensors
alone weights 9.6GB. When you load the model, there is more than "just" the sd_xl_turbo_1.0_fp16.safetensors
(6GB) file that gets downloaded. It also looks like you have a copy of each weight file in both fp16.safetensors
and .safetensors
. That can be the case if you've instantiated the pipeline twice, once with fp16 precision and once without.
Oh I see. Wow, how did i miss that? 🤦🏽♂️ Makes sense. My oversight.
No issue or bug here.
Thanks for your help. I'll be closing the issue.
Great! Glad that's clarified :hugs:
Describe the bug
When I use HF diffusers to download a model/checkpoint from HF using the
.from_pretrained()
method, it downloads the same model/checkpoint over and over, usually on different days or different times of the day. Between those repeated downloads, there's no updates to the checkpoint/model I try to download. So over time I end up with a cache folder for sdxl-turbo that is 20GB. But when i run the huggingface-cli delete-cache, it only gives me the option of deleting the entire cache folder for that model/checkpoint.As an example here's the last two checkpoints when i run the huggingface-cli scan-cache command:
I use
local_folders
, if i remember correctly. I normally work on a jupyter notebook file (.ipynb) inside of VS code.Output from the following command
tree -alh ~/.cache/huggingface/hub/models--stabilityai--sdxl-turbo
:Output from the following command
tree -alh ~/.cache/huggingface/hub/models--stabilityai--stable-diffusion-xl-base-1.0
:Reproduction
Pretty standard sdxl t2i adapter diffusers pipeline, but also happens with the sdxl controlnet pipeline and standard sdxl pipeline:
Logs
No response
System info