torch-vault
Zero-copy PyTorch checkpoint management and SQL-driven dataset streaming built with Rust, PyO3, SQLite, and DuckDB.
Features
- Safe Checkpointing: Replaces pickle-based
torch.savewithsafetensorsmemory-mapping backed by an atomic SQLite WAL index. - Selective Weight Saving:
vault.save(model, metrics=..., save_if_better="val_loss")continuously records metric history into SQLite while writing.safetensorsweight files to disk only when metrics improve. - SQL Dataset Streaming:
Segment("data.parquet").where("quality > 0.8")runs DuckDB predicate pushdown on disk before streaming records into PyTorch DataLoaders. - Zero-Copy Memory Interchange: Uses the Arrow C Stream Interface (
__arrow_c_stream__PyCapsule) to pass record batches directly into memory. - CLI & WebApp Inspector: Includes
torch-vault listandtorch-vault uifor inspecting checkpoints and charting metrics in a local browser interface.
Installation
pip install torch-vault
For development build:
git clone https://github.com/ethqnol/torch-vault.git
cd torch-vault
pip install maturin
maturin develop --release
Quickstart
Checkpoint Management (Vault)
import torch
import torch.nn as nn
from torch_vault import Vault
model = nn.Linear(10, 2)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
vault = Vault("./checkpoints")
for epoch in range(1, 11):
train_loss = 0.5 # compute training loss
val_loss = 0.4 # compute validation loss
# Log metrics to SQLite; save weight file on disk only if val_loss improves
vault.save(
model=model,
optimizer=optimizer,
metrics={"train_loss": train_loss, "val_loss": val_loss},
epoch=epoch,
save_if_better="val_loss",
mode="min",
)
# Load best model weights automatically by metric
best_weights = vault.load(metric="val_loss", mode="min")
model.load_state_dict(best_weights["model"])
SQL Dataset Streaming & Train/Val/Test Split (Segment)
from torch_vault import Segment
from torch_vault.transforms import Compose, SelectKeys, RenameKey, StandardScaler
pipeline = Compose([
RenameKey(src="score", dst="quality"),
StandardScaler(keys=["quality"]),
SelectKeys("quality", "label"),
])
# Stream filtered Parquet data with a 80%/10%/10% split
train_loader, val_loader, test_loader = (
Segment("data/dataset.parquet")
.where("quality > 0.7 AND split = 'train'")
.transform(pipeline)
.to_dataloader(batch_size=32, split=(0.8, 0.1, 0.1), seed=42)
)
CLI & WebApp Inspector
# Print terminal ASCII table of logged checkpoints
torch-vault list ./checkpoints
# Launch browser WebApp inspector at http://127.0.0.1:8000/
torch-vault ui ./checkpoints --port 8000
Documentation
Full interactive API reference and architecture specifications are available at ethqnol.github.io/torch-vault.
License
MIT License.
Metadata
Release files for torch-vault 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torch_vault-0.2.0-cp310-abi3-manylinux_2_39_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.39+ x86-64 | Details |
Release files / torch_vault-0.2.0-cp310-abi3-manylinux_2_39_x86_64.whl
| Download URL | torch_vault-0.2.0-cp310-abi3-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 13.2 MB |
| Tags | CPython 3.10 Linux glibc 2.39+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f3d8638772514bd03b6e8f93403f5b525b7027447ec1518bf483938395ae801b
|
|
BLAKE2b-256 checksum How to use checksums |
ae7c7c417fe976ec9af6e29b72b72c797afeac1a01bacf6ec3239d21da0c8a0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for torch-vault 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.