Safetensors HeaderTooSmall & Incomplete Metadata
Fix SafetensorError HeaderTooSmall, MetadataIncompleteBuffer, and incomplete metadata file not fully covered by checking LFS pointers and truncated downloads.
HeaderTooSmall means the .safetensors file is under 8 bytes (often a 0-byte failed save), whereas MetadataIncompleteBuffer or incomplete metadata, file not fully covered means the download or checkpoint write truncated mid-file. Inspect file byte size and the first 64 bytes before re-downloading or restoring from the previous verified shard.
- Symptom
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooSmall- Root cause
- The target .safetensors file is empty, truncated on disk, or contains a Git LFS pointer instead of the complete serialized tensor binary.
- Recommended fix
- Check exact byte size with ls -lh *.safetensors and inspect the opening bytes with head -c 128 model.safetensors to spot Git LFS pointers (version https://git-lfs.github.com/spec/v1).
- How Denpex helps
- Denpex investigates Safetensors HeaderTooSmall & Incomplete Metadata using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
What this failure is
Safetensors Rust deserialization errors raised when a file is shorter than its 8-byte length prefix or ends before the declared header and tensor byte offsets.
Is this what broke your run? Paste your log.
You're reading about Safetensors HeaderTooSmall & Incomplete Metadata. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
Why it happens (the mechanism)
Safetensors validates the 8-byte little-endian header length against actual file length before reading tensors. Interrupted downloads, unpulled Git LFS pointer files, or crashing checkpoint writers leave fewer bytes on disk than the header specifies.
What you'll observe
- Model loading aborts immediately in safetensors_rust during header deserialization.
- Truncated shards or 0-byte placeholder files look like valid .safetensors paths by filename alone.
Common symptoms and what they mean
Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.
| Symptom | Possible explanation |
|---|---|
| safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooSmall | The target .safetensors file is empty, truncated on disk, or contains a Git LFS pointer instead of the complete serialized tensor binary. |
| safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer | The target .safetensors file is empty, truncated on disk, or contains a Git LFS pointer instead of the complete serialized tensor binary. |
| safetensors_rust.SafetensorError: Error while deserializing header: incomplete metadata, file not fully covered | The target .safetensors file is empty, truncated on disk, or contains a Git LFS pointer instead of the complete serialized tensor binary. |
Which systems are affected
- Hugging Face Transformers, Diffusers, vLLM, and ComfyUI loading .safetensors weights
- Distributed training checkpoint saves interrupted mid-write
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Run python3 -c "import struct, os; f=open('model.safetensors','rb'); n=struct.unpack('<Q', f.read(8))[0]; print('header_len', n, 'file_bytes', os.path.getsize('model.safetensors'))".
- ✓Compare the local file size against the expected size in model.safetensors.index.json or upstream repo.
Root cause
- The target .safetensors file is empty, truncated on disk, or contains a Git LFS pointer instead of the complete serialized tensor binary.
The fix and how to prevent it
How to fix it
- Check exact byte size with ls -lh *.safetensors and inspect the opening bytes with head -c 128 model.safetensors to spot Git LFS pointers (version https://git-lfs.github.com/spec/v1).
- For MetadataIncompleteBuffer or incomplete metadata, delete the partial cache shard and re-download using hf download or huggingface-cli download with SHA256 verification.
- Run git lfs pull if the repository was cloned with Git without LFS binary materialization.
- If the error came from your own training checkpoint save, inspect disk space (df -h) and resume from the previous complete checkpoint directory.
Step-by-step remediation
- 1Run ls -lh and inspect the first bytes without parsing tensors to detect empty files or LFS pointers.
- 2Clear the corrupted shard from the Hugging Face cache and download again with checksum verification.
- 3Load the model in Python using safetensors.safe_open to confirm all metadata and shards resolve cleanly.
How to prevent it
- Verify SHA256 digests from the upstream Hugging Face repo manifest after downloading shards.
- Write checkpoints to a temporary file and atomically rename only after flush and fsync succeed.
Save this diagnosis and catch the next crash automatically
All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.
Or start a 30-day free Team trial (work email)
Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.
Searchable error signature
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooSmall
safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBufferUse this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.
Diagnose your own log automatically
The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.
Sign up free. Analyze your cluster logsNo credit card. Daily allowance follows verified trust tier. Instant access.
Why the recommended fix works
Checking file byte length and prefix bytes separates empty saves, Git LFS text pointers, and partial shard transfers in seconds without modifying parser guards.
Code examples
ls -lh *.safetensors
head -c 100 model.safetensors
rm -f model.safetensors && huggingface-cli download <org>/<repo> model.safetensorsThis snippet illustrates the entry-specific check. Verify the installed versions, permissions, target and workload context before using it. A command or API example is not proof of recovery.
Best practices by model family
| Model / Stack | Recommendation | Notes |
|---|---|---|
| HeaderTooSmall | Check for 0-byte or <8-byte file | Almost always a failed/empty file creation or truncated empty stub. |
| MetadataIncompleteBuffer | Re-download truncated shard | File ended mid-header or mid-tensor payload; compare size and SHA256. |
With the fix vs without the fix
| Dimension | With the fix | Without the fix |
|---|---|---|
| Prefix check | Inspect size + first 64 bytes safely | Converting or force-loading via pickle |
| Recovery | Clean re-download or prior checkpoint | Retrying load against partial file |
Diagnostic note
“Based on the Hugging Face safetensors binary header format specification.”
Visual fingerprint
SafetensorError -> <8 bytes (HeaderTooSmall) | truncated mid-file (MetadataIncompleteBuffer) | ASCII LFS/HTML (HeaderTooLarge)
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.
Install the free VS Code extensionFrequently asked questions
Questions engineers and on-call staff commonly ask about this failure.
What causes SafetensorError: MetadataIncompleteBuffer or incomplete metadata?
How is HeaderTooSmall different from HeaderTooLarge?
Don't just read the fix, diagnose your run
The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.