This page is for people extending or contributing to Tensorless PyTorch, not end users.
tensorless/
├── __init__.py public API surface: train, run, load, inspect
├── api.py orchestration for train()/run(): Smart Auto Check + wiring
├── config.py TrainConfig (user-facing) / ResolvedConfig (fully resolved)
├── errors.py exception hierarchy
├── runtime.py LoadedModel: rebuilds a model from a .tl payload for inference
├── _version.py package + .tl format version numbers
├── data/
│ ├── loader.py path -> Dataset (txt/json/jsonl/csv/dirs)
│ ├── fingerprint.py content-based dataset hashing
│ ├── inspector.py tl.inspect() report generation
│ └── tabular.py TabularPreprocessor: numeric/categorical encoding
├── auto/
│ ├── detector.py Dataset -> task string
│ └── config.py Dataset + TrainConfig -> ResolvedConfig
├── tokenization/
│ ├── char_tokenizer.py CharTokenizer: vocab build/encode/decode/save/load
│ └── bpe_tokenizer.py BPETokenizer: corpus-trained subword encoding
├── models/
│ ├── transformer.py TinyTransformer (GPT-style decoder)
│ ├── mlp.py TabularMLP
│ └── registry.py build_model(task, model_type, cfg, meta)
├── training/
│ ├── data_prep.py Dataset -> DataLoaders per task
│ ├── trainer.py the training loop (run_training)
│ └── early_stopping.py EarlyStopping
├── checkpoint/
│ └── manager.py CheckpointManager: atomic save/load/clear
├── serialization/
│ └── tl_format.py save_tl/load_tl: the .tl file format
├── devices/
│ └── device.py hardware auto-detection + torch.device resolution
└── cli/
└── main.py argparse-based CLI
path
│
▼
data.loader.load_dataset(path) -> Dataset (kind, texts/records, columns)
│
▼
auto.detector.detect_task(ds) -> "text-generation" | "text-classification"
│ | "classification" | "regression"
▼
auto.config.resolve_config(ds, TrainConfig) -> ResolvedConfig (every field concrete)
│
▼
training.data_prep.prepare_*(ds, cfg) -> PreparedData (train/val DataLoaders,
│ meta, tokenizer/preprocessor)
▼
models.registry.build_model(task, model_type, cfg, meta) -> nn.Module
│
▼
training.trainer.run_training(...) -> trains, checkpoints periodically,
│ returns final weights + metrics
▼
serialization.tl_format.save_tl(out, payload) -> model.tl
│
▼
runtime.LoadedModel(payload) -> returned to the caller
api.train() wraps this whole flow with the Smart Auto Check (see
automatic_mode.md): before any of the above runs,
it checks for an existing complete .tl file or a resumable checkpoint
matching the dataset's fingerprint.
- Every automatic decision is explainable. Auto-detection and
auto-configuration are simple, inspectable heuristics (see
auto/detector.py,auto/config.py), not opaque search or ML-driven meta-learning. Anyone reading the code can predict what Tensorless PyTorch will choose for a given dataset. - Never silently touch user data.
data/loader.pyonly reads; nothing in the training path writes to or deletes files under the dataset path. - Fail with actionable errors. All user-facing errors are
TensorlessErrorsubclasses with messages that say what's wrong and usually what to do about it (seeerrors.pyand troubleshooting.md). - Checkpoints are self-describing. A checkpoint carries its own config, meta, and dataset fingerprint, so resuming never depends on external state being reconstructed correctly by the caller.
- A
.tlfile is the unit of portability. Nothing about inference should require the original dataset, training script, or checkpoint directory to still exist.
- Implement your
nn.Moduleinmodels/your_model.py. - Register it in
models/registry.py'sbuild_model(). - Add a branch in
training/trainer.py's_compute_loss()for how to compute loss for your task/model_type combination. - If it needs new data prep, add a
prepare_*()function intraining/data_prep.py. - If it changes what needs to go in the
.tlfile, extend themetadict produced by data prep —build_model()receives it and can pull out whatever fields it needs.
Add a branch to data/loader.py's load_dataset() / _load_directory()
for the new extension, producing a Dataset with the appropriate kind.
Extend devices/device.py's _*_available() checks and
auto_select_device() / get_torch_device().
See contributing.md for the contribution process itself (tests, PRs, etc).