[ERROR] !!! Exception during processing !!! Error while deserializing header: incomplete metadata, file not fully covered

#1
by sumirecccp - opened

I think there's something wrong with the lora file...

It is working, I have tested it. Which workflow did you use, and what model?
did you used this one, https://huggingface.co/Abiray/MiniMax-H3-Turbo-Lora-Pruned-ComfyUI/blob/main/Minimax_H3_turbo_workflow.json if not try it, i got no issue with this, and it smoothly generated the 10 second video in less then 8 minutes.

Abiray changed discussion status to closed
Abiray changed discussion status to open

Got the same error running the same LoRA against a regular safetensors.
This script patched and fixed (automatic backup!) the LoRA for me, and it functions well.

import struct, json, os, shutil

p = r"ComfyUI\models\loras\h3\distil\minimax_h3_turbo_4step_ckpt600_ema_V4.safetensors"
size = os.path.getsize(p)

# Parse declared size
with open(p, "rb") as f:
    hdr_len = struct.unpack("<Q", f.read(8))[0]
    hdr = json.loads(f.read(hdr_len))

tensors = {k: v for k, v in hdr.items() if k != "__metadata__"}
max_end = max(v["data_offsets"][1] for v in tensors.values())
expected = 8 + hdr_len + max_end
print(f"Actual size: {size}")
print(f"Declared/expected size: {expected}")
assert size > expected, "File smaller than declared? Investigate before trimming."

# Backup, then trim
bak = p + ".bak64"
shutil.copy2(p, bak)
print(f"Backup written to: {bak}")

with open(p, "r+b") as f:
    f.truncate(expected)

print(f"Trimmed to {os.path.getsize(p)} bytes")

# Verify with the same library ComfyUI uses
import safetensors
from safetensors import safe_open
with safe_open(p, framework="pt", device="cpu") as f:
    keys = list(f.keys())
    print(f"Loaded OK. {len(keys)} tensors.")
    print("First 3:", keys[:3])
    print("Last 3:", keys[-3:])
    # sanity: read a small tensor end-to-end
    k = keys[-1]
    t = f.get_tensor(k)
    print(f"Read last tensor {k}: shape={tuple(t.shape)}, dtype={t.dtype}, sum={t.float().sum().item():.6f}")
print("VERIFICATION PASSED")

It's entirely vibecoded, so use with caution.

Sign up or log in to comment