Scalar encodings for immutable model checkpoints #
The tensor container checks shapes and lengths; Checkpoint.Encoding checks scalar payloads.
Native formats preserve the bits their values export; Lean canonicalizes native NaNs. Their
decoders reject noncanonical NaN words instead of silently changing a payload. Configured binary
formats preserve all encodings, including NaN payloads. Complex values encode both coordinates
using the component encoding. No value passes through a narrower native format.
A versioned scalar checkpoint representation, with explicit rejection of malformed values.
- format : String
Identifies the scalar format and schema. Different interpretations need different tags.
- encode : α → Lean.Json
Encode one scalar without changing its precision.
Decode one scalar, rejecting out-of-range or incorrectly shaped payloads.
Instances
The existing binary64 JSON format, preserving compatibility with saved Float checkpoints.
Exact binary32 words for immutable CPU state. Streamed runtime checkpoints remain separate.
Configured binary checkpoints include the complete numerical format, independently of storage plan.
Exponent width, fraction width, bias, and exceptional-value encoding all participate in the tag. Two equal-width formats with different interpretations therefore cannot be confused on loading.