TorchLean API

NN.Runtime.Autograd.Model.StateIO.Encoding

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 : Lean.JsonExcept String α

    Decode one scalar, rejecting out-of-range or incorrectly shaped payloads.

Instances

    Parse a storage word without silently reducing an out-of-range input modulo its width.

    Instances For
      @[instance_reducible]

      The existing binary64 JSON format, preserving compatibility with saved Float checkpoints.

      @[instance_reducible]

      Exact binary32 words for immutable CPU state. Streamed runtime checkpoints remain separate.

      @[instance_reducible]

      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.

      @[instance_reducible]

      A complex scalar is an ordered pair of independently encoded real and imaginary coordinates.