Executable Modules #
Executable module operations for manual runtime and example code.
Live parameter and buffer storage shared by executable modules.
The shape list remains in the type, so replacing the state cannot silently reorder parameters or load tensors with incompatible dimensions. Mutation is confined to this runtime object; model and layer definitions remain immutable values that can be lowered and reasoned about.
- stateRef : Runtime.Autograd.Torch.ParamList α stateShapes
- runtime : TorchLean.Runtime.Config
- modeRef : IO.Ref TorchLean.nn.Mode
Instances For
Assemble runtime state from storage that has already been allocated.
Instantiate runtime state after converting semantic initializer tensors to α.
Instances For
Reveal parameter storage only to executable-module implementation code.
Reveal runtime configuration only to executable-module implementation code.
Reveal the train/eval mode cell only to executable-module implementation code.
Preserve random-operation order across successive forwards of the same module.
Read the current behavior of training-sensitive layers.
Instances For
Enable training behavior.
Instances For
Enable evaluation behavior.
Instances For
Return true exactly when the state uses training behavior.
Instances For
Read all parameters and buffers, synchronizing device storage when necessary.
Instances For
An ordinary tensor model with live, mutable runtime state.
nn.Sequential remains the immutable, shape-checked model definition used by proofs and graph
lowering. An nn.Module is its runtime counterpart: it owns one parameter set and a mutable
train/eval flag. This separation gives executable code the familiar module lifecycle without
hiding mutation inside the mathematical model.
- runtimeState : TorchLean.Module.RuntimeState α (Runtime.Autograd.Model.Layers.Seq.stateShapes model)
Instances For
An indexed-input model with live, mutable runtime state.
- runtimeState : TorchLean.Module.RuntimeState α model.stateShapes
Instances For
Wrap live runtime state behind the public module boundary.
Reveal live runtime state only to module implementation code.
Instantiate a checked model with mutable parameter and buffer storage.
Native binary32 is the default. Select another supported element type with
nn.Module.instantiate model (α := Float).
Instances For
Read whether training-sensitive layers currently use training or evaluation behavior.
Instances For
Enable training behavior for dropout, normalization buffers, and similar layers.
Instances For
Enable deterministic evaluation behavior for training-sensitive layers.
Instances For
Return true exactly when this module uses training behavior.
Instances For
Read the complete parameter-and-buffer state, synchronizing device storage when necessary.
Instances For
Replace the complete shape-indexed parameter-and-buffer state.
Instances For
Execute one ordinary module forward in an explicit mode without changing its mode cell.
Instances For
Evaluate one concrete input without constructing a backward tape.
The module's mode controls training-sensitive layer behavior. Training forwards update running
buffers from their actual activations and advance the module's random stream. This concrete call
does not construct a backward tape; differentiable model programs use nn.forward.
Instances For
Evaluation-mode inference without changing the module's persistent mode.
Keeping the override local to this call prevents concurrent forwards from observing a temporary mode change.
Instances For
Wrap live runtime state behind the public indexed-module boundary.
Reveal live runtime state only to indexed-module implementation code.
Instantiate an indexed model. Native binary32 is the default runtime element type.
Instances For
Read the current behavior of training-sensitive layers.
Instances For
Enable training behavior.
Instances For
Enable evaluation behavior.
Instances For
Return true exactly when the module uses training behavior.
Instances For
Read the complete parameter-and-buffer state.
Instances For
Replace the complete shape-indexed parameter-and-buffer state.
Instances For
Execute one indexed module forward in an explicit mode without changing its mode cell.
Instances For
Evaluate one validated index tensor without constructing a backward tape.
Instances For
Evaluation-mode inference without changing the module's persistent mode.
Keeping the override local to this call prevents concurrent forwards from observing a temporary mode change.
Instances For
Run evaluation-mode prediction through a supervised runtime module.
Instances For
Evaluate one supervised sample through a runtime module and return the scalar loss value.
This packages the common internal pattern Module.Objective.loss ...; Tensor.item.
Instances For
Bind an optimizer to the hidden runtime objective.
Instances For
Create a reusable evaluator for a data-only objective that shares an executable module's state.
The returned function accepts ordinary tensors and hides both the heterogeneous pack representation and the reusable eager session used underneath.
Instances For
Create a reusable evaluation-mode predictor for an indexed model sharing this objective's state.
This is useful after training an indexed loss: prediction sees the updated parameters without requiring callers to construct a runtime program, evaluator, or tensor pack.
Instances For
Validate and instantiate the optimizer shared by manual and mixed-dtype module loops.
Instances For
Create a one-step update function for any typed module input pack from the public optimizer config used by the trainer API.
Generic bridge for custom training loops: richer examples can keep their own control flow while
still choosing a public optim.* config through the same API as Trainer.RunConfig.
Instances For
Create a two-input update function for a mixed-dtype, data-only objective.
The returned function takes ordinary typed tensors. Optimizer state and heterogeneous runtime packs
remain implementation details. Configuration values must remain in their required domains after
conversion to the optimizer scalar, as checked by its Runtime.FromFloat instance. CUDA also
requires binary32-valid settings even when the host scalar is Float.