TorchLean API

NN.Runtime.PyTorch.Export.StateDict

PyTorch state_dict Bridge #

This module is the general weight-interchange path for PyTorch users.

The important split is:

Lean should not try to parse PyTorch pickle/zip checkpoints directly. Instead, we emit a small Python adapter that loads a checkpoint with PyTorch, normalizes common wrappers such as {"state_dict": ...}, and writes shape-checkable JSON:

{
  "params": { "layer.weight": [[...]], "layer.bias": [...] },
  "meta": { "layer.weight": { "shape": [out, in], "dtype": "torch.float32" } }
}

NN.Runtime.PyTorch.Import.Core then parses the "params" object into typed TorchLean tensors. Architecture-specific loaders are still useful, but only for mapping names and shapes. The transport format itself is model-agnostic.

References: