Skip to main content

Einshard

High-level array sharding API for JAX

Introduction

TODO: Add detailed introduction.

This project originated as a part of the Mistral 7B v0.2 JAX project and has since evolved into an independent project.

This project is supported by Cloud TPUs from Google's TPU Research Cloud (TRC).

Installation

This library requires at least Python 3.12.

pip install einshard

You need to have JAX installed by choosing the correct installation method before installing Einshard.

Usage

For testing purpose, we initialise the JAX CPU backend with 16 devices. This should be run before the actual code (e.g. placed at the top of the script):

n_devices = 16
import os
os.environ['JAX_PLATFORMS'] = 'cpu'
os.environ['XLA_FLAGS'] = os.environ.get('XLA_FLAGS', '') + f' --xla_force_host_platform_device_count={n_devices}'

Code:

from einshard import einshard 
import jax
import jax.numpy as jnp

a = jnp.zeros((4, 8))
a = einshard(a, 'a b -> * a* b2*')
jax.debug.visualize_array_sharding(a)

Output:

┌──────────┬──────────┬──────────┬──────────┐
│          │          │          │          │
│ CPU 0,8  │ CPU 1,9  │ CPU 2,10 │ CPU 3,11 │
│          │          │          │          │
│          │          │          │          │
├──────────┼──────────┼──────────┼──────────┤
│          │          │          │          │
│ CPU 4,12 │ CPU 5,13 │ CPU 6,14 │ CPU 7,15 │
│          │          │          │          │
│          │          │          │          │
└──────────┴──────────┴──────────┴──────────┘

Development

Crente venv:

python3.12 -m venv venv
. venv/bin/activate

Install dependencies:

pip install -U pip
pip install -U wheel
pip install "jax[cpu]"
pip install -r requirements.txt

Run test:

python tests/test_einshard.py

Build package:

pip install build
python -m build

Build docs:

cd docs
make html
cd docs/_build/html
python -m http.server -b 127.0.0.1

Metadata

Release files for einshard 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 einshard 0.2.0
File Size Uploaded Provenance Actions
einshard-0.2.0.tar.gz 10.9 kB Without provenance Details for einshard-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for einshard 0.2.0
File Interpreter ABI Platform Actions
einshard-0.2.0-py3-none-any.whl Python 3 none any Details for einshard-0.2.0-py3-none-any.whl

Total release size: 21.3 kB

Release files / einshard-0.2.0.tar.gz

Download URL einshard-0.2.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
07178559498da85da1a44a3ee70b9ef3a5acc1b993a35ab76c26f52cc2a83a8b
BLAKE2b-256 checksum
How to use checksums
b967c9522b2ac2ab1f2cc8b4c62f446ead137a20370172ff2fbe1b03d47ba7be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release files / einshard-0.2.0-py3-none-any.whl

Download URL einshard-0.2.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a059d40a266e843826e0a4168613d98c62ea8aedee29e5ce9b9f9e1d0fa3fd3
BLAKE2b-256 checksum
How to use checksums
e59c11d85aa5e5fe9cefda96c9bcdbaa7008c1c416ea47d5b3ce78a22410b65b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Security for einshard 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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