Skip to content

Commit

Permalink
Build MLC-Chat wheels for apple silicon (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh119 authored Jun 19, 2023
1 parent a0534d4 commit 2e3e759
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/llm_conda_nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GH actions.
name: LLM-Conda-Nightly
name: MLC-Chat-CLI-Conda-Nightly

on:
push:
Expand All @@ -16,7 +16,7 @@ jobs:
Build:
strategy:
matrix:
pkg: ['mlc-chat-nightly']
pkg: ['mlc-chat-cli-nightly']
sys:
- os: ubuntu-latest
conda_pkg_path: linux-64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prune_nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
run: >-
python -m pip install pyOpenSSL --upgrade &&
python -m pip install github3.py requests &&
python wheel/wheel_prune_and_sync.py --site-path mlc-ai.github.io --repo mlc-ai/package
python scripts/wheel_prune_and_sync.py --site-path mlc-ai.github.io --repo mlc-ai/package
4 changes: 2 additions & 2 deletions .github/workflows/wheel_manylinux_nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ jobs:
IMAGE: mlc-ai-${{ matrix.config.cuda }}
CUDA: ${{ matrix.config.cuda }}
run: |
docker/bash.sh --no-gpu $IMAGE ./wheel/build_wheel_manylinux.sh --cuda $CUDA
docker/bash.sh --no-gpu $IMAGE ./scripts/build_mlc_ai_wheel_manylinux.sh --cuda $CUDA
- name: Build MLC-Chat
env:
IMAGE: mlc-ai-${{ matrix.config.cuda }}
CUDA: ${{ matrix.config.cuda }}
run: |
docker/bash.sh --no-gpu $IMAGE ./wheel/build_mlc_chat_wheel_manylinux.sh --cuda $CUDA
docker/bash.sh --no-gpu $IMAGE ./scripts/build_mlc_chat_wheel_manylinux.sh --cuda $CUDA
- name: Wheel-Deploy
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheel_winmac_nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ jobs:
- name: Build@MacOS
if: startsWith(matrix.sys.os, 'macOS')
run: >-
scripts/build_lib_osx.sh
scripts/build_mlc_ai_lib_osx.sh
- name: Build MLC-Chat@MacOS
if: startsWith(matrix.sys.os, 'macOS')
run: >-
scripts/build_mlc_chat_lib_osx.sh
- name: Build@Win
if: startsWith(matrix.sys.os, 'windows')
run: >-
scripts/build_lib_win.bat
scripts/build_mlc_ai_lib_win.bat
- name: Build MLC-Chat@Win
if: startsWith(matrix.sys.os, 'windows')
run: >-
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ do
# cleanup and clone tvm mlc
rm -rf tvm && git clone https://github.com/mlc-ai/relax tvm --recursive --single-branch --branch mlc
# sync package
python common/sync_package.py mlc-ai-nightly --revision origin/mlc
python scripts/sync_package.py --package tvm --package-name mlc-ai-nightly --revision origin/mlc
# build tvm
./scripts/build_lib_apple_silicon.sh
./scripts/build_mlc_ai_lib_apple_silicon.sh

# build wheel
cd tvm/python && python setup.py bdist_wheel && cd -
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions scripts/build_mlc_chat_lib_apple_silicon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e
set -u

cd mlc-llm
rm -f config.cmake
rm -rf build
mkdir -p build
cd build

MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-13.02}

cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-DUSE_METAL=ON \
..

make -j12
cd ../..
32 changes: 32 additions & 0 deletions scripts/build_mlc_chat_wheel_apple_silicon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -euxo pipefail

eval "$(command conda 'shell.bash' 'hook' 2> /dev/null)"

# Need to first
# - create these enviroments,
# - install dependencies in https://github.com/tlc-pack/tlcpack/blob/main/conda/build-environment.yaml for these env.
declare -a conda_env_names=("wheel-3-8" "wheel-3-9" "wheel-3-10" "wheel-3-11")

export GITHUB_TOKEN=$1

for name in "${conda_env_names[@]}"
do
echo "Start build for $name"

# conda activate
conda activate $name

# cleanup and clone mlc-llm
rm -rf mlc-llm && git clone https://github.com/mlc-ai/mlc-llm mlc-llm --recursive --single-branch --branch main
# sync package
python scripts/sync_package.py --package mlc-llm --package-name mlc-chat-nightly --revision origin/main
# build mlc-llm
./scripts/build_mlc_chat_lib_apple_silicon.sh

# build wheel
cd mlc-llm/python && python setup.py bdist_wheel && cd -

# deploy wheel
python scripts/wheel_upload.py --repo mlc-ai/package --tag v0.9.dev0 mlc-llm/python/dist
done
File renamed without changes.
File renamed without changes.

0 comments on commit 2e3e759

Please sign in to comment.