Model files are tiny pointer files — git-lfs not installed (invalid load key 'v')
You cloned a model repo without Git LFS, so every weight file is a 130-byte text stub. Install git-lfs and run git lfs pull — or skip git and use huggingface-cli download.
Updated
The error
Loading the "weights" produces format errors:
_pickle.UnpicklingError: invalid load key, 'v'.
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge
And the files themselves are suspiciously small text:
$ cat model.safetensors version https://git-lfs.github.com/spec/v1 oid sha256:9a5cbf2de4f1cf8f1c1f5b8e6c9d1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f size 4915916800
What it means
Repos with big files store pointer files in Git — small text records naming the real content — while Git LFS fetches the actual bytes. Cloning without LFS installed (or with smudging skipped) checks out the pointers as if they were the files. Your model.safetensors is 134 bytes of text whose first word is version — and unpickling text starting with v is exactly what invalid load key, 'v' reports.
Why it happens
Git works perfectly without LFS — nothing warns during the clone. The stub files carry the right names, so everything looks normal until a loader reads one. Fresh machines, minimal Docker images and CI runners commonly lack git-lfs, and GIT_LFS_SKIP_SMUDGE=1 (sometimes set to survive quota errors) produces the same layout deliberately.
How to fix it
1. Confirm the diagnosis in five seconds.
ls -lh model.safetensors
head -c 200 model.safetensorsA file measured in bytes, beginning version https://git-lfs..., is a pointer. Done diagnosing.
2. Install git-lfs and pull the real content.
# Ubuntu/Debian: sudo apt install git-lfs
# macOS: brew install git-lfs
# Windows: winget install GitHub.GitLFS
git lfs install
git lfs pullRun inside the repo. git lfs pull replaces every stub with its real content — expect gigabytes of download.
3. Or skip git for models entirely — use the Hub tooling.
huggingface-cli download mistralai/Mistral-7B-Instruct-v0.3Or in code, from_pretrained("org/model"), which caches under ~/.cache/huggingface. The Hub downloaders resume interrupted transfers and never produce stub files, which makes them the better default for weights.
4. In Docker and CI, install git-lfs before any clone that needs weights — or better, download weights as a separate cached step with the Hub tooling, keeping images and clones light.
How to prevent it
Make git lfs install part of machine setup if you clone model repos at all. Better, adopt the split: git clones for code, huggingface-cli download for weights. And when any model file loads with a bizarre format error, check its size first — the 134-byte impostor is found by ls faster than by any debugger.
Related errors
- SafetensorError: error while deserializing header — the same stub hitting the safetensors loader
- This repository is over its data quota — when LFS itself refuses to serve the content
- Weights only load failed (torch.load)