Skip to content

Commit

Permalink
Merge branch 'main' into repin-sharktank-numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
stbaione authored Nov 15, 2024
2 parents 59eff94 + e417abd commit 72603b5
Show file tree
Hide file tree
Showing 54 changed files with 440 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
token: "${{ secrets.RELEASE_PUBLISH_ACCESS_TOKEN }}"
tag: "dev-wheels"
name: "dev-wheels"
body: "Automatic snapshot release of SHARK-Platform python wheels."
body: "Automatic snapshot release of shark-ai python wheels."
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-llama-large-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
# Test with pinned nightly releases, not what iree-turbine uses.
pip install -f https://iree.dev/pip-release-links.html --upgrade \
iree-base-compiler==2.9.0rc20241108 \
iree-base-runtime==2.9.0rc20241108
iree-base-compiler==3.0.0rc20241115 \
iree-base-runtime==3.0.0rc20241115
- name: Run llama tests
run: pytest sharktank/tests/models/llama/benchmark_amdgpu_test.py -v -s --run-all-llama --iree-hip-target=gfx942 --html=out/index.html
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-llama-quick-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
# Test with pinned nightly releases, not what iree-turbine uses.
pip install -f https://iree.dev/pip-release-links.html --upgrade \
iree-base-compiler==2.9.0rc20241108 \
iree-base-runtime==2.9.0rc20241108
iree-base-compiler==3.0.0rc20241115 \
iree-base-runtime==3.0.0rc20241115
- name: Run llama 8b tests
run: pytest sharktank/tests/models/llama/benchmark_amdgpu_test.py -v -s --iree-hip-target=gfx942 --run-8b-llama
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-sdxl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
repository: iree-org/iree
path: ${{ env.IREE_REPO_DIR }}
submodules: false
ref: iree-2.9.0rc20241108
ref: iree-3.0.0rc20241115

- name: Initalize IREE submodules
working-directory: ${{ env.IREE_REPO_DIR }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-sglang-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
# We could also pin to a known working or stable version.
# This should eventually stabilize. Do the best we can for now.
pip install -f https://iree.dev/pip-release-links.html --upgrade \
iree-base-compiler==2.9.0rc20241108 \
iree-base-runtime==2.9.0rc20241108 \
iree-base-compiler==3.0.0rc20241115 \
iree-base-runtime==3.0.0rc20241115 \
"numpy<2.0"
- name: Install SGLang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: CI - shark-platform
name: CI - shark-ai

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux_x64-libshortfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
repository: iree-org/iree
path: ${{ env.IREE_REPO_DIR }}
submodules: false
ref: iree-2.9.0rc20241108
ref: iree-3.0.0rc20241115

- name: Initalize IREE submodules
working-directory: ${{ env.IREE_REPO_DIR }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux_x64_asan-libshortfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
repository: iree-org/iree
path: ${{ env.IREE_SOURCE_DIR }}
submodules: false
ref: iree-2.9.0rc20241108
ref: iree-3.0.0rc20241115

- name: Initalize IREE submodules
working-directory: ${{ env.IREE_SOURCE_DIR }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux_x64_nogil-libshortfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
repository: iree-org/iree
path: ${{ env.IREE_REPO_DIR }}
submodules: false
ref: iree-2.9.0rc20241108
ref: iree-3.0.0rc20241115

- name: Initalize IREE submodules
working-directory: ${{ env.IREE_REPO_DIR }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_windows_x64-libshortfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
repository: iree-org/iree
path: ${{ env.IREE_REPO_DIR }}
submodules: false
ref: iree-2.9.0rc20241108
ref: iree-3.0.0rc20241115

- name: Initalize IREE submodules
working-directory: ${{ env.IREE_REPO_DIR }}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SHARK Modeling and Serving Libraries
# shark-ai: SHARK Modeling and Serving Libraries

> [!IMPORTANT]
> Development is still in progress for several project components. See the
> notes below for which workflows are best supported.
![GitHub License](https://img.shields.io/github/license/nod-ai/SHARK-Platform)
![GitHub License](https://img.shields.io/github/license/nod-ai/shark-ai)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

<!-- TODO: high level overview, features when components are used together -->
Expand All @@ -15,7 +15,7 @@

<!-- TODO: features list here? -->

[![PyPI version](https://badge.fury.io/py/shortfin.svg)](https://badge.fury.io/py/shortfin) [![CI - shortfin](https://github.com/nod-ai/SHARK-Platform/actions/workflows/ci_linux_x64-libshortfin.yml/badge.svg?event=push)](https://github.com/nod-ai/SHARK-Platform/actions/workflows/ci_linux_x64-libshortfin.yml?query=event%3Apush)
[![PyPI version](https://badge.fury.io/py/shortfin.svg)](https://badge.fury.io/py/shortfin) [![CI - shortfin](https://github.com/nod-ai/shark-ai/actions/workflows/ci_linux_x64-libshortfin.yml/badge.svg?event=push)](https://github.com/nod-ai/shark-ai/actions/workflows/ci_linux_x64-libshortfin.yml?query=event%3Apush)

The shortfin sub-project is SHARK's high performance inference library and
serving engine.
Expand All @@ -25,7 +25,7 @@ serving engine.

### [`sharktank/`](./sharktank/)

[![PyPI version](https://badge.fury.io/py/sharktank.svg)](https://badge.fury.io/py/sharktank) [![CI - sharktank](https://github.com/nod-ai/SHARK-Platform/actions/workflows/ci-sharktank.yml/badge.svg?event=push)](https://github.com/nod-ai/SHARK-Platform/actions/workflows/ci-sharktank.yml?query=event%3Apush)
[![PyPI version](https://badge.fury.io/py/sharktank.svg)](https://badge.fury.io/py/sharktank) [![CI - sharktank](https://github.com/nod-ai/shark-ai/actions/workflows/ci-sharktank.yml/badge.svg?event=push)](https://github.com/nod-ai/shark-ai/actions/workflows/ci-sharktank.yml?query=event%3Apush)

The SHARK Tank sub-project contains a collection of model recipes and
conversion tools to produce inference-optimized programs.
Expand All @@ -45,7 +45,7 @@ conversion tools to produce inference-optimized programs.

### [`tuner/`](./tuner/)

[![CI - Tuner](https://github.com/nod-ai/SHARK-Platform/actions/workflows/ci-tuner.yml/badge.svg?event=push)](https://github.com/nod-ai/SHARK-Platform/actions/workflows/ci-tuner.yml?query=event%3Apush)
[![CI - Tuner](https://github.com/nod-ai/shark-ai/actions/workflows/ci-tuner.yml/badge.svg?event=push)](https://github.com/nod-ai/shark-ai/actions/workflows/ci-tuner.yml?query=event%3Apush)

The Tuner sub-project assists with tuning program performance by searching for
optimal parameter configurations to use during model compilation.
Expand All @@ -63,8 +63,8 @@ optimal parameter configurations to use during model compilation.

Model name | Model recipes | Serving apps
---------- | ------------- | ------------
SDXL | [`sharktank/sharktank/models/punet/`](https://github.com/nod-ai/SHARK-Platform/tree/main/sharktank/sharktank/models/punet) | [`shortfin/python/shortfin_apps/sd/`](https://github.com/nod-ai/SHARK-Platform/tree/main/shortfin/python/shortfin_apps/sd)
llama | [`sharktank/sharktank/models/llama/`](https://github.com/nod-ai/SHARK-Platform/tree/main/sharktank/sharktank/models/llama) | [`shortfin/python/shortfin_apps/llm/`](https://github.com/nod-ai/SHARK-Platform/tree/main/shortfin/python/shortfin_apps/llm)
SDXL | [`sharktank/sharktank/models/punet/`](https://github.com/nod-ai/shark-ai/tree/main/sharktank/sharktank/models/punet) | [`shortfin/python/shortfin_apps/sd/`](https://github.com/nod-ai/shark-ai/tree/main/shortfin/python/shortfin_apps/sd)
llama | [`sharktank/sharktank/models/llama/`](https://github.com/nod-ai/shark-ai/tree/main/sharktank/sharktank/models/llama) | [`shortfin/python/shortfin_apps/llm/`](https://github.com/nod-ai/shark-ai/tree/main/shortfin/python/shortfin_apps/llm)


## SHARK Users
Expand Down
48 changes: 48 additions & 0 deletions build_tools/python_deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Python Deployment

These scripts assist with building Python packages and pushing them to
[PyPI (the Python Package Index)](https://pypi.org/). See also

* The Python Packaging User Guide: <https://packaging.python.org/en/latest/>

## Overview

See comments in scripts for canonical usage. This page includes additional
notes.

### Package building

These scripts build packages:

* [`/shark-ai/build_tools/build_linux_package.sh`](/shark-ai/build_tools/build_linux_package.sh)
* [`/sharktank/build_tools/build_linux_package.sh`](/sharktank/build_tools/build_linux_package.sh)
* [`/shortfin/build_tools/build_linux_package.sh`](/shortfin/build_tools/build_linux_package.sh)

### Version management

These scripts handle versioning across packages, including considerations like
major, minor, and patch levels (`X.Y.Z`), as well as suffixes like
`rc20241107`:

* [`compute_common_version.py`](./compute_common_version.py)
* [`compute_local_version.py`](./compute_local_version.py)
* [`promote_whl_from_rc_to_final.py`](./promote_whl_from_rc_to_final.py)
* [`write_requirements.py`](./write_requirements.py)

### PyPI deployment

These scripts handle promoting nightly releases packages to stable and pushing
to PyPI:

* [`promote_whl_from_rc_to_final.py`](./promote_whl_from_rc_to_final.py)
* [`pypi_deploy.sh`](./pypi_deploy.sh)

Both of these scripts expect to have the dependencies from
[`requirements-pypi-deploy.txt`](./requirements-pypi-deploy.txt) installed.
This can be easily managed by using a Python virtual environment:

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install -r ./requirements-pypi-deploy.txt
```
8 changes: 6 additions & 2 deletions build_tools/python_deploy/compute_common_version.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This scripts grabs the `X.Y.Z[.dev]` version identifier from the
# sharktank and shortfin version files and computes the version
# for the meta package.
# 'sharktank' and 'shortfin' version files and computes the version
# for the meta 'shark-ai' package.
#
# Usage:
# ./compute_common_version.py --stable-release --write-json
# cat ../../shark-ai/version_local.json

import argparse
from pathlib import Path
Expand Down
Empty file modified build_tools/python_deploy/compute_local_version.py
100644 → 100755
Empty file.
File renamed without changes.
126 changes: 126 additions & 0 deletions build_tools/python_deploy/pypi_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash

# Copyright 2024 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This script promotes Python packages from nightly releases to PyPI.
#
# Prerequisites:
# * You will need to have PyPI credentials set up. See
# https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives
# * Install requirements, e.g. in a Python virtual environment (venv):
# `pip install -r requirements-pypi-deploy.txt`
# * Install python3.13t and install pip. On Ubuntu:
# ```bash
# sudo add-apt-repository ppa:deadsnakes
# sudo apt-get update
# sudo apt-get install python3.13-nogil
# python3.13t -m ensurepip --upgrade
# ```
# * Choose a release candidate to promote from
# https://github.com/nod-ai/shark-ai/releases/tag/dev-wheels
#
# Usage:
# ./pypi_deploy.sh 2.9.0rc20241108

set -euo pipefail

RELEASE="$1"

SCRIPT_DIR="$(dirname -- "$( readlink -f -- "$0"; )")";
REPO_ROOT="$(cd "$SCRIPT_DIR"/../../ && pwd)"
TMPDIR="$(mktemp --directory --tmpdir shark_platform_pypi_wheels.XXXXX)"
ASSETS_PAGE="https://github.com/nod-ai/shark-ai/releases/expanded_assets/dev-wheels"

# TODO: rewrite in Python?

function download_wheels() {
echo ""
echo "Downloading wheels for '${RELEASE}'..."

# sharktank
python -m pip download sharktank==${RELEASE} \
--no-deps --python-version 3.11 -f ${ASSETS_PAGE}

# shortfin
python -m pip download shortfin==${RELEASE} \
--no-deps --python-version 3.11 -f ${ASSETS_PAGE}
python -m pip download shortfin==${RELEASE} \
--no-deps --python-version 3.12 -f ${ASSETS_PAGE}
python -m pip download shortfin==${RELEASE} \
--no-deps --python-version 3.13 -f ${ASSETS_PAGE}
python -m pip download shortfin==${RELEASE} \
--no-deps --python-version 3.13 -f ${ASSETS_PAGE}
# TODO: fetch 3.13t using the same `python` somehow
# * https://pip.pypa.io/en/stable/cli/pip_download/
# * https://py-free-threading.github.io/installing_cpython/
# * https://pip.pypa.io/en/stable/installation/
python3.13t -m pip download shortfin==${RELEASE} --no-deps -f ${ASSETS_PAGE}

# TODO: shark-ai meta package when it is published to nightlies

echo ""
echo "Downloaded wheels:"
ls
}

function edit_release_versions() {
echo ""
echo "Editing release versions..."
for file in *
do
${SCRIPT_DIR}/promote_whl_from_rc_to_final.py ${file} --delete-old-wheel
done

echo "Edited wheels:"
ls
}

function upload_wheels() {
# TODO: list packages that would be uploaded, pause, prompt to continue
echo ""
echo "Uploading wheels:"
ls
twine upload --verbose *
}

function build_shark_ai_meta_package() {
# TODO: download meta package from nightly releases instead of this
# Be aware that nightly releases pin other dependencies via the
# generated `requirements.txt` compared to stable releases.
echo ""

# TODO: rework `write_requirements.py` to use the versions from the downloaded whls?
echo "Computing local versions for sharktank and shortfin..."
${SCRIPT_DIR}/compute_local_version.py ${REPO_ROOT}/sharktank
${SCRIPT_DIR}/compute_local_version.py ${REPO_ROOT}/shortfin

echo "Computing common version for shark-ai meta package..."
${SCRIPT_DIR}/compute_common_version.py --stable-release --write-json

echo "Writing requirements for shark-ai meta package..."
${SCRIPT_DIR}/write_requirements.py

echo "Building shark-ai meta package..."
${REPO_ROOT}/shark-ai/build_tools/build_linux_package.sh

# TODO: This is error-prone. We only want to publish the whl for this release.
# Copy instead? Specify exact file name? Clear directory before building?
mv ${REPO_ROOT}/shark-ai/build_tools/wheelhouse/* .
}

function main() {
echo "Changing into ${TMPDIR}"
cd "${TMPDIR}"
# TODO: check_requirements (using pip)

download_wheels
edit_release_versions
build_shark_ai_meta_package
upload_wheels
}

main
File renamed without changes.
Empty file modified build_tools/python_deploy/write_requirements.py
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/model_cookbook.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Model cookbook

Note: These are early notes and commands that the SHARK-Platform team is using
Note: These are early notes and commands that the shark-ai team is using
and will turn into proper docs later.

## Diagrams
Expand Down
Loading

0 comments on commit 72603b5

Please sign in to comment.