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


Download files

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

Source Distribution

torchsnapshot-0.0.3.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

torchsnapshot-0.0.3-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file torchsnapshot-0.0.3.tar.gz.

File metadata

  • Download URL: torchsnapshot-0.0.3.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for torchsnapshot-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1d59c169b619a36822682f5b410f0e62e1f6a178b7b684abd075edfe3162cd6c
MD5 0dc4ffd4b3f0bdc43b5bbc77089bbe2a
BLAKE2b-256 7b7417b5d03210ccd3ed1a615abf483487e30eae379195fdb671bf6fac0fbc4d

See more details on using hashes here.

Provenance

File details

Details for the file torchsnapshot-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for torchsnapshot-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c8f752a56c4467230c8b39f320ce5cd595820e7e2e1ee1eaae145c4e924dc08e
MD5 873bfb1b76d1bcf7390423991019cc0e
BLAKE2b-256 477c6eee0a27bc7e235139be147f6f3501060e8861afdf57d2723cc3260ec3ec

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