IREE Turbine Machine Learning Deployment Tools
Project description
IREE Turbine
Turbine is IREE's frontend for PyTorch.
Turbine provides a collection of tools:
- AOT Export: For compiling one or more
nn.Module
s 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. - Custom Ops: Integration for defining custom PyTorch ops and implementing them in terms of IREE's backend IR or a Pythonic kernel language.
Contact us
Turbine is under active development. Feel free to reach out on one of
IREE's communication channels
(specifically, we monitor the #pytorch
and #turbine
channels on the IREE
Discord server).
Quick start for users
- Install from PyPI:
pip install iree-turbine
# Or for editable: see instructions under developers
The above does install some cuda/cudnn packages which are unnecessary for most usage. To avoid this you can install just pytorch-cpu via:
pip install -r pytorch-cpu-requirements.txt
pip install iree-turbine
(or follow the "Developers" instructions below for installing from head/nightly)
- 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.
- AOT MLP With Static Shapes
- AOT MLP with a dynamic batch size
- AOT llama2: Dynamic sequence length custom compiled module with state management internal to the model.
- Eager MNIST with
torch.compile
Developers
Use this as a guide to get started developing the project using pinned, pre-release dependencies. You are welcome to deviate as you see fit, but these canonical directions mirror what the CI does.
Setup a venv
We recommend setting up a virtual environment (venv). The project is configured
to ignore .venv
directories, and editors like VSCode pick them up by default.
python -m venv --prompt iree-turbine .venv
source .venv/bin/activate
Install PyTorch for your system
If no explicit action is taken, the default PyTorch version will be installed. This will give you a current CUDA-based version. Install a different variant by doing so explicitly first:
CPU:
pip install -r pytorch-cpu-requirements.txt
ROCM:
pip install -r pytorch-rocm-requirements.txt
Install development packages
# Install editable local projects.
pip install -r requirements.txt -e .
Running tests
# Python unit tests
pytest .
# Lit tests
lit lit_tests/ -v
Optional: Pre-commits and developer settings
This project is set up to use the pre-commit
tooling. To install it in
your local repo, run: pre-commit install
. After this point, when making
commits locally, hooks will run. See https://pre-commit.com/
Using a development compiler
If doing native development of the compiler, it can be useful to switch to source builds for iree-base-compiler and iree-base-runtime.
In order to do this, check out IREE and follow the instructions to build from source, making sure to specify additional options for the Python bindings:
-DIREE_BUILD_PYTHON_BINDINGS=ON -DPython3_EXECUTABLE="$(which python)"
Configuring python
Uninstall existing packages (including any with the old package names):
pip uninstall iree-compiler iree-base-compiler iree-runtime iree-base-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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file iree_turbine-3.0.0-py3-none-any.whl
.
File metadata
- Download URL: iree_turbine-3.0.0-py3-none-any.whl
- Upload date:
- Size: 274.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 491a1c500a72ae08c373f74a85c789b9d130cff4725c6a878332b9dafc4b7c43 |
|
MD5 | be2aea542a18945764116fd564c036e1 |
|
BLAKE2b-256 | 1bbe3eb5e279cb932e4bbd206a72d5ef124c61e5444f95dcb037880351d5a933 |