Skip to content

Commit

Permalink
Update docs and samples to use latest iree-turbine. (iree-org#19054)
Browse files Browse the repository at this point in the history
This adapts docs and samples to
https://github.com/iree-org/iree-turbine/releases/tag/v2.5.0.

* Switched from `import shark_turbine.aot as aot` to `import
iree.turbine.aot as aot` (see also
iree-org/iree-turbine#28).
* Redirected notes from `/RELEASING.md` to
https://github.com/iree-org/iree-turbine/blob/main/docs/releasing.md.
The release process is changing now with
iree-org#18938 and I'll want to fold the
notes there in to
https://iree.dev/developers/general/release-management/ instead.
* Re-ran some Colab notebooks and adapted to the latest changes across
projects. Note that the
https://github.com/iree-org/iree/tree/main/samples/dynamic_shapes sample
still has code using `@aot.jittable`, so I have re-opened
iree-org#18564 to migrate it. I spent
some time trying to update it but wasn't sure how to demonstrate dynamic
shapes using the "modern canonical usage" effectively.
* This fixes the recent test failures:
https://github.com/iree-org/iree/actions/runs/11697207429/job/32575551934.
Test run:
https://github.com/ScottTodd/iree/actions/runs/11713816651/job/32627295562

Signed-off-by: Giacomo Serafini <179146510+giacs-epic@users.noreply.github.com>
  • Loading branch information
ScottTodd authored and giacs-epic committed Dec 4, 2024
1 parent 777fd75 commit edf8eef
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 219 deletions.
112 changes: 4 additions & 108 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ release process:
* https://pypi.org/project/iree-compiler/
* https://pypi.org/project/iree-runtime/
* https://pypi.org/project/iree-turbine/
* https://pypi.org/project/shark-turbine/ (transitional until switched to
iree-turbine)
* https://pypi.org/project/iree-tools-tf/
* https://pypi.org/project/iree-tools-tflite/

Expand All @@ -101,109 +99,7 @@ Deprecated projects no longer updated:

There are presently two build promotion processes documented:

* Old one focused purely on releasing IREE core packages:
https://iree.dev/developers/general/release-management/
* New one driven by the Torch frontend and documented below.

The versioning scheme for
[iree-turbine](https://github.com/iree-org/iree-turbine) is rooted on the
then-current PyTorch released version, with optional date-based dev/pre-release
suffixes (i.e. `rcYYYYMMDD` or `devYYYYMMDD`) or intra PyTorch releases
(i.e. `postVVVV`).

This process is being trialed to correspond with the 2.3.0 release of PyTorch.
In this scenario, the pinned nightly build of IREE is considered current and
promoted as part of the Turbine release to PyPI (and the release is marked as
not pre-release on the GitHub releases page).

Promotions are done roughly monthly or at need. The schedule is shifted to
account for extra factors as needed.

In the future, we would like to adopt a real versioning scheme (beyond the
nightly calver+build number scheme) and manage promotion and pinning of the
core IREE dep more explicitly and in alignment with how downstreams are using
it.

### Steps to Promote

There are multiple release artifacts that are deployed from this project:

* shark-turbine wheel (transitional while switching to iree-turbine)
* iree-turbine wheel
* iree-compiler wheels
* iree-runtime wheels

Typically we deploy IREE compiler and runtime wheels along with a turbine
release, effectively promoting a nightly.

#### Building Artifacts

Start with a clean clone of iree-turbine:

```
cd scratch
git clone git@github.com:iree-org/iree-turbine.git
cd iree-turbine
```

Build a pre-release:

```
./build_tools/build_release.py --core-version 2.3.0 --core-pre-version=rcYYYYMMDD
```

Build an official release:

```
./build_tools/build_release.py --core-version 2.3.0
```

This will download all deps, including wheels for all supported platforms and
Python versions for iree-compiler and iree-runtime. All wheels will be placed
in the `wheelhouse/` directory.


#### Testing

TODO: Write a script for this.

```
python -m venv wheelhouse/test.venv
source wheelhouse/test.venv/bin/activate
pip install -f wheelhouse iree-turbine[testing]
# Temp: tests require torchvision.
pip install -f wheelhouse torchvision
pytest core/tests
```

#### Push

From the testing venv, verify that everything is sane:

```
pip freeze
```

Push IREE deps (if needed/updated):

```
twine upload wheelhouse/iree_compiler-* wheelhouse/iree_runtime-*
```

Push built wheels:

```
twine upload wheelhouse/iree_turbine-* wheelhouse/shark_turbine-*
```

#### Install from PyPI and Sanity Check

TODO: Script this

From the testing venv:

```
pip uninstall -y shark-turbine iree-turbine iree-compiler iree-runtime
pip install iree-turbine
pytest core/tests
```
* Releasing IREE core packages:
https://iree.dev/developers/general/release-management/
* Releasing iree-turbine packages:
https://github.com/iree-org/iree-turbine/blob/main/docs/releasing.md
12 changes: 6 additions & 6 deletions docs/website/docs/guides/ml-frameworks/pytorch.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ status: new

## :octicons-book-16: Overview

[iree-turbine](https://pypi.org/project/iree-turbine/) (rebrand pending from
"shark-turbine") offers a tight integration between compatible versions of IREE,
[iree-turbine](https://pypi.org/project/iree-turbine/) offers a tight
integration between compatible versions of IREE,
[torch-mlir](https://github.com/llvm/torch-mlir), and
[PyTorch](https://pytorch.org/).

Expand Down Expand Up @@ -193,7 +193,7 @@ graph LR
```python
import iree.runtime as ireert
import numpy as np
import shark_turbine.aot as aot
import iree.turbine.aot as aot
import torch

# Define the `nn.Module` to export.
Expand Down Expand Up @@ -264,15 +264,15 @@ graph LR
```

Advanced export workflows can use the
[`aot.CompiledModule`](https://github.com/iree-org/iree-turbine/tree/main/shark_turbine/aot/compiled_module.py)
[`aot.CompiledModule`](https://github.com/iree-org/iree-turbine/blob/main/iree/turbine/aot/compiled_module.py)
class to define and constrain the structure of a program prior to compiling it.

<!-- TODO(scotttodd): API reference pages for aot.CompiledModule etc.?
https://github.com/iree-org/iree-turbine/issues/77
-->

```python
import shark_turbine.aot as aot
import iree.turbine.aot as aot

# A minimal program, with no functions or variables.
class BasicModule(aot.CompiledModule):
Expand Down Expand Up @@ -339,7 +339,7 @@ models parameters on disk, so that they can be loaded later during runtime.
import torch
from safetensors.torch import save_file
import numpy as np
import shark_turbine.aot as aot
import iree.turbine.aot as aot

class LinearModule(torch.nn.Module):
def __init__(self, in_features, out_features):
Expand Down
Loading

0 comments on commit edf8eef

Please sign in to comment.