loom
loom runs offline PyTorch model loops: train, evaluate, predict and offline batch inference. It is not for serving models.
Install
pip install loom-torch
The package imports as loom.
Quickstart
From a clone of this repo:
uv sync
uv run pytest
./examples/regressor.py # smallest example; delete runs/regressor before re-running
./examples/mlp_classifier.py # adds periodic checkpoints; delete runs/mlp_classifier before re-running
Usage
Subclass Task for the model and its step logic. Subclass DataFeed for the data pipelines. Runner owns the loops.
A Task is an nn.Module that implements train_step (returns the loss) and build_optimizer. It adds eval_step
(returns a dict of metrics), predict_step and build_scheduler when it needs them. A DataFeed returns pipelines from
train_pipeline, eval_pipeline and predict_pipeline, usually built with build_pipeline(dataset, batch_size=...).
examples/regressor.py shows all of it in about 70 lines.
RunConfig holds every run setting: the stop condition (max_epochs or max_steps), device, checkpoint_dir, plus
grad_accum_steps, max_grad_norm, precision="bf16", checkpoint_every_n_steps and eval_every_n_steps.
To resume a run, set resume_from="latest" or a checkpoint path in RunConfig. To protect earlier results, a fit that
does not resume raises FileExistsError when checkpoint_dir already holds step-*.pt files. predict raises
FileExistsError when output_dir is non-empty.
Layout
src/loom/
task.py # Task base class
data.py # DataFeed and build_pipeline (torchdata.nodes)
checkpoint.py # checkpoint save and resume
runner.py # RunConfig and Runner: fit, evaluate, predict
examples/
regressor.py # smallest end-to-end example
mlp_classifier.py # MLP classifier with periodic checkpoints
tests/
Reading predictions back
import json
from pathlib import Path
import torch
d = Path("runs/regressor/predictions")
m = json.loads((d / "manifest.json").read_text())
outs = [o for s in m["shards"] for o in torch.load(d / s)]
MIT. See LICENSE.
Metadata
Release files for loom-torch 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| loom_torch-0.1.0.tar.gz | 10.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| loom_torch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / loom_torch-0.1.0.tar.gz
| Download URL | loom_torch-0.1.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a26263a161557bcd80a6cd0688dd4ec269a72c7eeac4f28ff5e9656c6538e85e
|
|
BLAKE2b-256 checksum How to use checksums |
dead502e4af428503ea8b13dcb075de09aa34066c2817d0c49c96c822e250d9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CentOS Stream","version":"9","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / loom_torch-0.1.0-py3-none-any.whl
| Download URL | loom_torch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43a27df8681a0711d113356dbe45e3768b8f6cb96647e243fbba44cb530898de
|
|
BLAKE2b-256 checksum How to use checksums |
df1808fc9a1b71439905a699580b8981223304f9224f22d63c0b626784eb926c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CentOS Stream","version":"9","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|