common : add --hf-prune-old-files (-hfp) parameter to automatically delete outdated HF files#21923
common : add --hf-prune-old-files (-hfp) parameter to automatically delete outdated HF files#21923Cr4xy wants to merge 1 commit intoggml-org:masterfrom
Conversation
…elete outdated HF files
|
I’m not convinced we should incorporate features from the |
I understand that, I just think this would make sense because otherwise users are forced to always clean up disk space manually with the CLI. Personally, I don't even have |
|
+1 as llama.cpp can download models from huggingface, users should be allowed to remove those downloaded files quickly too. |
Overview
This PR adds a new HF model management housekeeping CLI argument that tells llama.cpp to delete older versions of HuggingFace models.
Since models are now stored in the HF format, the disk usage can rise significantly when the same model gets downloaded multiple times.
For example, my models--unsloth--gemma-4-26B-A4B-it-GGUF folder currently takes up around 100GB instead of 27GB.
With this flag, llama.cpp will check for old versions on startup and delete them if it can find them. That basically brings back the old behavior, where the model size stayed (almost) the same when a new version was downloaded.
Additional information
This works by checking all symlinks in the snapshots directory that have the same file name as the current (latest) model file(s) and mmproj, if symlinks with the same name are found under a different commit, they are deleted, and if they don't point to the same file as the current files, those blob files are also deleted. If the commit folder ends up empty, it is cleaned up as well.
Unreferenced blobs are not being touched, since we don't have any information on what the file is used for and it might be bad to delete them.
Tests
For testing, I recreated a directory structure for unsloth/gemma-4-26B-A4B-it using these commands, and made sure only the latest version was kept:
Here's the current output:
Requirements