Skip to main content

Asynchronous P2P communication backend for decentralized pipeline parallelism, built on top of Iroh

Project description

Prime Intellect

PRIME-IROH: P2P Pipeline Parallel Communication


This library exposes a Python interface for reliable, asynchronous peer-to-peer communication built upon Iroh. The core classes exposed are:

  • Node: A class combining a single-peer sender/ receiver in one class, allowing to send to exactly one and receive from exactly one (potentially different) peer. The class allows for concurrent communication by opening multiple, consistent streams.
  • SendWork: A class representing the future of an asynchronous send operation, that can be awaited using a wait method.
  • RecvWork: A class representing the future of an asynchronous receive operation, that can be awaited using a wait method.

Because we are building on top of Iroh, we get many nice networking features out of the box. Most importantly, the library guarantees reliable P2P connections between nodes, trying to establish directions connections whenever possible, and falling back to NAT-hole punching and relaying when necessary. The API is mirroring the way asynchronous communication is handled in torch.distributed, i.e. exposing isend and irecv that return work objects that can be awaited using a wait method. This allows for a clean integration with the rest of the PyTorch ecosystem.

Installation

Quick Install: Run the following command for a quick install:

curl -sSL https://raw.githubusercontent.com/PrimeIntellect-ai/prime-iroh/refs/heads/master/script/install.sh | bash

Manual Install: First, install uv and cargo to build the project.

curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

Then, clone the repository

git clone git@github.com:PrimeIntellect-ai/prime-iroh.git && cd prime-iroh

To build the Rust backend run cargo build, to build the Python bindings run uv sync. This will let you install prime-iroh as a Python package within the virtual environment.

uv run python -c "import prime_iroh"

Examples

You can find the basic usage examples in the rust/examples and python/examples directories showing unidirectional and bidirectional communication patterns in Rust and Python.

Run unidirectional communication example:

# Rust
cargo run --example unidirectional
# Python
uv run python python/examples/unidirectional.py

Run bidirectional communication example:

# Rust
cargo run --example bidirectional
# Python
uv run python python/examples/bidirectional.py

You can set the log level by setting the RUST_LOG environment variable. For example, to see info logs from the prime-iroh crate, set RUST_LOG=prime_iroh=info.

Tests

We include unit tests and integration tests for Rust and Python.

Rust Tests

Run full test suite (unit and integration tests):

cargo test

Note: To run the tests with verbose output, use cargo test -- --nocapture.

Run single unit test, e.g. tests in src/node.rs (this will pattern match the test function names):

cargo test node

Run single integration test, e.g. tests/connection.rs:

cargo test --test connection

Python Tests

Run full test suite (only integration tests are available for now):

uv run pytest

To run the tests with verbose output, use uv run pytest -s.

Run single test, e.g. python/tests/test_unidirectional.py:

uv run pytest python/tests/test_unidirectional.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

prime_iroh-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

prime_iroh-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

prime_iroh-0.2.1-cp311-cp311-manylinux_2_34_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

prime_iroh-0.2.1-cp310-cp310-manylinux_2_34_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file prime_iroh-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for prime_iroh-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9031fb374ff5e91b4c1aabbafc54787330b655f546297f713486b1dfc801452e
MD5 dd6f43810b036f27e509d5a3dbf02e8f
BLAKE2b-256 dd3c66830a23246c7474eac43db73e69173ef86c9d1209ae2855ddf9a30b42e2

See more details on using hashes here.

File details

Details for the file prime_iroh-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for prime_iroh-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 44875f41340962aea25df4c5f79e28cb41a4e4d181e2f8ee62fd0fa5644d2e3c
MD5 377949d457ed79d0af3c5417aec92e36
BLAKE2b-256 e181c959b1811df62fc5d0c3effc272907398bc6ff5179e0d32bae764976f0e7

See more details on using hashes here.

File details

Details for the file prime_iroh-0.2.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for prime_iroh-0.2.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 66021e629b0396ef705b18a281d52b9dc0c765276e4b73ed2c234eab9b425d5f
MD5 855ab29b6f3d7e6ac57e9f1546610a1c
BLAKE2b-256 c2fbe79863fc4e3d487d62dc2fb3bbe640ec4349aa4e437a2f5e13119766cad7

See more details on using hashes here.

File details

Details for the file prime_iroh-0.2.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for prime_iroh-0.2.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 658d7dccd81cd63e1499b38b8716f29e6d4c86ac74fca145710dce0bbab82da6
MD5 33894261abbffa1c41e5e49296aa4d45
BLAKE2b-256 1410016b89903095480a1ea1576be71f978331cf34d66fe756077b870d758f16

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