These notes record the subset reverse-engineered for PTHrs 0.2.0.
Modern PyTorch checkpoints begin with a ZIP local-file header (PK\x03\x04).
All relevant paths normally share one generated prefix:
<prefix>/data.pkl
<prefix>/byteorder
<prefix>/version
<prefix>/data/0
<prefix>/data/1
...
data.pkl is small relative to the model. Each data/<id> entry is a raw
typed storage byte array. PyTorch normally stores these entries without ZIP
compression and adds alignment padding to the local-header extra field.
Tensor records use torch._utils._rebuild_tensor_v2 with arguments equivalent
to:
(storage, storage_offset, shape, stride, requires_grad, backward_hooks)
The storage value is supplied by the pickle BINPERSID opcode. Its persistent
ID is normally:
("storage", torch.<DType>Storage, "<id>", "<device>", element_count)
PTHrs maps <id> to <prefix>/data/<id>. The device string is retained but
does not affect reading.
The storage offset and stride are measured in elements, not bytes. For a tensor
coordinate i, the storage element is:
storage_offset + sum(i[axis] * stride[axis])
read_tensor returns contiguous row-major bytes. If the saved view is already
contiguous, PTHrs performs one bounded range read. Otherwise it reads the
smallest enclosing storage span and gathers elements in logical order.
Common inference checkpoints contain:
weight: state dictionary from parameter names to tensorsconfig: positional network configurationinfo: training checkpoint label or epochsr: sampling-rate label such as40kf0: whether pitch guidance is enabledversion: application architecture version such asv1orv2
These remain generic Value data so callers can handle future variations.