Skip to main content

pygloo

Pygloo provides Python bindings for gloo. It is implemented using pybind11.

It is currenlty used in Ray for collective communication between CPUs.

Requirements

Python >= 3.6

Installation

Install From Wheels

We provide prepackaged Python wheels (manylinux2014_x86_64,manylinux_2_24_x86_64). To install from wheels:

pip install pygloo

Building from source

One can build pygloo from source if none of released wheels fit with the development environment.

Pygloo uses Bazel to automatically manange dependencies and compilation. To compile from source, install Bazel>=2.0.0 following the Bazel installation guide. After installing Bazel, build and install pygloo following this command:

python setup.py install

Testing

Pygloo uses Ray to create multiple, distributed processes for collective communication tests. See tests directory.

Example

An example for allreduce.

import os
import ray
import pygloo
import numpy as np

@ray.remote(num_cpus=1)
def test_allreduce(rank, world_size, fileStore_path):
    '''
    rank  # Rank of this process within list of participating processes
    world_size  # Number of participating processes
    fileStore_path # The path to create filestore
    '''
    context = pygloo.rendezvous.Context(rank, world_size)
    # Prepare device and store for rendezvous
    attr = pygloo.transport.tcp.attr("localhost")
    dev = pygloo.transport.tcp.CreateDevice(attr)
    fileStore = pygloo.rendezvous.FileStore(fileStore_path)
    store = pygloo.rendezvous.PrefixStore(str(world_size), fileStore)

    context.connectFullMesh(store, dev)

    sendbuf = np.array([[1,2,3],[1,2,3]], dtype=np.float32)
    recvbuf = np.zeros_like(sendbuf, dtype=np.float32)
    sendptr = sendbuf.ctypes.data
    recvptr = recvbuf.ctypes.data

    pygloo.allreduce(context, sendptr, recvptr,
                    sendbuf.size, pygloo.glooDataType_t.glooFloat32,
                    pygloo.ReduceOp.SUM, pygloo.allreduceAlgorithm.RING)

if __name__ == "__main__":
    ray.init(num_cpus=6)
    world_size = 2
    fileStore_path = f"{ray.worker._global_node.get_session_dir_path()}" + "/collective/gloo/rendezvous"
    os.makedirs(fileStore_path)
    ray.get([test_allreduce.remote(rank, world_size, fileStore_path) for rank in range(world_size)])

License

Gloo is licensed under the Apache License, Version 2.0.

Release files for pygloo-rec 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygloo-rec 0.2.0
File Size Uploaded
pygloo-rec-0.2.0.tar.gz 24.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygloo-rec 0.2.0
File Interpreter ABI Platform
pygloo_rec-0.2.0-cp38-cp38-macosx_13_0_x86_64.whl CPython 3.8 CPython 3.8 macOS 13.0+ x86-64 Details

Total release size: 725.6 kB

Release files / pygloo-rec-0.2.0.tar.gz

Download URL pygloo-rec-0.2.0.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0ce17060ce419564df597df855b429e6753605f0280585fd6d0882e28a80a817
BLAKE2b-256 checksum
How to use checksums
f47c332bd0604e27fb86bf5bd08c8b6c1264b2b42af7621b8afc5930e05e9109
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.8

Release files / pygloo_rec-0.2.0-cp38-cp38-macosx_13_0_x86_64.whl

Download URL pygloo_rec-0.2.0-cp38-cp38-macosx_13_0_x86_64.whl
Size 701.4 kB
Tags CPython 3.8 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
9146d0c56c34f2ed020dcb31f2c0749986a4ee704ce43c9f5ce6a6cd6c1b85eb
BLAKE2b-256 checksum
How to use checksums
d68c4a2c24eb12a1abf67d20db3a2c8cdd3a76144f743a9a4276aef7d3cf05ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.8

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page