CUDA Adam Checkpoints #
The eager trainer records parameter leaves before input leaves on every step. Their tape identifiers are the stable zero-based parameter slots used by this internal format. The reader checks every slot against the shared optimizer schema before installing any state.
Device-side Adam moment buffers for one parameter leaf.
- m : LibTorch.Buffer
First moment buffer.
- v : LibTorch.Buffer
Second moment buffer.
- t : ℕ
Adam step counter for this parameter.
Instances For
Adam moment state keyed by the eager trainer's parameter-leaf slot.
Instances For
The update rule associated with a CUDA Adam-family state.
- adam : CudaAdamKind
- adamW : CudaAdamKind
Instances For
Instances For
Hyperparameters that determine the meaning of retained Adam-family moments.
- dtype : LibTorch.Dtype
Arithmetic and storage of the parameters and moments, not their host coefficient type.
- kind : CudaAdamKind
- beta1 : Float
- beta2 : Float
- epsilon : Float
- weightDecay : Float
Instances For
Human-readable name used in checkpoint diagnostics.
Instances For
Compare configurations by exact floating-point bit pattern.
Instances For
Reject invalid Adam-family hyperparameters before updating or restoring device state.
Epsilon must remain finite and positive after conversion to the parameter dtype, as in the native kernel.
Instances For
Version 2 header, retained for layouts with independent trainable parameters.
Instances For
Version 3 records storage sharing while retaining the original parameter-slot identifiers.
Instances For
Version 4 also restores the eager session's random-operation counter.
Instances For
Version 5 retains the moment dtype and an optional random counter. Older files are binary32.
Instances For
Read a supported header and reject a legacy checkpoint when the destination shares parameters.
Version 2 contains no sharing information. Its per-slot histories cannot establish which moment pair belongs to shared storage, so an aliased trainer must start a fresh history or load version 3 or later. Version 4 carries the random-operation counter as well. The check precedes config parsing and all device allocation.
Instances For
Release every device buffer owned by an Adam state map.
Instances For
Bind an in-memory moment map to one optimizer configuration.
Changing Adam to AdamW, or changing a moment-defining hyperparameter, requires a fresh state rather than silently reinterpreting existing moments.
Instances For
Serialize the hyperparameters as a tag plus four raw bit patterns.
Bits rather than decimal text: a checkpoint has to restore the same moments bit for bit, and a
decimal round trip of a Float is exactly where that guarantee would be lost.
Instances For
Inverse of writeConfig. An unrecognized kind tag fails loudly rather than defaulting to Adam,
since silently reading AdamW moments as Adam moments would corrupt training quietly.
Instances For
Stream CUDA Adam or AdamW moments to disk.
The file includes the optimizer configuration and the complete ordered parameter schema. Shared parameters use version 3 and one moment entry per representative; independent parameters keep the version 2 encoding. For binary32, supplying the session counter selects version 4, which retains both storage sharing and the next random key. Binary64 uses version 5 to retain its dtype and eight-byte moments, with or without a random counter. Saving before the first Adam-family update is rejected because no optimizer state has yet been defined.
Instances For
Read a whole CUDA Adam checkpoint: metadata, then one moment pair per representative.
The state is built in a local map and only installed once every parameter has been read and checked
against schema, so a truncated file leaves the live optimizer untouched.
Instances For
Restore CUDA Adam or AdamW moments after validating their optimizer and parameter metadata.
The old state remains live until the replacement has been parsed completely. Duplicate ids, frozen or out-of-range parameters, zero step counters, trailing bytes, and truncated payloads are rejected.