TorchLean Model-Zoo Facade #
Shared flags, logs, banners, paths, and runtime operations for built-in model-zoo examples.
Shared CLI and logging definitions for the built-in model-zoo examples.
These are public because examples should read like TorchLean programs. They stay under ModelZoo;
ordinary library users should prefer Trainer, Data, and optim directly.
Training flags shared by runnable model examples.
This covers the knobs almost every example needs: --steps, --log, CUDA memory watching, and
--lr. Model files should reuse this record and add only flags that change that model's actual
behavior, such as text generation settings or evaluation probes.
Instances For
Model-training flags plus an RNG/data-order seed.
Use this when the command needs reproducible initialization, synthetic data, or shuffled row order in addition to the standard training flags.
Instances For
Common CLI result for training commands that accept --steps, --batch-size, and --log.
Instances For
Common arguments for a model command that reads one supervised CSV.
Instances For
Shared corpus-window or training-window count used by finite cyclic examples.
Instances For
Parse the shared --windows flag.
The model decides how to use the windows; this helper just keeps the flag spelling and positivity check consistent.
Instances For
Optional parameter-checkpoint load/save paths shared by runnable model commands.
Instances For
Parse the shared --load-params / --save-params flags.
Instances For
Diffusion schedule knobs shared by model-zoo diffusion commands.
Instances For
Parse shared diffusion schedule flags: --T, --beta-start, and --beta-end.
Instances For
Standard TrainLog metadata for a diffusion schedule.
Instances For
Optional image artifacts emitted by image-generation or reconstruction commands.
Instances For
Parse shared image artifact flags for generation/reconstruction commands.
This only parses artifact paths and the optional reconstruction timestep. The model still decides which images it can write.
Instances For
Standard TrainLog metadata for requested image artifacts.
Instances For
Common paired-NPY dataset flags for scientific supervised examples.
This shape is for commands that train on one (x,y) tensor pair and evaluate/report on a held-out
pair. The model file supplies the tensor shapes and file defaults.
Instances For
Parse common train/test paired-NPY flags.
Commands supply their default paths and row counts. This parser keeps the repeated
--train-rows, --test-rows, --eval-rows, --x, --y, --test-x, and --test-y flags in one
place.
Instances For
Standard TrainLog metadata for paired train/test NPY tensors.
Instances For
Optional CSV artifact path for commands that emit one tabular diagnostic.
Instances For
Parse the shared optional --plot-csv artifact path.
Instances For
Generic NPY-backed labeled dataset flags.
Examples provide default paths and data-preparation hints. The repeated flags are --seed,
--n-total, --x, and --y.
Instances For
Parse the standard --seed, --n-total, --x, and --y flags for NPY-backed datasets.
Examples provide dataset-specific defaults; this parser keeps the repeated NPY dataset flags consistent.
Instances For
Standard TrainLog metadata for an NPY-backed dataset branch.
Instances For
Built-in image dataset branches shared by image-model commands.
Instances For
Parse --dataset, --cifar10, and --imagenet64, rejecting ambiguous selectors.
Instances For
Common arguments for a fixed-sample command backed by supervised .npy arrays.
Instances For
Parse a supervised NPY dataset, logged training flags, and require that no command-specific arguments remain.
Dataset-specific commands provide parseData, which owns defaults such as CIFAR or ImageNet paths;
this helper keeps the reusable "NPY data + logged TrainLog" path in one place.
Instances For
Common arguments for a model-training command backed by supervised .npy arrays.
Instances For
Parse a supervised NPY dataset and standard model-training flags.
The remaining arguments are returned so callers can still pass runtime/backend flags through a higher-level runner.
Instances For
Shared forecasting-window data flags: paths, window count, report offset, and seed.
Instances For
Standard TrainLog metadata for forecasting-window datasets.
Instances For
Common arguments for forecasting-window model-training commands.
Instances For
Parse forecasting-window data flags plus standard model-training flags.
The data parser comes from the caller because file defaults often depend on a dataset directory or a preparation script.
Instances For
Standard location for model-example training logs under data/model_zoo.
Instances For
Resolve an optional natural-number CLI flag against a default and require that the result is strictly positive.
Example parsers use this helper for the common "optional flag + default + positivity check"
case instead of restating the same getD / requirePositiveNatFlag sequence.
Instances For
Run an executable on the concrete Float runtime path.
We use this for runnable training commands that produce Float-valued artifacts: CPU/CUDA eager
execution, native kernels, and JSON loss curves. Commands that need to expose another scalar backend
can use runAnyOrFloat.
Instances For
Run an executable with the standard TorchLean runtime parser, using the polymorphic scalar path by
default and switching to the Float path when requested.
This is the common shape for public examples that support all executable scalar backends, but need
the Float path for CUDA bridges, decoded reports, or JSON artifacts whose metrics are stored as
Float.
Instances For
Run an executable on either the selected scalar backend or the concrete Float path when the
generic branch does not need an explicit Float → α cast helper.
Instances For
Detect --backend compiled in either --backend=compiled or split-flag form.
Instances For
Reject --cpu and add CUDA/runtime flags expected by GPU-first commands.
This helper only rewrites command-line intent before the standard runtime parser runs. It does not change the lower-level runtime semantics.
Instances For
Run a Float-only command after normalizing its runtime flags.
GPU-first examples use this to keep the public Runtime.runFloat path while inserting required
CUDA/eager flags before the standard parser runs.
Instances For
Run a Float-only command after forcing CUDA runtime flags.
Instances For
Run a Float-only command after forcing CUDA eager-runtime flags.
Instances For
Runtime device label used by public example banners and notes.
Instances For
Standard device=... note string used by public example logs.
Instances For
Standard model-zoo banner shape: executable name, short description, and selected device.
Standard two-line model-zoo banner: headline plus one indented detail/note line, both carrying the selected device on the headline.
Choose a CUDA memory-watch cadence for public examples.
Users can pass --cuda-mem-watch N to choose an exact cadence. When no cadence is supplied, long
CUDA runs sample about ten times over the requested training horizon. Short runs and CPU runs stay
quiet by default, so the examples do not print allocator telemetry unless it is likely to be useful.
Instances For
Standard TrainLog note for the effective CUDA memory-watch cadence.
Instances For
Maybe print a one-line CUDA allocator report.
The report samples the native allocator at a fixed cadence and warns if the observed free-memory slope would cross zero before the requested training horizon.
Instances For
Return whether a completed training step should emit a progress report.
The convention is shared across example trainers: logEvery = 0 disables progress output; otherwise
we log at exact multiples of the completed-step count.
Instances For
Write a standard JSON training artifact for routines that record an initial and final loss.
The function uses Runtime.Training.TrainLog.beforeAfterLoss and the stable TrainLog JSON format.
The output schema is independent of the model, dataset, and runtime backend.
Instances For
Write a before/after loss log to an explicit logging destination.
LogDestination.disabled is a no-op, mirroring wandb disabled for runs where metrics should stay
on stdout only.
Instances For
Write a one-series scalar curve to an explicit logging destination.
Instances For
Write a single-curve training log with an explicit series color.
Use this when a command already owns a Training.Curve and wants the richer
TrainLog artifact shape rather than the default "loss" curve writer.
Instances For
Write a multi-series metric history as a TrainLog artifact.
Use this when a command accumulates a Training.MetricHistory with explicit
series names/colors and then want to publish the richer TrainLog form without rebuilding the
same toTrainLog + writeTrainLog boundary in every example file.
Instances For
Write a prepared TrainLog JSON artifact and report the file path.
Instances For
Write a prepared TrainLog to a destination that may be disabled.
Instances For
Print the standard first/last loss summary for a scalar training curve.
Instances For
Fixed-sample run specialized to Float, returning a full per-step curve.