Decouple Torch Network-Aware Training on Interlinked Online Nodes (DeToNATION)
Project description
Decoupled Torch Network-Aware Training on Interlinked Online Nodes (DeToNATION)
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.
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
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
File details
Details for the file detonation-0.2.1.tar.gz.
File metadata
- Download URL: detonation-0.2.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b40096da2cdf734acd5a718c9cae8c138f5e02434d59ddedb4d8e039b283c99
|
|
| MD5 |
1bc391311daa8c2afc93f1ea6b493945
|
|
| BLAKE2b-256 |
751b41d3646d4f7afd955cc4df589dae478c93f63a867429acb4dc2a3bfb1fd8
|