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.
  • Work: A class representing the future of an asynchronous 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.

Examples

You can find the basic usage examples in the examples directory showing unidirectional and bidirectional communication patterns in Rust and Python.

Run unidirectional communication example:

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

Run bidirectional communication example:

# Rust
cargo run --example bidirectional
# Python
uv run 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.

For Python usage, you would use the node class as follows:

Tests

We include unit tests and integration tests for the Rust backend which can be run using cargo test. The integration tests for uni- and bidirectional communication are also ported to Python and can be run using uv run pytest.

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. pytests/test_unidirectional.py:

uv run pytest 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.0-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.0-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.0-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.0-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.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for prime_iroh-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8128bd0dd82f5a744fb5eec45ef3b73f418845b624116ae83885f5e302c76b11
MD5 6742ac014c2061eaf5a1a95d87a892a4
BLAKE2b-256 bb2eff271f94c52b3eef7290308ffabcf6e4ec513fc4812db64c3d12fb683c81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prime_iroh-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 85f75ba8e7e9b0030f9872a5bfa1d42ceb639613521db002bbd92e3dd48a3fcc
MD5 3a1e4cc78eae58980141d432bf9d0716
BLAKE2b-256 abb83883feec0aa68bf5d1871ddf5488a473830f8bc8a28702cb22d6cd70f88a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prime_iroh-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f01057924b52de654d4368f21c747651da9889564234aa9cafe3f03e129d82ef
MD5 0780be3b20ae92f46a85e02f51a9582c
BLAKE2b-256 39da9cd9e2095127c18c4205c3fc57f0d4f7fe61c2f9b27452f56bc7315fdfa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prime_iroh-0.2.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3e2911a30937c013007f757085248879acbd293dd8a8b96df8e57ef7e7041712
MD5 92a51b05a57322d96c0f91a7b6046f1d
BLAKE2b-256 064fae6badea22c7905db6c1147c875c452c9e289f8f13b7163c7e4c0b1cc478

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