silver-torch
Leakage-safe tensors and a real training loop with every important decision left visible.
An optional PyTorch layer for Silver. It turns a small Silver preprocessing
program into a fitted, inspectable, reusable tensor and DataLoader pipeline.
Every layer, explained
from silver_torch import inspect_model
# Use the loader created above (or any validation DataLoader).
sample, _ = next(iter(loader))
inspection = inspect_model(model, sample)
open("network.svg", "w", encoding="utf-8").write(inspection.to_svg())
The SVG is generated from the model itself: leaf-layer shapes, parameter counts, activation mean/variance/sparsity, and current gradient RMS. It works across CPU, CUDA, and MPS. Read the measurement details.
pip install silver-data
pip install 'silver-torch[pytorch]'
Train a real model
import torch
from torch.utils.data import DataLoader, TensorDataset
from silver_torch import (
SilverTrainer, TrainingConfig, build_tabular_model,
)
x = torch.tensor([[-2.0, -1.0], [-1.0, -2.0], [1.0, 1.0], [2.0, 1.0]])
y = torch.tensor([0, 0, 1, 1])
loader = DataLoader(TensorDataset(x, y), batch_size=4)
model = build_tabular_model(input_size=2, output_size=2)
trainer = SilverTrainer(model, TrainingConfig(
epochs=50,
learning_rate=0.01,
checkpoint_path=".silver/best.pt",
))
result = trainer.fit(loader, loader)
print(result.best_epoch, result.best_loss, result.parameter_count)
SilverTrainer includes deterministic seeds, CPU/CUDA/MPS selection, gradient
clipping, non-finite loss protection, early stopping, best-state restoration,
atomic checkpoints, evaluation, prediction, and event callbacks.
from silver_data import Dataset
from silver_torch import compile_silver
program = """
pipeline ieee_inverse:
features voltage, current, phase, sensor
categorical sensor
label fault
architecture transformer
sequence_length 2
scaling standard
missing median
label_type classification
batch_size 128
num_workers 2
cache_dir .cache/ieee_inverse
"""
dataset = Dataset.from_records("ieee", [
{"voltage": 1.0, "current": 2.0, "phase": 0.2, "sensor": "a", "fault": 0},
{"voltage": 1.2, "current": 2.1, "phase": 0.3, "sensor": "b", "fault": 1},
])
splits = dataset.split(0.5, 0.5, 0.0)
pipeline = compile_silver(program).fit(splits.train.records())
loader = pipeline.dataloader(splits.validation.records(), device="cuda")
print(pipeline.plan(device="cuda").to_dict())
print(pipeline.benchmark(splits.validation.records(), steps=20))
The compiler has explicit research-safety boundaries:
- statistics and vocabularies are fitted only on
splits.train; - missing columns, non-finite numbers, invalid labels, and incompatible sequence lengths fail loudly;
- categorical vocabularies are sorted for reproducibility and reserve index 0 for unknown values;
- classification targets are
torch.long; regression targets use the chosen floating dtype; - cache keys include the fitted-training fingerprint and transformed rows, and cache writes are atomic;
- loaders are seeded and tune pinning, persistent workers, prefetching, and
drop_lastbased on the declared runtime.
The emitted shapes are [batch, features] for MLP, [batch, 1, features] for
CNN, and [batch, sequence_length, features_per_step] for RNN/Transformer.
These are layout contracts, not model implementations. Measure with
benchmark() on the target machine; input speedups depend on storage, CPU,
worker count, batch size, and accelerator.
Decision-ready model visuals
inspect_model(model) captures real layer shapes, parameters, activation
statistics, sparsity, and gradient RMS, with a deterministic SVG for review.
Pass its layer records to silver-diagnostics.build_debug_plan to turn dead,
collapsed, vanishing, or exploding signals into targeted architecture or
optimization experiments and verify the effect on the next run.
Metadata
Release files for silver-torch 1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| silver_torch-1.5.1.tar.gz | 3.4 MB | With provenance | Details for silver_torch-1.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| silver_torch-1.5.1-py3-none-any.whl | Python 3 | none | any | Details for silver_torch-1.5.1-py3-none-any.whl |
Total release size: 3.4 MB
Release files / silver_torch-1.5.1.tar.gz
| Download URL | silver_torch-1.5.1.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5361ea24dedef89b42c38c7bc9aaff87f915b01b42dde4ef75f77068334abb16
|
|
BLAKE2b-256 checksum How to use checksums |
f13216a8219a0a195b2f13dbfe9fa8c8db6a5519021a5e07f29b4da219bf9de7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logRelease files / silver_torch-1.5.1-py3-none-any.whl
| Download URL | silver_torch-1.5.1-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1b6efde7550ecde80e162bd980ca07e3c5b649327433ae689138f92d1c86efd
|
|
BLAKE2b-256 checksum How to use checksums |
149688bf6b0e7b2d201652e13b8d1f5e1e82760a109ff79719635e241992872f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logSecurity for silver-torch 1.5.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for silver_torch-1.5.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logA 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.