TorchLean API

NN.API.Trainer.Run

Training Options #

Datasets, probes, runtime flag parsing, and per-training options for the trainer API.

structure TorchLean.Trainer.Dataset (σ τ : Shape) :

Supervised dataset that can be materialized at the trainer's selected scalar type.

Instances For
    structure TorchLean.Trainer.Probe (σ : Shape) :

    A small input probe printed before and after training.

    Instances For

      Two-coordinate vector probe for small tabular regression examples.

      Instances For
        def TorchLean.Trainer.Probe.ofFloatTensor {σ : Shape} (name : String) (x : Tensor.T Float σ) (inputText : String := "") (expected : Option String := none) :

        Probe built from a concrete Float tensor.

        Instances For

          Override the scalar dtype for this run configuration.

          Instances For

            Override the execution backend for this run configuration.

            Instances For

              Override the execution device using a maintained backend profile.

              Instances For

                Select a complete backend contract profile.

                The profile carries the device, provider preference, assurance policy, VJP ownership, and capsule registry together. It can select, for example, LibTorch forward execution with a TorchLean-owned backward pass.

                Instances For

                  Enable or disable first-use backend capsule reporting.

                  Instances For

                    Use the eager runtime backend.

                    Instances For

                      Use the proof-compiled runtime backend.

                      Instances For

                        Run on CPU.

                        Instances For

                          Run on CUDA.

                          Instances For

                            Apply parsed runtime/device options to a persistent trainer run configuration.

                            Instances For

                              Build a run configuration from parsed runtime flags and trainer choices.

                              Instances For

                                Convert a run configuration to the runtime Options record.

                                Instances For

                                  CLI spelling for a Float32 runtime mode.

                                  Instances For

                                    CLI arguments that reproduce a dtype choice.

                                    Instances For

                                      CLI arguments that reproduce a backend choice.

                                      Instances For

                                        CLI arguments that reproduce a device choice.

                                        Instances For

                                          Parse CLI runtime flags into persistent trainer run settings.

                                          Instances For

                                            Resolve runtime flags into a Trainer.RunConfig and reject unused trailing arguments.

                                            Instances For

                                              Lower this persistent run configuration to the standard runtime CLI flags.

                                              Instances For
                                                def TorchLean.Trainer.Config.fromRunConfig {σ τ : Shape} (run : RunConfig) (task : Task σ τ := Task.regression) (seed : := 0) :
                                                Config σ τ

                                                Build trainer options from an already parsed runtime configuration.

                                                Instances For

                                                  Build a run configuration from parsed runtime options.

                                                  Instances For

                                                    Run a callback under a runtime dtype that can also be read back to host Float tensors.

                                                    Trainer methods return ordinary Float predictions for display and downstream scripts, even when the model itself runs under an executable scalar such as IEEE32Exec. This dispatcher carries the extra scalar-readback evidence that DType.withRuntime intentionally does not require.

                                                    Instances For

                                                      Runtime configuration carried by this trainer.

                                                      Instances For

                                                        Runtime configuration carried by this trainer.

                                                        Instances For

                                                          Runtime configuration carried by this trainer.

                                                          Instances For

                                                            Per-training-call options for the trainer API.

                                                            • steps :

                                                              Number of optimizer updates.

                                                            • batchSize :

                                                              Number of dataset items included in one optimizer update.

                                                              For an ordinary sample dataset, each item is one example. A dataset made by Data.batchDataset already stores fixed-size tensor minibatches as its items; the usual vectorized path therefore keeps this option at 1. Values above one accumulate gradients from several such items before updating.

                                                            • Optional learning-rate schedule, indexed by completed optimizer updates.

                                                            • logEvery :

                                                              Print step losses every logEvery updates; 0 disables stdout step logging.

                                                            • cudaMemWatch :

                                                              Sample CUDA allocator state every this many completed updates; 0 disables sampling.

                                                            • Optional TrainLog artifact destination. Use .disabled for stdout-only runs.

                                                            • title : String

                                                              Title used when writing a TrainLog artifact.

                                                            • notes : Array String

                                                              Free-form notes attached to the TrainLog artifact.

                                                            • loadParams? : Option System.FilePath

                                                              Optional exact-bits parameter checkpoint loaded before training.

                                                            • saveParams? : Option System.FilePath

                                                              Optional exact-bits parameter checkpoint written after training.

                                                            Instances For

                                                              Start training options with a fixed number of optimizer steps.

                                                              Instances For

                                                                Override stdout step logging cadence.

                                                                Instances For

                                                                  Override the CUDA allocator sampling cadence.

                                                                  Instances For

                                                                    Override the requested minibatch size.

                                                                    Instances For

                                                                      Apply a learning-rate schedule during this training call.

                                                                      Instances For

                                                                        Run with the optimizer's fixed learning rate.

                                                                        Instances For

                                                                          Override the training-log destination.

                                                                          Instances For

                                                                            Disable TrainLog artifact writing for a training call that will write a richer custom artifact later.

                                                                            Instances For

                                                                              Override the training-log title.

                                                                              Instances For

                                                                                Override the training-log notes.

                                                                                Instances For

                                                                                  Load an exact-bits parameter checkpoint before training.

                                                                                  Instances For

                                                                                    Save an exact-bits parameter checkpoint after training.

                                                                                    Instances For

                                                                                      Lower the public training options to the manual runtime training config.

                                                                                      Instances For

                                                                                        A named classification input used for before/after prediction reporting.

                                                                                        Instances For

                                                                                          Convert a single-example class probe into the batched tensor probe used by trainer.train.

                                                                                          Instances For