Views
No views yet
.pt2
resource-exhaustion issue.torch.export.load()
encounters an empty raw tensor record, PyTorch treats the empty bytes as a
special case and allocates a zero-filled tensor using the shape declared in
model_weights_config.json.[134217728]. Loading it causes PyTorch to allocate a
512 MiB zero tensor during normal torch.export.load().pytorch/pytorch commit
c7656354cff2e2c4f9aee5695d3e7f37e3006dd4torch==2.12.1+cpupython -c 'import torch; obj=torch.export.load("control.pt2"); print(obj.state_dict["p"].shape)'torch.Size([1])python -c 'import torch; obj=torch.export.load("zero-payload-512m.pt2"); print(obj.state_dict["p"].shape)'torch.Size([134217728])python mutate_and_measure_pt2_zero_payload.pyDefaultCPUAllocator: can't allocate memory: you tried to allocate 536870912 bytes(134217728,).control.pt2 - benign control archive, SHA256
cb79c7913524f08255f74214f37b8bce500ac80b4bf6f2d6f3979116c42287c1zero-payload-512m.pt2 - malicious 5,558-byte PT2 archive, SHA256
7e4c2c3ab37ac28f6ad4e307b77ae75fd2d655b15f9cbeb6832ac02702e2b18amutate_and_measure_pt2_zero_payload.py - generator/measurement script,
SHA256 d1c3887e4f7d612c428c1a66c2ecada91d9b7bdcf42d17cc383303818b6f0690zero_payload_measurements_latest.json - local measurement report,
SHA256 33ee2b71e6964773228a693aba4696679167a49a9f806df844ec69bafe8ed311torch/export/pt2_archive/_package.py, the PT2 loader reads
model_weights_config.json and the referenced raw tensor record. For non-empty
records it validates byte alignment before mapping tensor storage. For empty
records, it logs that torch.frombuffer() cannot operate on empty bytes and
creates a zero tensor as a workaround:torch.zeros(size, dtype=dtype, device=device)size value comes from archive-controlled tensor metadata, so a tiny PT2
archive can force a large allocation during load.