Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #59 from casperdcl/ci-fun
Browse files Browse the repository at this point in the history
add CI build matrix, refactoring, linting
  • Loading branch information
filopedraz authored Jul 27, 2023
2 parents dd36f1f + afd6d3f commit 51843d1
Show file tree
Hide file tree
Showing 49 changed files with 497 additions and 457 deletions.
72 changes: 50 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
name: CI

env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: "enabled"
COMPOSE_DOCKER_CLI_BUILD: 1

on:
pull_request:
branches: ["main"]

push:
branches: ["main"]

pull_request:
jobs:
linter:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: list
name: List modified models
run: |
git diff --stat HEAD~1
echo "modified=$(
for model in $(ls -d *-*); do
git diff --quiet HEAD~1 -- $model || echo $model
done | sort | jq -Rsc 'split("\n")[:-1]'
)" >> $GITHUB_OUTPUT
outputs:
models: ${{ steps.list.outputs.modified }}
build-test-push:
needs: setup
runs-on: [self-hosted, gpu]
strategy:
fail-fast: false # TODO: remove
matrix:
model: ${{ fromJson(needs.setup.outputs.models) }}
env:
VERSION: '1.0.0'
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
COMPOSE_DOCKER_CLI_BUILD: 1
steps:
- uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: ./build.sh ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && '--push' || '--load' }}
working-directory: ${{ matrix.model }}
env:
# can't load cross-CPU-platform
BUILDX_PLATFORM: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && 'linux/arm64,linux/amd64' || 'linux/amd64' }}
# can't test cross-CPU-platform
TESTS_SKIP_CPU: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && '1' || '' }}
# avoid OoM errors (TODO: remove when using larger GPU)
TESTS_SKIP_GPU: ${{ contains(fromJSON('["a2t-whisper","cht-dolly-v2","cht-gorilla","cht-llama-v2","cht-mpt","cht-xgen","dfs-dalle","dfs-diffusers"]'), matrix.model) && '1' || '' }}
pass:
needs: build-test-push
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Run pre-commit
uses: pre-commit/action@v3.0.0
- run: echo success
69 changes: 37 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
exclude: "^docs/|/migrations/"
default_stages: [commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: end-of-file-fixer
- id: check-toml
- id: check-xml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: ["--config=setup.cfg"]
additional_dependencies: [flake8-isort]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-broken-line
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-isort
- flake8-pyproject
- flake8-string-format
ci:
autoupdate_schedule: weekly
skip: []
Expand Down
Empty file removed a2t-whisper/README.md
Empty file.
26 changes: 26 additions & 0 deletions a2t-whisper/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
export VERSION=1.0.1

IMAGE=ghcr.io/premai-io/audio-to-text-whisper-tiny-cpu
docker buildx build ${@:1} \
--file ./docker/cpu/Dockerfile \
--build-arg="MODEL_ID=tiny" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
--platform ${BUILDX_PLATFORM:-linux/arm64,linux/amd64} \
.
if test -z $TESTS_SKIP_CPU; then
docker run --rm $IMAGE:$VERSION pytest
fi

IMAGE=ghcr.io/premai-io/audio-to-text-whisper-large-v2-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=large-v2" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi
1 change: 0 additions & 1 deletion cdr-replit/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions cdr-replit/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e
export VERSION=1.0.0

IMAGE=ghcr.io/premai-io/coder-replit-code-v1-3b-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=replit/replit-code-v1-3b" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi
Empty file removed cdr-t5/README.md
Empty file.
15 changes: 15 additions & 0 deletions cdr-t5/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
export VERSION=1.0.0

IMAGE=ghcr.io/premai-io/coder-codet5p-220m-py-cpu
docker buildx build ${@:1} \
--file ./docker/cpu/Dockerfile \
--build-arg="MODEL_ID=Salesforce/codet5p-220m-py" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
--platform ${BUILDX_PLATFORM:-linux/arm64,linux/amd64} \
.
if test -z $TESTS_SKIP_CPU; then
docker run --rm $IMAGE:$VERSION pytest
fi
1 change: 0 additions & 1 deletion cht-dolly-v2/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions cht-dolly-v2/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e
export VERSION=1.0.3

IMAGE=ghcr.io/premai-io/chat-dolly-v2-12b-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=databricks/dolly-v2-12b" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi
1 change: 0 additions & 1 deletion cht-falcon/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions cht-falcon/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e
export VERSION=1.0.0

IMAGE=ghcr.io/premai-io/chat-falcon-7b-instruct-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=tiiuae/falcon-7b-instruct" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi
1 change: 0 additions & 1 deletion cht-gorilla/README.md

This file was deleted.

25 changes: 25 additions & 0 deletions cht-gorilla/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e
export VERSION=1.0.0

IMAGE=ghcr.io/premai-io/chat-gorilla-falcon-7b-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=gorilla-llm/gorilla-falcon-7b-hf-v0" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi

IMAGE=ghcr.io/premai-io/chat-gorilla-mpt-7b-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=gorilla-llm/gorilla-mpt-7b-hf-v0" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi
1 change: 0 additions & 1 deletion cht-llama-cpp/README.md

This file was deleted.

27 changes: 27 additions & 0 deletions cht-llama-cpp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e
export VERSION=1.0.4

IMAGE=ghcr.io/premai-io/chat-gpt4all-lora-q4-cpu
docker buildx build ${@:1} \
--file ./docker/cpu/Dockerfile \
--build-arg="MODEL_ID=gpt4all-lora-q4" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
--platform ${BUILDX_PLATFORM:-linux/arm64,linux/amd64} \
.
if test -z $TESTS_SKIP_CPU; then
docker run --rm $IMAGE:$VERSION pytest
fi

IMAGE=ghcr.io/premai-io/chat-vicuna-7b-q4-cpu
docker buildx build ${@:1} \
--file ./docker/cpu/Dockerfile \
--build-arg="MODEL_ID=vicuna-7b-q4" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
--platform ${BUILDX_PLATFORM:-linux/arm64,linux/amd64} \
.
if test -z $TESTS_SKIP_CPU; then
docker run --rm $IMAGE:$VERSION pytest
fi
7 changes: 5 additions & 2 deletions cht-llama-cpp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"gpt4all-lora-q4": {"modelWeightsName": "gpt4all-lora-q4.bin", "ctxMaxTokens": 512},
"vicuna-7b-q4": {"modelWeightsName": "vicuna-7b-q4.bin", "ctxMaxTokens": 512},
}
DEFAULT_N_THREADS = max(multiprocessing.cpu_count() // 2, 1)


def get_model_info() -> dict:
Expand Down Expand Up @@ -43,10 +44,12 @@ def generate(
n: int = 1,
stream: bool = False,
max_tokens: int = 256,
stop: list = [],
n_threads: int = max(multiprocessing.cpu_count() // 2, 1),
stop: list = None,
n_threads: int = DEFAULT_N_THREADS,
**kwargs,
):
if stop is None:
stop = []
messages = cls.reduce_number_of_messages(messages[::-1], max_tokens)[::-1]
cls.model.n_threads = n_threads
return cls.model.create_chat_completion(
Expand Down
1 change: 0 additions & 1 deletion cht-llama-v2/README.md

This file was deleted.

47 changes: 47 additions & 0 deletions cht-llama-v2/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -e
export VERSION=1.0.0

IMAGE=ghcr.io/premai-io/chat-llama-2-7b-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=llama-2-7b-hf" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi

IMAGE=ghcr.io/premai-io/chat-llama-2-7b-chat-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=llama-2-7b-chat-hf" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi

IMAGE=ghcr.io/premai-io/chat-llama-2-13b-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=llama-2-13b-hf" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi

IMAGE=ghcr.io/premai-io/chat-llama-2-13b-chat-gpu
docker buildx build ${@:1} \
--file ./docker/gpu/Dockerfile \
--build-arg="MODEL_ID=llama-2-13b-chat-hf" \
--tag $IMAGE:latest \
--tag $IMAGE:$VERSION \
.
if test -z $TESTS_SKIP_GPU; then
docker run --rm --gpus all $IMAGE:$VERSION pytest
fi
1 change: 0 additions & 1 deletion cht-mpt/README.md

This file was deleted.

Loading

0 comments on commit 51843d1

Please sign in to comment.