Expand description
Model serialization for AxonML.
Save/load in .axonml (binary), .json, and SafeTensors formats. StateDict
(PyTorch-compatible named parameter collection), Checkpoint with
TrainingState (loss/val-loss/metric history, epoch/step, config map),
format auto-detection (by extension and magic bytes), PyTorch weight
conversion (convert_pytorch_key, convert_full_dict, linear weight
transposition), metadata embedding, ONNX shape utilities.
§File
crates/axonml-serialize/src/lib.rs
§Author
Andrew Jewell Sr. — AutomataNexus LLC ORCID: 0009-0005-2158-7060
§Updated
April 14, 2026 11:15 PM EST
§Disclaimer
Use at own risk. This software is provided “as is”, without warranty of any kind, express or implied. The author and AutomataNexus shall not be held liable for any damages arising from the use of this software.
Structs§
- Bundle
Header - Lightweight header decoded before the weights blob. Kept in sync with
the Python converter’s
parse_axonmlheader JSON (must round-trip verbatim). - Checkpoint
- A complete training checkpoint.
- Checkpoint
Builder - Builder for creating checkpoints.
- Model
Bundle - Full bundle payload carrying everything the ONNX converter needs.
- State
Dict - State dictionary for storing model parameters.
- State
Dict Entry - An entry in the state dictionary.
- Tensor
Data - Serializable tensor data.
- Training
State - Training state for checkpointing.
Enums§
- Bundle
Error - Errors produced by bundle save/load.
- Format
- Supported serialization formats.
- Onnx
OpType - ONNX operator type mapping.
Constants§
- AXONML_
BUNDLE_ VERSION - Current bundle format version.
- AXONML_
MAGIC - Magic bytes at the start of every
.axonmlbundle file.
Functions§
- convert_
from_ pytorch - Convert a state dict from
PyTorchnaming conventions. - detect_
format - Detect the format from a file path based on extension.
- detect_
format_ from_ bytes - Detect format from file contents (magic bytes).
- from_
onnx_ shape - Convert from ONNX shape (handling -1 for dynamic dimensions).
- from_
pytorch_ key - Convert a PyTorch-style key to Axonml format.
- load_
bundle - Read a bundle from disk, returning both the header (decoded eagerly) and the full payload.
- load_
bundle_ from_ bytes - In-memory variant of
load_bundle— useful for HTTP handlers or tests. - load_
checkpoint - Load a training checkpoint.
- load_
header - Decode only the header of a
.axonmlfile without reading the weights blob. - load_
model - Load a model’s parameters from a saved state dictionary file.
- load_
state_ dict - Load a state dictionary from a file.
- pytorch_
layer_ mapping - Map of
PyTorchlayer names to Axonml equivalents. - save_
bundle - Write a bundle to disk in the
.axonmlcontainer format. - save_
checkpoint - Save a complete training checkpoint.
- save_
model - Save a model’s state dictionary to a file.
- save_
state_ dict - Save a state dictionary to a file with specified format.
- to_
onnx_ shape - Convert a shape to ONNX format (with batch dimension handling).
- to_
pytorch_ key - Convert an AxonML key to PyTorch format.
- transpose_
linear_ weights - Transpose weights if needed for format conversion.
Type Aliases§
- Bundle
Result - Convenience alias for bundle operation results.