Skip to main content

Decouple Torch Network-Aware Training on Interlinked Online Nodes (DeToNATION)

Project description

Decoupled Torch Network-Aware Training on Interlinked Online Nodes (DeToNATION)

This code currently implements the results described in FlexDeMo: Decoupled Momentum Optimization for Fully and Hybrid Sharded Training. An implementation to run all experiments from the paper is found in the benchmarks folder.

Installation

Installation from PyPI:

pip install detonation

Installation from source:

git clone https://github.com/schneiderkamplab/DeToNATION
cd DeToNATION
pip install .

Example

There is a a full example for language model training using FlexDeMo in the example folder. Please refer to the documentation:

examples/t5/README.md

This example demonstrates the use of the prepare_detonation function for obtaining a distributed model and optimizer.

Benchmarks

There is a a full benchmarking example for language model training using FlexDeMo in the benchmarks folder. Please refer to the documentation:

benchmarks/t5/README.md

This benchmarking example demonstrates the use of the prepare_detonation function for obtaining a distributed model and optimizer, and uses aim and mltiming to track model parameters and performance.

Usage

The direct usage of DeToNATION without using prepare_detonation requires three elements as exemplified below for the FlexDeMo optimizer, i.e., DeToNATION with node-based hybrid sharding using DeMo replication.

First, you need to wrap your model with FSDP and the hybrid sharding strategy:

from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
model = FSDP(
    model,
    sharding_strategy=ShardingStrategy.HYBRID_SHARD,
)

Then, you can import and instantiate the FlexDeMo optimizer:

from detonation import DeMo
optim = DeMo(
    compression_topk=16,
    compression_chunk=128,
    sharding_parallel_group=model.process_group,
    replication_parallel_group=model._inter_node_pg,
)

Third and last, you need to wrap the forward and backward pass using a no_sync context manager to avoid automatic full gradient synchronization:

    with model.no_sync(): # Disable gradient synchronizations across FSDP instances.
        loss = model(input_ids=batch["input_ids"],labels=batch["labels"])["loss"]
        loss.backward()

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

detonation-0.4.0b0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

detonation-0.4.0b0-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file detonation-0.4.0b0.tar.gz.

File metadata

  • Download URL: detonation-0.4.0b0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for detonation-0.4.0b0.tar.gz
Algorithm Hash digest
SHA256 ba083f121b705e852e7b7aa0062588ac56227362693774f0799b718fa40a00cf
MD5 a760a172c17891bf301b73bf3be3a453
BLAKE2b-256 bbdc9d80be193db1ba79e724cb5bb3c9417aeabbefebfbb51cbf3aec26787660

See more details on using hashes here.

File details

Details for the file detonation-0.4.0b0-py3-none-any.whl.

File metadata

  • Download URL: detonation-0.4.0b0-py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for detonation-0.4.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 c42df1df7f1bfaf238a557477ce73b4065529601adba895d23536e24e5fbe244
MD5 38fe0719ac8cb7211ec606899bd28a5b
BLAKE2b-256 4b98d89bf710e112fa83804e2d72ad82931b2347a7c112274a6e97db50bdb395

See more details on using hashes here.

Supported by

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