Trainer Parameters #
Mutable, shape-indexed parameter storage for the Torch-style trainer. Parameter values may retain a
CUDA mirror; reads and writes keep host and device ownership explicit through the underlying
Param operations.
A dependent pack of mutable parameters indexed by their tensor shapes.
- nil {α : Type} [TorchLean.Storage α] : ParamList α []
- cons {α : Type} [TorchLean.Storage α] {s : Spec.Shape} {ss : List Spec.Shape} : Param α s → ParamList α ss → ParamList α (s :: ss)
Instances For
Parameter storage in list order, retaining none at every frozen slot.
Instances For
Instances For
Map each trainable slot to the first trainable slot sharing all its mutable storage cells.
Frozen slots remain none; list indices are never compressed. This is the shared alias map for
optimizer updates and checkpoint schemas. Storage identity does not inspect tensor elements.
Rebuild the reference index from this list on each call. This preserves changes to the alias layout while avoiding pairwise identity checks among independent storages.
Instances For
Allocate mutable parameters from an ordered tensor pack.
Instances For
Allocate mutable parameters with an explicit trainability mask.
The mask follows parameter order and must have exactly the same size as the shape list.
Instances For
Instances For
Read the trainability mask in parameter order.
Instances For
Instances For
Read current host parameter values without synchronizing stale CUDA mirrors.
Instances For
Read parameter values after synchronizing any current CUDA mirrors to the host.
Instances For
Replace host parameter values from an ordered tensor pack.
Instances For
Sum occurrence gradients at their canonical parameter slots, in list order.
Frozen slots contribute nothing. The first gradient is retained directly so a parameter with no aliases keeps the same arithmetic as an ordinary update. Complete shape and index validation precedes any parameter mutation by the caller.
Instances For
Instances For
Read one canonical gradient, checking its runtime shape.