Skip to main content

TorchDrift: drift detection for PyTorch

TorchDrift is a data and concept drift library for PyTorch. It lets you monitor your PyTorch models to see if they operate within spec.

We focus on practical application and strive to seamlessly integrate with PyTorch.

Installation

To install the latest release version use

pip install torchdrift

To get the latest and greatest install from git with

pip install git+https://github.com/torchdrift/torchdrift/

Documentation

Our documentation is at TorchDrift.org.

Examples

Check out our worked example with an ImageNet-type classifier.

If you have a model (without head) as the feature extractor and a training dataloader you can fit the reference distribution as

drift_detector = torchdrift.detectors.KernelMMDDriftDetector()
torchdrift.utils.fit(train_dataloader, feature_extractor, drift_detector)

and then check drifts with

features = feature_extractor(inputs)
score = drift_detector(features)
p_val = drift_detector.compute_p_value(features)

if p_val < 0.01:
    raise RuntimeError("Drifted Inputs")

Also check out our deployment example for integration of TorchDrift into inference with a model.

Authors

TorchDrift is a joint project of Orobix Srl, Bergamo, Italy and MathInf GmbH, Garching b. München, Germany.

The TorchDrift Team: Thomas Viehmann, Luca Antiga, Daniele Cortinovis, Lisa Lozza

Acknowledgements

We were inspired by

Release files for torchdrift 0.1.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for torchdrift 0.1.0.post1
File Interpreter ABI Platform
torchdrift-0.1.0.post1-py3-none-any.whl Python 3 none any Details

Release files / torchdrift-0.1.0.post1-py3-none-any.whl

Download URL torchdrift-0.1.0.post1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a211e9d9572432a12eb57d4c0dc099e8c6309c48718cc4256cc445b338ddb57d
BLAKE2b-256 checksum
How to use checksums
07c4ec78a41ad83bcff8b47982f87d7a651fe86aca4c8cff14a2a8eac2465f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1+

Release history Release notifications | RSS feed

This release

0.1.0.post1 This release

1 release file

0.1.0

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page