Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ jobs:
- name: checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install colorama

- name: Check Format
run: |
pip install black
Expand All @@ -37,6 +47,33 @@ jobs:
run: |
pip install numpy
pip install torch
pip install gguf

- name: Python Test
run: python scripts/python_test.py --cpu

- name: GGUF Generation Test
run: python scripts/gguf_test.py --mode gguf

- name: C++ Test on Linux
if: matrix.os == 'ubuntu-latest'
run: |
export LD_LIBRARY_PATH="$PWD/build/linux/x86_64/release:$LD_LIBRARY_PATH"
tests=(add gemm mul random_sample swiglu clip)
for t in "${tests[@]}"; do
build/linux/x86_64/release/infiniop-test \
test/infiniop-test/${t}.gguf \
--cpu \
--warmup 0 \
--run 0
done

- name: C++ Test on Windows
if: matrix.os == 'windows-latest'
run: |
$exe = ".\build\windows\x64\release\infiniop-test.exe"
$base = "test\infiniop-test"
$tests = @("add","gemm","mul","random_sample","swiglu","clip")
foreach ($t in $tests) {
& $exe "$base\$t.gguf" "--cpu" "--warmup" "0" "--run" "0"
}
43 changes: 43 additions & 0 deletions scripts/gguf_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import sys
import subprocess
from set_env import set_env
import argparse


PROJECT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
os.chdir(PROJECT_DIR)

def run(test, device, mode):
base = os.path.join(PROJECT_DIR, "test", "infiniop-test")
if mode in ("gguf", "all"):
if subprocess.run(f"python -m test_generate.testcases.{test}",
shell=True, cwd=base).returncode:
return f"{test}: gguf failed"
if mode in ("cpp", "all"):
exe = os.path.join(PROJECT_DIR, "build/linux/x86_64/release/infiniop-test")
gguf = os.path.join(base, f"{test}.gguf")
if subprocess.run(f"{exe} {gguf} --{device} --warmup 20 --run 1000",
shell=True, cwd=PROJECT_DIR).returncode:
return f"{test}: cpp failed"
return None

def main():
parser = argparse.ArgumentParser()
parser.add_argument("--device", nargs="?", default="cpu")
parser.add_argument("--mode", choices=["gguf", "cpp", "all"], default="all")
args = parser.parse_args()

set_env()
tests = ["add", "gemm", "mul", "random_sample", "swiglu", "clip"]
fails = [r for t in tests if (r := run(t, args.device, args.mode))]

if not fails:
print("\n\033[92mAll tests passed!\033[0m")
sys.exit(0)
print("\033[91mSome tests failed:\033[0m")
for f in fails: print(" -", f)
sys.exit(1)

if __name__ == "__main__":
main()
2 changes: 0 additions & 2 deletions test/infiniop-test/test_generate/testcases/add.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from ast import List
import numpy as np
import gguf
from typing import List
from numpy.lib.stride_tricks import as_strided

from .. import InfiniopTestWriter, InfiniopTestCase, np_dtype_to_ggml, gguf_strides, contiguous_gguf_strides, process_zero_stride_tensor

Expand Down
1 change: 0 additions & 1 deletion test/infiniop-test/test_generate/testcases/gemm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from ast import List
import numpy as np
import gguf
from typing import List
Expand Down
3 changes: 0 additions & 3 deletions test/infiniop-test/test_generate/testcases/random_sample.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from ast import List
import numpy as np
import gguf
from typing import List

from .. import InfiniopTestWriter, InfiniopTestCase, np_dtype_to_ggml, gguf_strides

Expand Down