Metadata-Version: 2.4
Name: ddpw
Version: 5.4.0
Summary: A lightweight wrapper that scaffolds PyTorch's (Distributed Data) Parallel.
Keywords: pytorch,distributed compute
Author: Sujal Vijayaraghavan
License-Expression: BSD-3-Clause
License-File: LICENCE
Classifier: Programming Language :: Python
Requires-Dist: submitit>=1.5.3
Requires-Dist: torch>=2.8.0
Maintainer: Sujal Vijayaraghavan
Requires-Python: >=3.13
Project-URL: Documentation, https://ddpw.projects.sujal.tv
Project-URL: Homepage, https://ddpw.projects.sujal.tv
Project-URL: Repository, https://github.com/sujaltv/ddpw
Description-Content-Type: text/markdown

<h1 align="center">DDPW</h1>

**Distributed Data Parallel Wrapper (DDPW)** is a lightweight Python wrapper
relevant for [PyTorch](https://pytorch.org/) users.

DDPW handles basic logistical tasks such as creating threads on GPUs/SLURM
nodes, setting up inter-process communication, _etc._, and provides simple,
default utility methods to move modules to devices and get dataset samplers,
allowing the user to focus on the main aspects of the task. It is written in
Python 3.13. The [documentation](https://ddpw.projects.sujal.tv) contains
details on how to use this package.

## Overview

### Installation

[![PyPI](https://img.shields.io/pypi/v/ddpw)](https://pypi.org/project/ddpw/)

```bash
uv add ddpw # with uv

pip install ddpw # with pip
```

### Examples

#### With the decorator `wrapper`

```python
from ddpw import Platform, wrapper

platform = Platform(device="gpu", n_cpus=32, ram=64, n_gpus=4, verbose=True)

@wrapper(platform)
def run(*args, **kwargs):
    # global and local ranks, and the process group in:
    # kwargs['global_rank'], # kwargs['local_rank'], kwargs['group']

    ...

if __name__ == '__main__':
    run(...)
```

#### As a callable

```python
from ddpw import Platform, Wrapper

# some task
def run(*args, **kwargs):
    # global and local ranks, and the process group in:
    # kwargs['global_rank'], # kwargs['local_rank'], kwargs['group']

# platform (e.g., 4 GPUs)
platform = Platform(device='gpu', n_gpus=4)

# wrapper
wrapper = Wrapper(platform=platform)

# start
wrapper.start(task, ('example',))
```

---

###### Status

[![Publish to PyPI](https://github.com/sujaltv/ddpw/actions/workflows/pypi_publish.yaml/badge.svg)](https://github.com/sujaltv/ddpw/actions/workflows/pypi_publish.yaml)
[![Publish documentation](https://github.com/sujaltv/ddpw/actions/workflows/s3_publish.yaml/badge.svg)](https://github.com/sujaltv/ddpw/actions/workflows/s3_publish.yaml)
