core/nn/serialize library
Simple parameter checkpointing for Modules.
The checkpoint format is stable and self-describing:
magic: "DPTC" (4 bytes)
version: uint32 LE (currently 1)
headerLen: uint32 LE
header: UTF-8 JSON, length = headerLen
{
"version": 1,
"params": [{"shape": [<int>, ...]}, ...],
"totalScalars": <int>
}
data: totalScalars * 4 bytes of Float32 LE
Parameters are serialized in the exact order returned by
module.parameters() — no names, no reflection. Loading is done
against an already-constructed module of the same architecture
(same order and shapes); each tensor is assigned in place, so
optimizer state buffers keyed by parameter identity remain valid.
GPT-style tied weights (e.g. GPT with tieWeights: true) work
transparently: the tied tensor is exposed once in parameters()
so it is saved once and loaded once.