Skip to content

Commit

Permalink
Merge branch 'main' into shortfin-system-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
renxida authored Oct 16, 2024
2 parents cde99ed + e30d0af commit a38e87c
Show file tree
Hide file tree
Showing 12 changed files with 1,376 additions and 18 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/ci_windows_x64-libshortfin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# 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

name: CI - shortfin - Windows

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
paths:
- '.github/workflows/ci_windows_x64-libshortfin.yml'
- 'shortfin/**'

permissions:
contents: read

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit). The workflow name is prepended to avoid conflicts between
# different workflows.
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

env:
IREE_REPO_DIR: ${{ github.workspace }}/iree
LIBSHORTFIN_DIR: ${{ github.workspace }}/shortfin/

jobs:
build-and-test:
name: Build and test
runs-on: windows-2022

steps:
- name: Configure MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0

- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: false

- name: Checkout IREE repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: iree-org/iree
path: ${{ env.IREE_REPO_DIR }}
submodules: false
ref: candidate-20240904.1006

- name: Initalize IREE submodules
working-directory: ${{ env.IREE_REPO_DIR }}
run : |
git submodule update --init --depth 1 -- third_party/benchmark
git submodule update --init --depth 1 -- third_party/cpuinfo/
git submodule update --init --depth 1 -- third_party/flatcc
git submodule update --init --depth 1 -- third_party/googletest
git submodule update --init --depth 1 -- third_party/hip-build-deps/
- name: Setup Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.12"
cache: "pip"
- name: Install Python packages
working-directory: ${{ env.LIBSHORTFIN_DIR }}
run: |
pip install -r requirements-tests.txt
pip install -r requirements-iree-compiler.txt
pip freeze
- name: Build shortfin (full)
working-directory: ${{ env.LIBSHORTFIN_DIR }}
shell: bash
run: |
mkdir build
cmake -GNinja \
-S. \
-Bbuild \
-DSHORTFIN_BUNDLE_DEPS=ON \
-DSHORTFIN_IREE_SOURCE_DIR="${{ env.IREE_REPO_DIR }}" \
-DSHORTFIN_BUILD_PYTHON_BINDINGS=ON
cmake --build build --target all
pip install -v -e build/
- name: Test shortfin (full)
working-directory: ${{ env.LIBSHORTFIN_DIR }}
run: |
ctest --timeout 30 --output-on-failure --test-dir build
pytest -s
60 changes: 60 additions & 0 deletions .github/workflows/eval_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Evaluation Tests

on:
workflow_dispatch:
schedule:
# Weekdays nightly at 07:00 UTC = 23:00 PST / 00:00 PDT.
- cron: "0 7 * * 1-5"

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit). The workflow name is prepended to avoid conflicts between
# different workflows.
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
test_perplexity:
name: "Evaluation Tests - perplexity"
strategy:
matrix:
version: [3.11]
os: [ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{matrix.os}}
defaults:
run:
shell: bash
env:
PIP_CACHE_DIR: "${{ github.workspace }}/.pip-cache"
steps:
- name: "Setting up Python"
id: setup_python
uses: actions/setup-python@v3
with:
python-version: ${{matrix.version}}

- name: "Checkout Code"
uses: actions/checkout@v3

- name: Cache Pip Packages
uses: actions/cache@v4
id: cache-pip
with:
path: ${{ env.PIP_CACHE_DIR }}
key: pip-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('*requirements.txt') }}

- name: Install pip deps
run: |
python -m pip install --no-compile --upgrade pip
# Note: We install in three steps in order to satisfy requirements
# from non default locations first. Installing the PyTorch CPU
# wheels saves multiple minutes and a lot of bandwidth on runner setup.
pip install --no-compile -r pytorch-cpu-requirements.txt
pip install --no-compile -f https://iree.dev/pip-release-links.html --src deps \
-e "git+https://github.com/iree-org/iree-turbine.git#egg=iree-turbine"
pip install --no-compile -r requirements.txt -e sharktank/ shortfin/
- name: Run perplexity test
run: pytest sharktank/tests/evaluate/perplexity_test.py
10 changes: 10 additions & 0 deletions docs/model_cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ iree-run-module \
--parameters=model=/tmp/open_llama_3b_v2/open-llama-3b-v2-f16.gguf
```

## Evaluation pipeline

Run perplexity test:

```bash
python -m sharktank.evaluate.perplexity \
--gguf-file=llama8b_f16.gguf \
--tokenizer-config-json=tokenizer_config.json
```

## Generating data for llama models

```bash
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ onnx==1.15.0
huggingface-hub==0.22.2
transformers==4.40.0
sentencepiece==0.2.0
datasets==3.0.0

# It is expected that you have installed a PyTorch version/variant specific
# to your needs, so we only include a minimum version spec.
Expand Down
3 changes: 1 addition & 2 deletions sharktank/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ def initialize_options(self):
name=f"sharktank",
version=f"{PACKAGE_VERSION}",
author="SHARK Authors",
author_email="[email protected]",
description="SHARK layers and inference models for genai",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/nod-ai/sharktank",
url="https://github.com/nod-ai/SHARK-Platform",
license="Apache-2.0",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
12 changes: 12 additions & 0 deletions sharktank/sharktank/evaluate/data/eval_prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Robert Boulter is an English film, television and theatre actor.
Robert Boulter had a guest-starring role on the television series "The Bill" in 2000.
Du Fu was a prominent Chinese poet of the Tang dynasty.
Along with Li Bai (Li Po), Du Fu is frequently called the greatest of the Chinese poets.
The Ise-class battleships were a pair of dreadnought battleships built for the Imperial Japanese Navy (IJN) during World War I.
Originally intended to be repeats of the preceding Fusō class, the Ise-class battleships were redesigned before construction began. Both ships carried supplies for the survivors of the Great Kantō earthquake in 1923.
They were modernized in 1934-37 with improvements to their armour and machinery and a rebuilt superstructure in the pagoda mast style. Afterwards they played a minor role in the Second Sino-Japanese War.
Richard Gale "Dick" Rifenburg (August 21, 1926-December 5, 1994) was an American football player and a pioneering television broadcaster for the forerunner to WIVB-TV in Buffalo.
Rifenburg played college football for the University of Michigan Wolverines in 1944 and from 1946 to 1948. He was a consensus selection at end on the 1948 College Football All-America Team.
Rifenburg played professionally in the National Football League (NFL) with the Detroit Lions for one season in 1950. After retiring from football he settled in Buffalo and became a sports broadcaster.
An oxaziridine is an organic molecule that features a three-membered heterocycle containing oxygen, nitrogen, and carbon. In their largest application, oxazidines are intermediates in the industrial production of hydrazine.
Oxaziridine derivatives are also used as specialized reagents in organic chemistry for a variety of oxidations, including alpha hydroxylation of enolates, epoxidation and aziridination of olefins, and other heteroatom transfer reactions.
Loading

0 comments on commit a38e87c

Please sign in to comment.