pytorch-reader: checkpoints saved with compute_crc32=False fail to open with "Invalid checksum"
Author: antimoraCreated Sep 17, 2026Updated Sep 17, 2026
Labelsbugstore
Summary
torch.utils.serialization.config.save.compute_crc32 = False makes torch.save write a CRC of 0 in every entry's header. PytorchReader::new then fails on the first entry it reads to the end, byteorder, because the zip crate verifies the CRC once a read reaches an entry's end. Such checkpoints cannot be opened at all. PyTorch's own loader accepts them.
Repro (torch 2.14.0)
import torch
from torch.utils.serialization import config
config.save.compute_crc32 = False
torch.save({"w": torch.tensor([1.0, 2.5, -3.7, 0.0])}, "nocrc.pt")zipfile.ZipFile("nocrc.pt").infolist() shows CRC == 0x0 for every entry.
PytorchReader::new("nocrc.pt")
Err(Io(Custom { kind: InvalidData, error: "ZIP entry 'nocrc/byteorder': Invalid checksum" }))Where
ZipSource::read_entry streams through the zip crate's Crc32Reader, which compares on reaching the entry's end. The fix for #5711 adds the same check with crc32fast for whole-entry tensor reads of stored entries (ZipSource::read_stored). Both need the same rule.
Options
- Treat a header CRC of
0as "not computed" and skip verification. The CRC of an empty entry is also0, so that case is unaffected; a non-empty entry whose true CRC happens to be0(1 in 2^32) loses its check. This is what the flag means on the writing side. - An open-time opt-out on
PytorchReader, leaving the default strict.
Source: tracel-ai/burn