Skip to main content

A library for persisting PyTorch program state

Project description

torchsnapshot

This library is currently in Alpha and currently does not have a stable release. The API may change and may not be backward compatible. If you have suggestions for improvements, please open a GitHub issue. We'd love to hear your feedback.

A light-weight library for adding fault tolerance to large-scale PyTorch distributed training workloads.

Install

Requires Python >= 3.7 and PyTorch >= 1.11

From pip:

pip install torchsnapshot

From source:

git clone https://github.com/facebookresearch/torchsnapshot
cd torchsnapshot
pip install -r requirements.txt
python setup.py install

Concepts

  • Stateful object - an object that whose state can be obtained via .state_dict() and restored via .load_state_dict(). Most PyTorch components (e.g. Module, Optimizer, LRScheduler) already implement this protocol.
  • App state - the application state described using multiple stateful objects.
  • Snapshot - the persisted app state.

Basic Usage

Describing the application state with multiple stateful objects:

app_state = {"model": model, "optimizer": optimizer}

Taking a snapshot of the application state:

from torchsnapshot import Snapshot

# File System
snapshot = Snapshot.take(path="/foo/bar/baz", app_state=app_state)

# S3
snapshot = Snapshot.take(path="s3://foo/bar", app_state=app_state)

# Google Cloud Storage
snapshot = Snapshot.take(path="gcs://foo/bar", app_state=app_state)

Referencing an existing snapshot:

snapshot = Snapshot(path="foo/bar/baz")

Restoring the application state from a snapshot:

snapshot.restore(app_state=app_state)

See the example directory for more examples.

License

torchsnapshot is BSD licensed, as found in the LICENSE file.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchsnapshot-nightly-2022.7.12.tar.gz (20.3 kB view details)

Uploaded Source

Built Distributions

torchsnapshot_nightly-2022.7.12-py3.7.egg (57.2 kB view details)

Uploaded Source

torchsnapshot_nightly-2022.7.12-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file torchsnapshot-nightly-2022.7.12.tar.gz.

File metadata

File hashes

Hashes for torchsnapshot-nightly-2022.7.12.tar.gz
Algorithm Hash digest
SHA256 b61dabd1dd3296aaadcbe532d81027318ebf0217cefa817af320e942db405d82
MD5 c78b4dc2877117e98f583ffd280651aa
BLAKE2b-256 a8497a14e3a07f57d335d2470cc44c59c19c6629a536a3b90febcddda85022e3

See more details on using hashes here.

Provenance

File details

Details for the file torchsnapshot_nightly-2022.7.12-py3.7.egg.

File metadata

File hashes

Hashes for torchsnapshot_nightly-2022.7.12-py3.7.egg
Algorithm Hash digest
SHA256 ad579c323c12bd0266c0758095af1df964b0684c55572035486dea012b8355f5
MD5 e50a0ab4e2fe898dbad98dc50e6bcbd0
BLAKE2b-256 c993b8dad23c2f0a01d93e35ad77748dea6277b92978de18a93fc7f5f6e62946

See more details on using hashes here.

Provenance

File details

Details for the file torchsnapshot_nightly-2022.7.12-py3-none-any.whl.

File metadata

File hashes

Hashes for torchsnapshot_nightly-2022.7.12-py3-none-any.whl
Algorithm Hash digest
SHA256 ce948615b2585af95154c811cccecc5b9a509983145d4615511e9f0f51ec68f3
MD5 e88d4e8448f08ac48ae5cee49b058e90
BLAKE2b-256 321dd5e823b6f097303e6e3784585d246d1ff2257033ec609b09f149ef88755c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page