Comfy-Org/ComfyUI · error · ValueError
{}\n\nFile path: {}\n\nThe safetensors file is corrupt/incom
Error message
{}\n\nFile path: {}\n\nThe safetensors file is corrupt/incomplete. Check the file size and make sure you have copied/downloaded it correctly. What it means
When loading a .safetensors file, safetensors raises MetadataIncompleteBuffer when the declared header size exceeds the bytes actually present in the file — i.e. the file is truncated relative to its own header. ComfyUI catches this in load_torch_file and raises a ValueError pointing at incomplete copy/download.
Source
Thrown at comfy/utils.py:148
if not return_metadata:
metadata = None
else:
with safetensors.safe_open(ckpt, framework="pt", device=device.type) as f:
sd = {}
for k in f.keys():
tensor = f.get_tensor(k)
if DISABLE_MMAP: # TODO: Not sure if this is the best way to bypass the mmap issues
tensor = tensor.to(device=device, copy=True)
sd[k] = tensor
if return_metadata:
metadata = f.metadata()
except Exception as e:
if len(e.args) > 0:
message = e.args[0]
if "HeaderTooLarge" in message:
raise ValueError("{}\n\nFile path: {}\n\nThe safetensors file is corrupt or invalid. Make sure this is actually a safetensors file and not a ckpt or pt or other filetype.".format(message, ckpt))
if "MetadataIncompleteBuffer" in message:
raise ValueError("{}\n\nFile path: {}\n\nThe safetensors file is corrupt/incomplete. Check the file size and make sure you have copied/downloaded it correctly.".format(message, ckpt))
raise e
else:
torch_args = {}
if MMAP_TORCH_FILES:
torch_args["mmap"] = True
pl_sd = torch.load(ckpt, map_location=device, weights_only=True, **torch_args)
if "state_dict" in pl_sd:
sd = pl_sd["state_dict"]
else:
if len(pl_sd) == 1:
key = list(pl_sd.keys())[0]
sd = pl_sd[key]
if not isinstance(sd, dict):
sd = pl_sd
else:
sd = pl_sdView on GitHub (pinned to 1c6d8d45b3)
Solutions
- Re-download or re-copy the safetensors file and verify its byte size matches the source
- Check hash if the source publishes one (sha256/civitai hash)
- If it is a cloud-sync placeholder, force the sync app to materialize the file before loading
Example fix
// before
sd = utils.load_torch_file('model.safetensors') # truncated
# after
# re-download, then verify expected size before loading
assert os.path.getsize('model.safetensors') == EXPECTED_BYTES
sd = utils.load_torch_file('model.safetensors') Defensive patterns
Strategy: validation
Validate before calling
import os
expected = 6425467122 # from source metadata if known
if path.endswith('.safetensors') and os.path.getsize(path) < 1_000_000:
raise ValueError('safetensors suspiciously small; download likely incomplete') Try / catch
except ValueError as e:
if 'corrupt/incomplete' in str(e):
# trigger re-download path
raise Prevention
- Verify file size/hash against the source after downloading
- Avoid loading files while a download or cloud sync is still in progress
When it happens
Trigger: load_torch_file on a .safetensors file truncated by an interrupted download/transfer, or a file corrupted by disk issues, such that the header region is incomplete.
Common situations: Browser download cut off; scp/rsync interrupted; cloud-sync placeholder files; file copied while still being written.
Related errors
- {}\n\nFile path: {}\n\nThe safetensors file is corrupt or in
- Unsupported RIFE model: expected 5 blocks, found {len(channe
- The provided model does not have a heatmap_head. Please use
- INVALID_TAG_FILTER
- ERROR: audio encoder file is invalid or unsupported embed_di
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/a35a4b0bf2841b41.
Report an issue: GitHub.