Skip to content

Commit

Permalink
CI/CD on Mac
Browse files Browse the repository at this point in the history
.

..

...

build-info as part of cicd

.
  • Loading branch information
icppWorld committed Jul 21, 2024
1 parent f39670b commit 5a9d853
Show file tree
Hide file tree
Showing 27 changed files with 257 additions and 1,681 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/cicd-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: cicd-mac

on:
workflow_dispatch:
push:
paths:
- "scripts/**"
- "native/**"
- "src/**"
- "test/**"
- "Makefile"
- ".github/trigger.txt"
- ".github/workflows/cicd-mac.yml"

jobs:
all-mac:
name: all-mac
strategy:
matrix:
python-version: [3.8, 3.11]
os: [macos-latest]

runs-on: ${{ matrix.os }}

steps:
# https://github.com/marketplace/actions/setup-miniconda
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}

# -------------------------------------------------------------------
# Checkout llama_cpp_canister & llama_cpp_onicai_fork as nested directory
- name: checkout llama_cpp_canister
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: checkout llama_cpp_onicai_fork
uses: actions/checkout@v4
with:
repository: onicai/llama_cpp_onicai_fork
ref: onicai # Specify the branch name here
path: src/llama_cpp_onicai_fork
fetch-depth: 1 # Get just the last commit
submodules: 'recursive'
# -------------------------------------------------------------------

- name: install
shell: bash -l {0} # activates the default conda environment ('test')
run: |
echo "Installing tool chains & dependencies"
pwd
make summary
make install-dfx
make install-python
make install-homebrew-mac
make install-jp-mac
- name: versions
shell: bash -l {0}
run: |
echo "icpp --version: $(icpp --version)"
echo "clang++ --version: $(clang++ --version)"
echo "g++ --version: $(g++ --version)"
#echo "wasm2wat version: $(wasm2wat --version)"
echo "pip version : $(pip --version)"
echo "python version : $(python --version)"
echo "jp version : $(jp --version)"
#echo "rustc version : $(rustc --version)"
echo "dfx version : $(dfx --version)"
echo "Ensure conda works properly"
conda info
which pip
which python
which icpp
- name: install-wasi-sdk
shell: bash -l {0}
run: |
echo "Installing wasi-sdk"
icpp install-wasi-sdk
- name: install-rust
shell: bash -l {0}
run: |
echo "Installing rust"
icpp install-rust
- name: build-info-cpp
shell: bash -l {0}
run: |
make build-info-cpp
- name: all-static
shell: bash -l {0}
run: |
make all-static
- name: test-llm-wasm
shell: bash -l {0}
run: |
make test-llm-wasm
- name: test-llm-native
shell: bash -l {0}
run: |
make test-llm-native
# TODO
# - name: all-tests
# shell: bash -l {0}
# run: |
# make all-tests
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
name: cicd
name: cicd-ubuntu

on:
workflow_dispatch:
push:
paths:
- "icpp_llama2/**"
- "scripts/**"
- "native/**"
- "src/**"
- "test/**"
- "Makefile"
- ".github/trigger.txt"
- ".github/workflows/cicd.yml"

env:
PYTHON_VERSION: 3.11
- ".github/workflows/cicd-ubuntu.yml"

jobs:
all:
name: all
runs-on: ubuntu-latest
all-ubuntu:
name: all-ubuntu
strategy:
matrix:
python-version: [3.8, 3.11]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
# https://github.com/marketplace/actions/setup-miniconda
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ env.PYTHON_VERSION }}
python-version: ${{ matrix.python-version }}

# -------------------------------------------------------------------
# Checkout icpp-llm
- name: checkout icpp-llm
uses: actions/checkout@v3
# Checkout llama_cpp_canister & llama_cpp_onicai_fork as nested directory
- name: checkout llama_cpp_canister
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: checkout llama_cpp_onicai_fork
uses: actions/checkout@v4
with:
repository: onicai/llama_cpp_onicai_fork
path: src/llama_cpp_onicai_fork
fetch-depth: 0
submodules: 'recursive'
# -------------------------------------------------------------------

- name: install
Expand All @@ -41,17 +55,19 @@ jobs:
make install-dfx
make install-python
make install-clang-ubuntu
make install-jp
make install-jp-ubuntu

- name: versions
shell: bash -l {0}
run: |
echo "icpp --version: $(icpp --version)"
echo "clang++ --version: $(clang++ --version)"
echo "g++ --version: $(g++ --version)"
#echo "wasm2wat version: $(wasm2wat --version)"
echo "pip version : $(pip --version)"
echo "python version : $(python --version)"
echo "jp version : $(jp --version)"
#echo "rustc version : $(rustc --version)"
echo "dfx version : $(dfx --version)"
echo "Ensure conda works properly"
conda info
Expand All @@ -65,11 +81,11 @@ jobs:
echo "Installing wasi-sdk"
icpp install-wasi-sdk

- name: download models
- name: install-rust
shell: bash -l {0}
run: |
make icpp_llama2_get_stories15M
make icpp_llama2_get_stories260K
echo "Installing rust"
icpp install-rust

- name: all-tests
shell: bash -l {0}
Expand Down
64 changes: 33 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,12 @@ CLANG_TIDY = $(ICPP_COMPILER_ROOT)/bin/clang-tidy
# CI/CD - Phony Makefile targets
#
.PHONY: all-tests
all-tests: all-static test-all-llms

# TODO: change to gguf from llama_cpp_... of onicai's huggingface repo
.PHONY: icpp_llama2_get_stories260K
icpp_llama2_get_stories260K:
cd icpp_llama2 && \
mkdir -p stories260K && \
wget -P stories260K https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin && \
wget -P stories260K https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin

# TODO: change to gguf from llama_cpp_... of onicai's huggingface repo
.PHONY: icpp_llama2_get_stories15M
icpp_llama2_get_stories15M:
cd icpp_llama2 && \
mkdir -p models && \
wget -P models https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin
all-tests: all-static test-llm-wasm test-llm-native

.PHONY: build-info-cpp
build-info-cpp:
echo "Creating src/llama_cpp_onicai_fork/common/build-info.cpp"
@sh src/llama_cpp_onicai_fork/scripts/build-info.sh clang > src/llama_cpp_onicai_fork/common/build-info.cpp

.PHONY: summary
summary:
Expand All @@ -75,19 +65,24 @@ summary:
@echo ICPP_COMPILER_ROOT=$(ICPP_COMPILER_ROOT)
@echo "-------------------------------------------------------------"

# TODO: change to testing llama_cpp
.PHONY: test-all-llms
test-all-llms:
.PHONY: test-llm-native
test-llm-native:
dfx identity use default
build-info-cpp
icpp build-native
./build-native/mockic.exe

.PHONY: test-llm-wasm
test-llm-wasm:
dfx identity use default
@echo "#########################################"
@echo "####### testing icpp_llama2 #############"
@echo "#########################################"
cd icpp_llama2 && \
icpp build-native && \
./build-native/mockic.exe && \
./demo.sh && \
pytest && \
dfx stop
build-info-cpp
icpp build-wasm
dfx stop
dfx start --clean --background
dfx deploy
python -m scripts.upload models/stories260Ktok512.gguf
pytest -vv
dfx stop

.PHONY: all-static
all-static: \
Expand Down Expand Up @@ -164,11 +159,18 @@ install-didc:
@echo "Installed successfully in:"
@echo /usr/local/bin/didc

# TODO: update as in icpp-pro, for ubuntu & mac
.PHONY: install-jp
install-jp:
.PHONY: install-jp-ubuntu
install-jp-ubuntu:
sudo apt-get update && sudo apt-get install jp

.PHONY: install-jp-mac
install-jp-mac:
brew install jp

.PHONY: install-homebrew-mac
install-homebrew-mac:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

.PHONY: install-python
install-python:
pip install --upgrade pip
Expand Down
Loading

0 comments on commit 5a9d853

Please sign in to comment.