Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

SHARK Turbine

image

Turbine is the set of development tools that the SHARK Team is building for deploying all of our models for deployment to the cloud and devices. We are building it as we transition from our TorchScript-era 1-off export and compilation to a unified approach based on PyTorch 2 and Dynamo. While we use it heavily ourselves, it is intended to be a general purpose model compilation and execution tool.

Turbine provides three primary tools:

  • AOT Export: For compiling one or more nn.Modules to compiled, deployment ready artifacts. This operates via both a simple one-shot export API (Already upstreamed to torch-mlir) for simple models and an underlying advanced API for complicated models and accessing the full features of the runtime.
  • Eager Execution: A torch.compile backend is provided and a Turbine Tensor/Device is available for more native, interactive use within a PyTorch session.
  • Turbine Kernels: (coming soon) A union of the Triton approach and Pallas but based on native PyTorch constructs and tracing. It is intended to complement for simple cases where direct emission to the underlying, cross platform, vector programming model is desirable.

Under the covers, Turbine is based heavily on IREE and torch-mlir and we use it to drive evolution of both, upstreaming infrastructure as it becomes timely to do so.

See the roadmap for upcoming work and places to contribute.

Contact Us

Turbine is under active development. If you would like to participate as it comes online, please reach out to us on the #turbine channel of the nod-ai Discord server.

Quick Start for Users

  1. Install from source:
pip install shark-turbine
# Or for editable: see instructions under developers

The above does install some unecessary cuda/cudnn packages for cpu use. To avoid this you can specify pytorch-cpu and install via:

pip install -r core/pytorch-cpu-requirements.txt
pip install shark-turbine

(or follow the "Developers" instructions below for installing from head/nightly)

  1. Try one of the samples:

Generally, we use Turbine to produce valid, dynamic shaped Torch IR (from the torch-mlir torch dialect with various approaches to handling globals). Depending on the use-case and status of the compiler, these should be compilable via IREE with --iree-input-type=torch for end to end execution. Dynamic shape support in torch-mlir is a work in progress, and not everything works at head with release binaries at present.

Developers

Getting Up and Running

If only looking to develop against this project, then you need to install Python deps for the following:

  • PyTorch
  • iree-compiler (with Torch input support)
  • iree-runtime

The pinned deps at HEAD require pre-release versions of all of the above, and therefore require additional pip flags to install. Therefore, to satisfy development, we provide a requirements.txt file which installs precise versions and has all flags. This can be installed prior to the package:

Installing into a venv is highly recommended.

pip install -r core/pytorch-cpu-requirements.txt
pip install --upgrade -r core/requirements.txt
pip install --upgrade -e "core[torch-cpu-nightly,testing]"

Run tests:

pytest core/

Using a development compiler

If doing native development of the compiler, it can be useful to switch to source builds for iree-compiler and iree-runtime.

In order to do this, check out IREE and follow the instructions to build from source, making sure to specify additional options:

-DIREE_BUILD_PYTHON_BINDINGS=ON -DPython3_EXECUTABLE="$(which python)"

Configuring Python

Uninstall existing packages:

pip uninstall iree-compiler
pip uninstall iree-runtime

Copy the .env file from iree/ to this source directory to get IDE support and add to your path for use from your shell:

source .env && export PYTHONPATH

Metadata

Release files for shark-turbine 2.3.0rc20240410

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

Built distribution (wheel)

Table of built distributions (wheels) for shark-turbine 2.3.0rc20240410
File Interpreter ABI Platform Actions
shark_turbine-2.3.0rc20240410-py3-none-any.whl Python 3 none any Details for shark_turbine-2.3.0rc20240410-py3-none-any.whl

Release files / shark_turbine-2.3.0rc20240410-py3-none-any.whl

Download URL shark_turbine-2.3.0rc20240410-py3-none-any.whl
Size 150.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03e97b7cd5d095712dd9cedbb98a11645fa54d4e9e50d08485cf211bbef8a9d0
BLAKE2b-256 checksum
How to use checksums
66897b34dcbd246dcd7d815dcf9ca178c3905c0f6bae914b4a5a62e9e3a4f3b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0rc1

Security for shark-turbine 2.3.0rc20240410

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