Skip to main content

Python actor framework for heterogeneous computing.

Project description


Python actor framework for heterogeneous computing.

PyPI Latest Release Coverage Build Status License

What is actor

Writing parallel and distributed programs is often challenging and requires a lot of time to deal with concurrency issues. Actor model provides a high-level, scalable and robust abstraction for building distributed applications. It provides several benefits:

  • Scalability: Actors easily scale across nodes. The asynchronous, non-blocking nature of actors allows them to handle huge volumes of concurrent tasks efficiently.
  • Concurrency: The actor model abstracts over concurrency, allowing developers to avoid raw threads and locks.
  • Modularity: An actor system decomposes naturally into a collection of actors that can be understood independently. Actor logic is encapsulated within the actor itself.

Why Xoscar

Xoscar implements the actor model in Python and provides user-friendly APIs that offer significant benefits for building applications on heterogeneous hardware:

  • Abstraction over low-level communication details: Xoscar handles all communication between actors transparently, whether on CPUs, GPUs, or across nodes. Developers focus on application logic rather than managing hardware resources and optimizing data transfer.
  • Flexible actor models: Xoscar supports both stateful and stateless actors. Stateful actors ensure thread safety for concurrent systems while stateless actors can handle massive volumes of concurrent messages. Developers choose the appropriate actor model for their needs.
  • Batch method: Xoscar provides a batch interface to significantly improve call efficiency when an actor interface is invoked a large number of times.
  • Advanced debugging support: Xoscar can detect potential issues like deadlocks, long-running calls, and performance bottlenecks that would otherwise be nearly impossible to troubleshoot in a heterogeneous environment.
  • Automated recovery: If an actor fails for any reason, Xoscar will automatically restart it if you want. It can monitor actors and restart them upon failure, enabling fault-tolerant systems.

Overview

architecture.png Xoscar allows you to create multiple actor pools on each worker node, typically binding an actor pool to a CPU core or a GPU card. Xoscar provides allocation policies so that whenever an actor is created, it will be instantiated in the appropriate pool based on the specified policy.

When actors communicate, Xoscar will choose the optimal communication mechanism based on which pools the actors belong to. This allows Xoscar to optimize communication in heterogeneous environments with multiple processing units and accelerators.

Where to get it

PyPI

Binary installers for the latest released version are available at the Python Package Index (PyPI).

# PyPI
pip install xoscar

Build from source

The source code is currently hosted on GitHub at: https://github.com/xorbitsai/xoscar .

Building from source requires that you have cmake and gcc installed on your system.

  • cmake >= 3.11
  • gcc >= 8
# If you have never cloned xoscar before
git clone --recursive https://github.com/xorbitsai/xoscar.git
cd xoscar/python
pip install -e .

# If you have already cloned xoscar before
cd xoscar
git submodule init
git submodule update
cd python && pip install -e .

APIs

Here are basic APIs for Xoscar.

Define an actor

import xoscar as xo

# stateful actor, for stateless actor, inherit from xo.StatelessActor
class MyActor(xo.Actor):
    def __init__(self, *args, **kwargs):
        pass

    async def __post_create__(self):
        # called after created
        pass

    async def __pre_destroy__(self):
        # called before destroy
        pass

    def method_a(self, arg_1, arg_2, **kw_1):  # user-defined function
        pass

    async def method_b(self, arg_1, arg_2, **kw_1):  # user-defined async function
        pass

Create an actor

import xoscar as xo

actor_ref = await xo.create_actor(
    MyActor, 1, 2, a=1, b=2,
    address='<ip>:<port>', uid='UniqueActorName')

Get an actor reference

import xoscar as xo

actor_ref = await xo.actor_ref(address, actor_id)

Invoke a method

# send
await actor_ref.method_a.send(1, 2, a=1, b=2)
# equivalent to actor_ref.method_a.send
await actor_ref.method_a(1, 2, a=1, b=2)
# tell, it sends a message asynchronously and does not wait for a response.
await actor_ref.method_a.tell(1, 2, a=1, b=2)

Batch method

Xoscar provides a set of APIs to write batch methods. You can simply add a @extensible decorator to your actor method and create a batch version. All calls wrapped in a batch will be sent together, reducing possible RPC cost.

Define a batch method

import xoscar as xo

class ExampleActor(xo.Actor):
    @xo.extensible
    async def batch_method(self, a, b=None):
        pass

Xoscar also supports creating a batch version of the method:

class ExampleActor(xo.Actor):
    @xo.extensible
    async def batch_method(self, a, b=None):
        raise NotImplementedError  # this will redirect all requests to the batch version

    @batch_method.batch
    async def batch_method(self, args_list, kwargs_list):
        results = []
        for args, kwargs in zip(args_list, kwargs_list):
            a, b = self.batch_method.bind(*args, **kwargs)
            # process the request
            results.append(result)
        return results  # return a list of results

In a batch method, users can define how to more efficiently process a batch of requests.

Invoke a batch method

Calling batch methods is easy. You can use <method_name>.delay to make a batched call and use <method_name>.batch to send them:

ref = await xo.actor_ref(uid='ExampleActor', address='127.0.0.1:13425')
results = await ref.batch_method.batch(
    ref.batch_method.delay(10, b=20),
    ref.batch_method.delay(20),
)

License

Apache 2

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

xoscar-0.1.1.tar.gz (124.0 kB view details)

Uploaded Source

Built Distributions

xoscar-0.1.1-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

xoscar-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

xoscar-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

xoscar-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

xoscar-0.1.1-cp311-cp311-macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

xoscar-0.1.1-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

xoscar-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

xoscar-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

xoscar-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

xoscar-0.1.1-cp310-cp310-macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

xoscar-0.1.1-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9Windows x86-64

xoscar-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

xoscar-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

xoscar-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

xoscar-0.1.1-cp39-cp39-macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

xoscar-0.1.1-cp38-cp38-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.8Windows x86-64

xoscar-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

xoscar-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

xoscar-0.1.1-cp38-cp38-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

xoscar-0.1.1-cp38-cp38-macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file xoscar-0.1.1.tar.gz.

File metadata

  • Download URL: xoscar-0.1.1.tar.gz
  • Upload date:
  • Size: 124.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xoscar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 21ad1fbcb638baafc3e24f058013ad3cc4a2ba63f010df6b5d6e0fbb1af75074
MD5 bfce1f7c825630d76e8a5b8211406ccf
BLAKE2b-256 e77e686d4b4b06030a036bf3a357be688f3b6fc5f38f3bf151dfef4f81a3e082

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: xoscar-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xoscar-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f8bfbe2cdb4cb5711eb16a38f64ab02f7416a27ca3b716613f3780a9d2c2b8fc
MD5 719b67bb4a301da9cd62a59f8c9e6c34
BLAKE2b-256 904c8eb3779c58b42819cf8c31e2b47ec862cf7513b5edafa1f13ac02366b833

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e044c5c053634f066c8bf2ec0f0808b5965a1aadbe934be9bc3880b886a7d98
MD5 14f0f6d8e5e2ff89a5851fd464b3d8dc
BLAKE2b-256 f3113250f78bb782432bb518f3ea5e65e716efb5badaa9515bea8444326c880f

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b020faba617e66d7f5b17290cf2eb3d79ee5bf922ccd2bf94452ae3154aede73
MD5 bd6a2d961d68a25780170dd5c2cb6e51
BLAKE2b-256 e60c3c5924034bc8e1726e0b272f4e342c80a49b5929acbd9856123f33157293

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 993ef76c5a07518150fbfac1c81f872b33f397a90cd0982d9c71aca24c101e13
MD5 5b1b2b8ecce86ce6d692e0b9ed39f1a9
BLAKE2b-256 660f22cb5c7fcee0accaf57d8575539aa964f6b0afd9fb06860cd268e8f2b596

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a4310434875e84699fe828d469fa9701dcae481816d15919f2462ada7930b0cf
MD5 12c497c3c1251ee47c59590539b59476
BLAKE2b-256 4c64e57c06bd2fb7b24741e5dd9714918f724bf451f623730b2857bf5d4f802e

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: xoscar-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xoscar-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 eee1924a9fd592f7c702c8d1186600439fc641fbcd411cd94dcea12a3fb36bb3
MD5 ca1a8c17d4c5de27b6c7537cdd23c8e5
BLAKE2b-256 90889b39fea8da2c7a290191836b0c734a95f5126ef6a9632075804106bdf4d9

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8aea1bb651c6ee27e0fba9c3007e11960395ace4ba15bde8db2723249dda6139
MD5 c3cc014e8bbdc68b6843afa4a7851203
BLAKE2b-256 ec2de456bcbd468e3c3288d317701e88959e23a062e51a54d202aab38df857e1

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1f5362552f684278e8d2e22e712c89ba86de7c767a55b410b82aaa6f334708bf
MD5 61a97a09d8fcfe63e4d45172ccd5fc87
BLAKE2b-256 ddf11c2b6a7b9bc3f6ddaeb9155d5849b89fe19fc2143811d971e7785fc1d0ac

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 01849332d873b5a8621e2dfe1b3c732f43f941678d383650536353973a908f01
MD5 0c3038a971983d9ca85d1c3548c1aa43
BLAKE2b-256 cd0e8ad0b3ad82ad34ab95f54c58f5fc1f1d25f947ea4627175588cc6ae49768

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 20818fb7fc354b96968dac27bfd2e698488411a1666d1d0471db46d674b34b1b
MD5 d902b1bb0b9ee18a1de0d223851c28ff
BLAKE2b-256 43af40f19b331aa17b7ef2c4eefd1e1d5665818fd1f17aa9dfc9cfa596d1cdee

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: xoscar-0.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xoscar-0.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3e0d9532d6dd10ac5b0f46896ad78d39cf500072f907ff385f4402a7082124ad
MD5 2c17afa13470279b83304590799738b1
BLAKE2b-256 53fa1ade2aaabbc37693dbe62dcf5618db89e4cdf55ebd070714610a9869e3d3

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fbb60cf6ec4811ef1affc7e9d44b561f7010402970fe79f41ac78f42a8d42a34
MD5 fcca719b91dc5be704d2c7d54974f2f6
BLAKE2b-256 980fec0a70df100625370b4b34aa22f0d2c2ae0d65a3f218efaf1a6fceb43bdf

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3734e35859f62f383fc4bdb6e1347b0c5301b2370025144f984316b2e507790b
MD5 cab8a267c791c1b827919389795aeb37
BLAKE2b-256 41b1468fbcc4cecdae157bcc4bdfa58b17f61f42c5ae1cc7c0735561f8b68cd7

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a613618dbea3ce694e5706483092dcdc62e5ef6e6e219eba8f1db6ca7338b659
MD5 cc767de8f46e2a73db92ff4c1691d370
BLAKE2b-256 22973b5e066be7d2f378f2a9bd878003e2cc37720aa7d2b2c910b092772cc85c

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 cb01e771dd21401ea86a139ca02f4771f399b29284c7e651a4926c5ed8584188
MD5 3e2e29ef982297f1274e3ac5245ba793
BLAKE2b-256 396c44386789e395944d82ee84f1a0a2330b302d99b4c569be7138aa5620a351

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: xoscar-0.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xoscar-0.1.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 44764b2c20d8ba975e7ea3c733a34eea6f41e844d07fa2d62f085630f81fa43a
MD5 0036f7fa66e917606a9107105815191e
BLAKE2b-256 7f52382d6deb26d3c8f5484d46ad665885754211da3e9127e6d3936b099f6c29

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b33cf5514451eb066625136089e563220b558fd1e84dc6dc90481f15abb5d51
MD5 d01b653e3618e94d8e1517ba4bfc8bf6
BLAKE2b-256 36428aece64426aedb5646ce3e1d70ed6fe0bb8f8c88cba4df4de23658943f61

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9c392867a3804cf8241b973c4b74d80c27f2c1c3d3d8252378819c4833250d26
MD5 dbda00017155119232f8a758a91467bc
BLAKE2b-256 7daba68c20c6d12d1fb0e741a7873d528ed71c5e92803baed4c42e45a0f30aa4

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 55a1e773c04b0599cd7fc48c119c55f96b8b31ea2e12c1a6bdb06fa0b3f45ca1
MD5 cffdacae07229cc200ffc5b2483fde7e
BLAKE2b-256 7a26e92fd24bff30de514886a7e96be40e49ee7dd25b493a72071f1a8bcd795d

See more details on using hashes here.

File details

Details for the file xoscar-0.1.1-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for xoscar-0.1.1-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 011d73bdf56a8774359713e0f65ae4e08e8787be8dbfc2eab8ed6053ab7a1fb4
MD5 a6c63f74bd731c64027c6dceada3f203
BLAKE2b-256 48c48273ab41cee5f1927c40d60f2cc9f7ffd07630cb539cc4be43f28c333d71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page