Skip to content

Commit

Permalink
feat: Update sampling API for llama.cpp (#1742)
Browse files Browse the repository at this point in the history
* Initial samplng api update

* Fix logger

* Update tests

* Update

* Remove seed

* Add sampling chain

* Remove unnused test

* Use Qwen2 0.5B for ci tests

* Fix typo

* Fix typo

* Update cache version

* Use real model for tests

* Add huggingface-hub as a test dependency

* Remove RUST_LOG=trace

* Add actual logit processor test
  • Loading branch information
abetlen authored Sep 19, 2024
1 parent a4e1451 commit f8fcb3e
Show file tree
Hide file tree
Showing 10 changed files with 1,035 additions and 2,083 deletions.
81 changes: 54 additions & 27 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Tests

on:
pull_request:
branches:
Expand All @@ -8,14 +7,34 @@ on:
branches:
- main

env:
REPO_ID: Qwen/Qwen2-0.5B-Instruct-GGUF
MODEL_FILE: qwen2-0_5b-instruct-q8_0.gguf

jobs:
build-linux:
download-model:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install huggingface-hub
run: pip install huggingface-hub
- name: Download model
run: huggingface-cli download ${{ env.REPO_ID }} ${{ env.MODEL_FILE }}
- name: Cache model
uses: actions/cache@v4
with:
path: ~/.cache/huggingface/hub
key: ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}

build-linux:
needs: download-model
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -26,36 +45,35 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Restore model cache
uses: actions/cache@v3
with:
path: ~/.cache/huggingface/hub
key: ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
- name: Install dependencies (Linux/MacOS)
if: runner.os != 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install uv
RUST_LOG=trace python -m uv pip install -e .[all] --verbose
python -m uv pip install -e .[all] --verbose
shell: bash

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
env:
RUST_LOG: trace
run: |
python -m pip install --upgrade pip
python -m pip install uv
python -m uv pip install -e .[all] --verbose
shell: cmd

shell: cmd
- name: Test with pytest
run: |
python -m pytest
build-windows:

needs: download-model
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -66,19 +84,23 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Restore model cache
uses: actions/cache@v3
with:
path: ~/.cache/huggingface/hub
key: ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}

- name: Install dependencies (Linux/MacOS)
if: runner.os != 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install uv
RUST_LOG=trace python -m uv pip install -e .[all] --verbose
python -m uv pip install -e .[all] --verbose
shell: bash

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
env:
RUST_LOG: trace
run: |
python -m pip install --upgrade pip
python -m pip install uv
Expand All @@ -90,12 +112,11 @@ jobs:
python -m pytest
build-macos:

needs: download-model
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -106,34 +127,36 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Restore model cache
uses: actions/cache@v3
with:
path: ~/.cache/huggingface/hub
key: ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}

- name: Install dependencies (Linux/MacOS)
if: runner.os != 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install uv
RUST_LOG=trace python -m uv pip install -e .[all] --verbose
python -m uv pip install -e .[all] --verbose
shell: bash

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
env:
RUST_LOG: trace
run: |
python -m pip install --upgrade pip
python -m pip install uv
python -m uv pip install -e .[all] --verbose
shell: cmd
shell: cmd

- name: Test with pytest
run: |
python -m pytest
build-macos-metal:

needs: download-model
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -144,18 +167,22 @@ jobs:
with:
python-version: "3.9"

- name: Restore model cache
uses: actions/cache@v3
with:
path: ~/.cache/huggingface/hub
key: ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}

- name: Install dependencies (Linux/MacOS)
if: runner.os != 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install uv
RUST_LOG=trace CMAKE_ARGS="-DLLAMA_METAL=on" python -m uv pip install .[all] --verbose
CMAKE_ARGS="-DLLAMA_METAL=on" python -m uv pip install .[all] --verbose
shell: bash

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
env:
RUST_LOG: trace
run: |
python -m pip install --upgrade pip
CMAKE_ARGS="-DGGML_METAL=on" python -m pip install .[all] --verbose
Expand Down
Loading

0 comments on commit f8fcb3e

Please sign in to comment.