Skip to main content

A hook for torch.distributed ProcessGroup primitives with timeout detection

Project description

Group Collective Communication Hook

A monitoring solution for PyTorch distributed training that hooks into all ProcessGroup collective communication primitives and performs timeout detection in pure Python using multiprocessing to avoid GIL limitations.

Overview

This package provides a robust monitoring mechanism for distributed PyTorch training by:

  • Hooking all ProcessGroup collective communication primitives
  • Implementing timeout detection using a separate process to avoid Python GIL constraints
  • Sending SIGUSR1 signal when timeout is detected
  • No C++ compilation required - pure Python implementation with multiprocessing

Quick Start

Build from Source

# Install the package (no build step needed - pure Python)
pip install .

# Run tests
torchrun --nproc_per_node=4 test_all_reduce.py 

# Test basic hook functionality
torchrun --nproc_per_node=4 test_hook_simple.py

Installation

Install the package using pip:

pip install .

Usage

Add the following code to your training script:

from run_daemon import run_daemon, stop_daemon

# Start the monitoring daemon
run_daemon()
 
############################# Your Training Code START #########################

############################# Your Training Code END ###########################

# Stop the monitoring daemon
stop_daemon()

Project Structure

├── work_monitor.py                                # Pure Python work monitoring and timeout detection
├── patch_all_collective_primi.py                  # Hooks for ProcessGroup primitives
├── run_daemon.py                                  # Daemon launcher script
├── setup.py                                       # Package setup configuration
├── test_all_reduce.py                             # AllReduce test script
├── test_hook_simple.py                            # Basic hook functionality test
├── README.md                                      # This file
└── doc/                                           # Documentation directory
    ├── DESIGN_ANALYSIS.md                         # Design analysis report
    ├── COMPATIBILITY.md                           # Version compatibility guide
    └── DEBUG_USAGE.md                             # Debug logging instructions

Documentation

Requirements

  • Python: >= 3.7, < 3.13
  • PyTorch: >= 1.8.0, < 3.0.0
  • CUDA: Required for GPU support (if using NCCL backend)
  • Operating System: Linux (or any OS supporting PyTorch distributed)

For detailed compatibility information, please refer to COMPATIBILITY.md.

Development

Running Tests

# Install development dependencies
pip install -r requirements-dev.txt

# Run unit tests
pytest tests/unit/

# Code quality checks
black --check .
flake8 .

Contributing

Contributions are welcome! Please feel free to submit Issues and Pull Requests.

Before submitting your code, please ensure:

  • All tests pass
  • Code follows the project style guidelines (Black, Flake8)
  • Documentation is updated if necessary

License

See LICENSE file for details.

Changelog

See CHANGELOG.md for version history and changes.

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

group_cc_hook-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

group_cc_hook-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file group_cc_hook-0.1.0.tar.gz.

File metadata

  • Download URL: group_cc_hook-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for group_cc_hook-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3c764049f434cb53f48a3e99bc15aee0d57626394311a2213806bd5bdf2fead
MD5 27ef24454c4188af12f2fc42dbc9b5f1
BLAKE2b-256 312ebfae5b53356635ff5712a0fff2e766e771c938da47c199f9bc3e2e74a446

See more details on using hashes here.

File details

Details for the file group_cc_hook-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: group_cc_hook-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for group_cc_hook-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 113584422e1fcc8c9263d018636019486c9161e632240f86393f6753b921752f
MD5 014044f5981c6a517f238c8bf11eea4c
BLAKE2b-256 d6b5a6878186fc208f9f01ea5fffba3a7f42fbe8519270af511f50e8d75d1404

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