Skip to main content

Starway UCX P2P communication lib.

Project description

Starway

Starway is an ultra-fast communication library that wraps OpenUCX to deliver lock-free, asynchronous, zero-copy messaging for Python applications.

Highlights

  • Zero-copy transfers into preallocated NumPy buffers.
  • Full-duplex messaging with independent async send/recv APIs.
  • Choice of connection style: traditional TCP socket address or direct UCX worker-address handshakes (no TCP listener required).
  • Flush primitives (aflush, aflush_ep) to force completion ordering when you need delivery guarantees.
  • Built-in performance probes via evaluate_perf for quick transport telemetry.

Installation

Starway depends on dynamic OpenUCX libraries:

  1. Install OpenUCX system-wide (for example via your distro's package manager or an HPC toolchain), or
  2. Install the libucx-cu12 wheel, which ships redistributable shared objects.

Starway does not hard-depend on libucx-cu12; it is treated as an optional fallback.

You can use environment variable to control System/Wheel preference:

import os

# Defaults to "true". Set to "false" to prefer the wheel first.
os.environ["STARWAY_USE_SYSTEM_UCX"] = "false"

import starway  # falls back to system UCX if the wheel is unavailable

Quick Start

Socket-address workflow

import asyncio
import numpy as np
from starway import Client, Server

SERVER_ADDR, SERVER_PORT = "127.0.0.1", 19198


async def main():
    server = Server()
    client = Client()

    server.listen(SERVER_ADDR, SERVER_PORT)
    await client.aconnect(SERVER_ADDR, SERVER_PORT)

    # Establish endpoint object on the server side
    client_ep = next(iter(server.list_clients()))

    send_buf = np.arange(4, dtype=np.uint8)
    recv_buf = np.zeros_like(send_buf)

    recv_task = server.arecv(recv_buf, tag=1, tag_mask=0xFFFF)
    await client.asend(send_buf, tag=1)
    await recv_task

    await asyncio.gather(client.aflush(), server.aflush_ep(client_ep))
    await asyncio.gather(client.aclose(), server.aclose())


asyncio.run(main())

Worker-address workflow

import asyncio
import numpy as np
from starway import Client, Server


async def main():
    server = Server()
    worker_address = server.listen_address()  # bytes blob, no TCP listener

    client = Client()
    await client.aconnect_address(worker_address)

    # Accept callback still fires; poll list_clients() to obtain the peer ep
    for _ in range(100):
        clients = server.list_clients()
        if clients:
            client_ep = next(iter(clients))
            break
        await asyncio.sleep(0.01)

    recv_buf = np.zeros(4, dtype=np.uint8)
    recv_task = server.arecv(recv_buf, tag=2, tag_mask=0xFFFF)
    await client.asend(np.arange(4, dtype=np.uint8), tag=2)
    await recv_task

    await asyncio.gather(client.aclose(), server.aclose())


asyncio.run(main())

API Cheatsheet

Server

  • listen(addr, port) – create a TCP-backed listener.
  • listen_address() – start worker-only mode and return the local UCX worker address for out-of-band distribution.
  • set_accept_cb(callback) – invoked for each new endpoint (both listener and worker-address flows).
  • list_clients() – inspect active UCX endpoints.
  • asend(client_ep, buffer, tag) / arecv(buffer, tag, tag_mask) – async one-sided messaging.
  • aflush() – wait for all server-side operations to complete.
  • aflush_ep(client_ep) – flush operations targeting a specific endpoint.
  • evaluate_perf(client_ep, msg_size) – request UCX transport estimates.
  • get_worker_address() – read back the cached worker address bytes.
  • aclose() – gracefully shut down and release resources.

Client

  • aconnect(addr, port) – connect to a listener.
  • aconnect_address(worker_address) – connect using a UCX worker address only.
  • asend(buffer, tag) / arecv(buffer, tag, tag_mask) – async messaging APIs.
  • aflush() – wait for in-flight client operations to finish.
  • evaluate_perf(msg_size) – ask UCX for local transport estimates.
  • get_worker_address() – shareable bytes for reciprocal connections.
  • aclose() – close the connection and stop the worker.

ServerEndpoint

Inspect transport metadata for debugging or topology decisions:

  • .name – UCX endpoint name.
  • .local_addr, .local_port, .remote_addr, .remote_port – socket details when available (address-only mode may leave these empty).
  • .view_transports() – list (device, transport) tuples negotiated by UCX.

Flushing and Ordering

UCX operations are inherently asynchronous. Starway exposes lightweight futures on top of UCX requests and lets you opt into ordering guarantees:

  • Client.aflush() and Server.aflush() drain all pending operations on their respective workers.
  • Server.aflush_ep(ep) waits for sends targeting a single endpoint.
  • All async flushes integrate with Python's event loop, making them suitable for structured concurrency patterns (await asyncio.gather(...)).

Testing

Pytest drives the integration suite. Typical commands:

uv sync --group dev --group test
uv run pytest tests/test_basic.py -vv

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

starway-0.6.0.tar.gz (64.2 kB view details)

Uploaded Source

Built Distributions

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

starway-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl (210.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

starway-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl (210.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

starway-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl (210.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

starway-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl (210.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file starway-0.6.0.tar.gz.

File metadata

  • Download URL: starway-0.6.0.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for starway-0.6.0.tar.gz
Algorithm Hash digest
SHA256 04a5440596425aea9020e86e5971ec81a16938da44ba96e9916bbd0100bb765d
MD5 bc7e3123a7b2cf2d6113620373d9d13e
BLAKE2b-256 411915d4482c0aa66d948e6872ae81895c890f595329b360430e438da7c05d98

See more details on using hashes here.

Provenance

The following attestation bundles were made for starway-0.6.0.tar.gz:

Publisher: wheels.yml on Clouder0/starway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starway-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for starway-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0692f9311c26ec79c5bcab8061797b9f3e08b2ba72a9ee390c84ee9b908305d5
MD5 74fe3e995d5ee0e7e89ec26397e29749
BLAKE2b-256 57312ab1626ba6be44750ab7e12a0d34587dc2a677e7a0c27e6278f76ddfdb99

See more details on using hashes here.

Provenance

The following attestation bundles were made for starway-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: wheels.yml on Clouder0/starway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starway-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for starway-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4b6ae700d48860b0122b58ef28ab7a67ec6d34f2c99c6ffa010965d05b2c9d13
MD5 219d3760ef98174b9ebe73fa9c7d1988
BLAKE2b-256 3d2ca357a063eef799f20780e78cb0704a78212a6d99819b411f545a5398ed69

See more details on using hashes here.

Provenance

The following attestation bundles were made for starway-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: wheels.yml on Clouder0/starway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starway-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for starway-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c74734bbe82c5587758e7c6fbb893513dad9f80d3fbd1b6f39de508669655947
MD5 005060bcf17a6b51ce79b7768e4e1aa2
BLAKE2b-256 09cf508a4abd2678b217e9b8a56faedb8c3f3a8c86782f4dbe20dfba192b9976

See more details on using hashes here.

Provenance

The following attestation bundles were made for starway-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: wheels.yml on Clouder0/starway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starway-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for starway-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2bd3a06d615b9541d4d10f46a3c42df51850920945a2ffe367a2f24b4db4e19c
MD5 e92472472dafa1f37eedbf38d99b5819
BLAKE2b-256 428d3956a5b266ad4c0eb0921ae2b9a5b551281f89b93f70768ac8a7679bfd7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for starway-0.6.0-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: wheels.yml on Clouder0/starway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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