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.6.13.tar.gz (21.2 kB view details)

Uploaded Source

Built Distributions

torchsnapshot_nightly-2022.6.13-py3.9.egg (57.4 kB view details)

Uploaded Source

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for torchsnapshot-nightly-2022.6.13.tar.gz
Algorithm Hash digest
SHA256 fe72bf240d2ff0e2b250679276264ca027a1cf63c2f195dd6d2bf13003f4d3df
MD5 cf4a36432cc92ad2d8ab16fdbbca2563
BLAKE2b-256 346b2da6e49eac06b717a02227ac38989fc575eb7d3ceb80791edee5d8264b03

See more details on using hashes here.

File details

Details for the file torchsnapshot_nightly-2022.6.13-py3.9.egg.

File metadata

File hashes

Hashes for torchsnapshot_nightly-2022.6.13-py3.9.egg
Algorithm Hash digest
SHA256 74df0d97855606c20093838fa3f6927bb06346eb9d5c71203803873768733175
MD5 0d122f5ac68c0be3fad62717f27d3027
BLAKE2b-256 8f1a7cdf92b6f06c87514e4b0463f2770f07b81cd294725917208068c99182a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torchsnapshot_nightly-2022.6.13-py3-none-any.whl
Algorithm Hash digest
SHA256 5d38ab3d94edce5d04731647f05302f28e44f64ed3bf933db05ef14243211e43
MD5 19cbe6bbc28e7bf8402cd60cc3942521
BLAKE2b-256 28fde3c091968569a635b551f148db18709d64fb5e71188978a1d2f2cf779ae1

See more details on using hashes here.

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