Runtime Supervised Training #
Training loops for in-memory datasets and DataLoaders. A list-valued batch means gradient
accumulation: every dataset item is differentiated at the same parameter point, the typed gradient
packs are averaged, and the optimizer is applied once. An item may itself contain a fixed-size
tensor minibatch; use a list batch of one for one vectorized pass in that case.
Gradient accumulation #
Add two shape-aligned gradient packs and materialize every result tensor.
Instances For
Scale a shape-aligned gradient pack and materialize every result tensor.
Instances For
Compute mean parameter gradients for a nonempty sample batch at one parameter point.
Mutable model buffers advance before differentiation. Trainable parameters remain fixed until all sample gradients have been collected.
Instances For
Compute the mean loss and parameter gradients for a nonempty sample batch at one parameter point.
Use this form only when the caller needs the loss value. On CUDA, reading that scalar back to the host synchronizes the device.
Instances For
Apply one optimizer update without reading a loss scalar.
useNativeSingleton is chosen once by the surrounding loop. Keeping it fixed prevents a final
partial loader batch from switching between device-resident and host optimizer state.
Instances For
Apply one optimizer update and return the loss from the gradient-producing tapes.
Instances For
Run the fixed-step in-memory loop for one concrete optimizer state type.
Instances For
In-memory datasets #
Train on an in-memory sample list for a fixed number of optimizer updates.
cfg.batchSize controls how many dataset items contribute to each update. It does not multiply the
number of optimizer steps. If an item is already a vectorized tensor minibatch, use batchSize := 1
unless you intend to accumulate gradients across several such minibatches.
Instances For
Train over a dataset by materializing its sample list.
Instances For
Data loaders #
Run all loader epochs for one concrete optimizer state type.
Instances For
Instances For
Instances For
Train over a DataLoader.
Every loader batch contributes one averaged-gradient optimizer update. The scheduler advances once per epoch.