Skip to content

Commit 7675ac6

Browse files
author
Olivier Chafik
committed
Merge remote-tracking branch 'origin/master' into agent-example
2 parents b4a00ce + a68a1e7 commit 7675ac6

File tree

99 files changed

+6606
-1633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+6606
-1633
lines changed

.devops/main-intel.Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ WORKDIR /app
1010

1111
COPY . .
1212

13-
RUN mkdir build && \
14-
cd build && \
15-
if [ "${LLAMA_SYCL_F16}" = "ON" ]; then \
13+
RUN if [ "${LLAMA_SYCL_F16}" = "ON" ]; then \
1614
echo "LLAMA_SYCL_F16 is set" && \
1715
export OPT_SYCL_F16="-DLLAMA_SYCL_F16=ON"; \
1816
fi && \
19-
cmake .. -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ${OPT_SYCL_F16} && \
20-
cmake --build . --config Release --target main
17+
cmake -B build -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ${OPT_SYCL_F16} && \
18+
cmake --build build --config Release --target main
2119

2220
FROM intel/oneapi-basekit:$ONEAPI_VERSION as runtime
2321

.devops/main-vulkan.Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ RUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key
1414
# Build it
1515
WORKDIR /app
1616
COPY . .
17-
RUN mkdir build && \
18-
cd build && \
19-
cmake .. -DLLAMA_VULKAN=1 && \
20-
cmake --build . --config Release --target main
17+
RUN cmake -B build -DLLAMA_VULKAN=1 && \
18+
cmake --build build --config Release --target main
2119

2220
# Clean up
2321
WORKDIR /

.devops/server-intel.Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ WORKDIR /app
1010

1111
COPY . .
1212

13-
RUN mkdir build && \
14-
cd build && \
15-
if [ "${LLAMA_SYCL_F16}" = "ON" ]; then \
13+
RUN if [ "${LLAMA_SYCL_F16}" = "ON" ]; then \
1614
echo "LLAMA_SYCL_F16 is set" && \
1715
export OPT_SYCL_F16="-DLLAMA_SYCL_F16=ON"; \
1816
fi && \
19-
cmake .. -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_CURL=ON ${OPT_SYCL_F16} && \
20-
cmake --build . --config Release --target server
17+
cmake -B build -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_CURL=ON ${OPT_SYCL_F16} && \
18+
cmake --build build --config Release --target server
2119

2220
FROM intel/oneapi-basekit:$ONEAPI_VERSION as runtime
2321

.devops/server-vulkan.Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ RUN apt-get update && \
1818
# Build it
1919
WORKDIR /app
2020
COPY . .
21-
RUN mkdir build && \
22-
cd build && \
23-
cmake .. -DLLAMA_VULKAN=1 -DLLAMA_CURL=1 && \
24-
cmake --build . --config Release --target server
21+
RUN cmake -B build -DLLAMA_VULKAN=1 -DLLAMA_CURL=1 && \
22+
cmake --build build --config Release --target server
2523

2624
# Clean up
2725
WORKDIR /

.github/workflows/bench.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ jobs:
9696
id: cmake_build
9797
run: |
9898
set -eux
99-
mkdir build
100-
cd build
101-
cmake .. \
99+
cmake -B build \
102100
-DLLAMA_NATIVE=OFF \
103101
-DLLAMA_BUILD_SERVER=ON \
104102
-DLLAMA_CURL=ON \
@@ -109,7 +107,7 @@ jobs:
109107
-DLLAMA_FATAL_WARNINGS=OFF \
110108
-DLLAMA_ALL_WARNINGS=OFF \
111109
-DCMAKE_BUILD_TYPE=Release;
112-
cmake --build . --config Release -j $(nproc) --target server
110+
cmake --build build --config Release -j $(nproc) --target server
113111
114112
- name: Download the dataset
115113
id: download_dataset

.github/workflows/build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,63 @@ jobs:
593593
run: |
594594
make swift
595595
596+
windows-msys2:
597+
runs-on: windows-latest
598+
599+
strategy:
600+
fail-fast: false
601+
matrix:
602+
include:
603+
- { sys: UCRT64, env: ucrt-x86_64, build: Release }
604+
- { sys: CLANG64, env: clang-x86_64, build: Release }
605+
606+
steps:
607+
- name: Clone
608+
uses: actions/checkout@v4
609+
610+
- name: Setup ${{ matrix.sys }}
611+
uses: msys2/setup-msys2@v2
612+
with:
613+
update: true
614+
msystem: ${{matrix.sys}}
615+
install: >-
616+
base-devel
617+
mingw-w64-${{matrix.env}}-toolchain
618+
mingw-w64-${{matrix.env}}-cmake
619+
mingw-w64-${{matrix.env}}-openblas
620+
621+
- name: Build using make
622+
shell: msys2 {0}
623+
run: |
624+
make -j $(nproc)
625+
626+
- name: Clean after building using make
627+
shell: msys2 {0}
628+
run: |
629+
make clean
630+
631+
- name: Build using make w/ OpenBLAS
632+
shell: msys2 {0}
633+
run: |
634+
make LLAMA_OPENBLAS=1 -j $(nproc)
635+
636+
- name: Build using CMake
637+
shell: msys2 {0}
638+
run: |
639+
cmake -B build
640+
cmake --build build --config ${{ matrix.build }} -j $(nproc)
641+
642+
- name: Clean after building using CMake
643+
shell: msys2 {0}
644+
run: |
645+
rm -rf build
646+
647+
- name: Build using CMake w/ OpenBLAS
648+
shell: msys2 {0}
649+
run: |
650+
cmake -B build -DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS
651+
cmake --build build --config ${{ matrix.build }} -j $(nproc)
652+
596653
windows-latest-cmake:
597654
runs-on: windows-latest
598655

.github/workflows/python-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
uses: py-actions/flake8@v2
2222
with:
2323
ignore: "E203,E211,E221,E225,E231,E241,E251,E261,E266,E501,E701,E704,W503"
24-
exclude: "examples/*,examples/*/**,*/**/__init__.py"
24+
exclude: "examples/*,examples/*/**,*/**/__init__.py,convert-hf-to-gguf-update.py"

.github/workflows/server.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,16 @@ jobs:
4141
sanitizer: ""
4242
fail-fast: false # While -DLLAMA_SANITIZE_THREAD=ON is broken
4343

44-
container:
45-
image: ubuntu:latest
46-
ports:
47-
- 8888
48-
options: --cpus 4
49-
5044
steps:
5145
- name: Dependencies
5246
id: depends
5347
run: |
54-
apt-get update
55-
apt-get -y install \
48+
sudo apt-get update
49+
sudo apt-get -y install \
5650
build-essential \
5751
xxd \
5852
git \
5953
cmake \
60-
python3-pip \
61-
python3-venv \
6254
curl \
6355
wget \
6456
language-pack-en \
@@ -71,6 +63,17 @@ jobs:
7163
fetch-depth: 0
7264
ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
7365

66+
- name: Python setup
67+
id: setup_python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: '3.11'
71+
72+
- name: Tests dependencies
73+
id: test_dependencies
74+
run: |
75+
pip install -r examples/server/tests/requirements.txt
76+
7477
- name: Verify server deps
7578
id: verify_server_deps
7679
run: |
@@ -91,23 +94,14 @@ jobs:
9194
- name: Build
9295
id: cmake_build
9396
run: |
94-
mkdir build
95-
cd build
96-
cmake .. \
97+
cmake -B build \
9798
-DLLAMA_NATIVE=OFF \
9899
-DLLAMA_BUILD_SERVER=ON \
99100
-DLLAMA_CURL=ON \
100101
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
101102
-DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
102-
cmake --build . --config ${{ matrix.build_type }} -j $(nproc) --target server
103+
cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target server
103104
104-
- name: Setup python env
105-
id: pipenv
106-
run: |
107-
cd examples/server/tests
108-
python3 -m venv venv
109-
. venv/bin/activate
110-
pip install -r requirements.txt
111105
112106
- name: Tests
113107
id: server_integration_tests
@@ -133,6 +127,7 @@ jobs:
133127
uses: actions/checkout@v4
134128
with:
135129
fetch-depth: 0
130+
ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
136131

137132
- name: libCURL
138133
id: get_libcurl
@@ -146,10 +141,8 @@ jobs:
146141
- name: Build
147142
id: cmake_build
148143
run: |
149-
mkdir build
150-
cd build
151-
cmake .. -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
152-
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} --target server
144+
cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
145+
cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target server
153146
154147
- name: Python setup
155148
id: setup_python

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.a
33
*.so
44
*.gguf
5+
*.gguf.json
56
*.bin
67
*.exe
78
*.dll
@@ -108,3 +109,18 @@ examples/server/*.mjs.hpp
108109
poetry.lock
109110
poetry.toml
110111
nppBackup
112+
113+
# Test binaries
114+
/tests/test-grammar-parser
115+
/tests/test-llama-grammar
116+
/tests/test-double-float
117+
/tests/test-grad0
118+
/tests/test-opt
119+
/tests/test-quantize-fns
120+
/tests/test-quantize-perf
121+
/tests/test-sampling
122+
/tests/test-tokenizer-0
123+
/tests/test-tokenizer-1-spm
124+
/tests/test-tokenizer-1-bpe
125+
/tests/test-rope
126+
/tests/test-backend-ops

Makefile

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,23 @@ BUILD_TARGETS = \
66

77
# Binaries only useful for tests
88
TEST_TARGETS = \
9-
tests/test-llama-grammar tests/test-grammar-parser tests/test-double-float tests/test-grad0 tests/test-opt \
10-
tests/test-quantize-fns tests/test-quantize-perf tests/test-sampling tests/test-tokenizer-0-llama \
11-
tests/test-tokenizer-0-falcon tests/test-tokenizer-1-llama tests/test-tokenizer-1-bpe tests/test-rope \
12-
tests/test-backend-ops tests/test-model-load-cancel tests/test-autorelease \
13-
tests/test-json-schema-to-grammar tests/test-grammar-integration
9+
tests/test-autorelease \
10+
tests/test-backend-ops \
11+
tests/test-double-float \
12+
tests/test-grad0 \
13+
tests/test-grammar-integration \
14+
tests/test-grammar-parser \
15+
tests/test-json-schema-to-grammar \
16+
tests/test-llama-grammar \
17+
tests/test-model-load-cancel \
18+
tests/test-opt \
19+
tests/test-quantize-fns \
20+
tests/test-quantize-perf \
21+
tests/test-rope \
22+
tests/test-sampling \
23+
tests/test-tokenizer-0 \
24+
tests/test-tokenizer-1-bpe \
25+
tests/test-tokenizer-1-spm
1426

1527
# Code coverage output files
1628
COV_TARGETS = *.gcno tests/*.gcno *.gcda tests/*.gcda *.gcov tests/*.gcov lcov-report gcovr-report
@@ -27,6 +39,17 @@ ifndef UNAME_M
2739
UNAME_M := $(shell uname -m)
2840
endif
2941

42+
# In GNU make default CXX is g++ instead of c++. Let's fix that so that users
43+
# of non-gcc compilers don't have to provide g++ alias or wrapper.
44+
DEFCC := cc
45+
DEFCXX := c++
46+
ifeq ($(origin CC),default)
47+
CC := $(DEFCC)
48+
endif
49+
ifeq ($(origin CXX),default)
50+
CXX := $(DEFCXX)
51+
endif
52+
3053
# Mac OS + Arm can report x86_64
3154
# ref: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789
3255
ifeq ($(UNAME_S),Darwin)
@@ -49,11 +72,17 @@ default: $(BUILD_TARGETS)
4972
test: $(TEST_TARGETS)
5073
@failures=0; \
5174
for test_target in $(TEST_TARGETS); do \
52-
if [ "$$test_target" = "tests/test-tokenizer-0-llama" ]; then \
53-
./$$test_target $(CURDIR)/models/ggml-vocab-llama.gguf; \
54-
elif [ "$$test_target" = "tests/test-tokenizer-0-falcon" ]; then \
75+
if [ "$$test_target" = "tests/test-tokenizer-0" ]; then \
76+
./$$test_target $(CURDIR)/models/ggml-vocab-llama-spm.gguf; \
77+
./$$test_target $(CURDIR)/models/ggml-vocab-llama-bpe.gguf; \
78+
./$$test_target $(CURDIR)/models/ggml-vocab-phi-3.gguf; \
5579
./$$test_target $(CURDIR)/models/ggml-vocab-falcon.gguf; \
56-
elif [ "$$test_target" = "tests/test-tokenizer-1-llama" ]; then \
80+
./$$test_target $(CURDIR)/models/ggml-vocab-deepseek-coder.gguf; \
81+
./$$test_target $(CURDIR)/models/ggml-vocab-deepseek-llm.gguf; \
82+
./$$test_target $(CURDIR)/models/ggml-vocab-bert-bge.gguf; \
83+
./$$test_target $(CURDIR)/models/ggml-vocab-starcoder.gguf; \
84+
./$$test_target $(CURDIR)/models/ggml-vocab-gpt-2.gguf; \
85+
elif [ "$$test_target" = "tests/test-tokenizer-1-spm" ]; then \
5786
continue; \
5887
elif [ "$$test_target" = "tests/test-tokenizer-1-bpe" ]; then \
5988
continue; \
@@ -971,19 +1000,15 @@ tests/test-sampling: tests/test-sampling.cpp ggml.o llama.o $(OBJS)
9711000
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
9721001
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
9731002

974-
tests/test-tokenizer-0-falcon: tests/test-tokenizer-0-falcon.cpp ggml.o llama.o $(COMMON_DEPS) console.o $(OBJS)
975-
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
976-
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
977-
978-
tests/test-tokenizer-0-llama: tests/test-tokenizer-0-llama.cpp ggml.o llama.o $(COMMON_DEPS) console.o $(OBJS)
1003+
tests/test-tokenizer-0: tests/test-tokenizer-0.cpp ggml.o llama.o $(COMMON_DEPS) console.o $(OBJS)
9791004
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
9801005
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
9811006

9821007
tests/test-tokenizer-1-bpe: tests/test-tokenizer-1-bpe.cpp ggml.o llama.o $(COMMON_DEPS) console.o $(OBJS)
9831008
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
9841009
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
9851010

986-
tests/test-tokenizer-1-llama: tests/test-tokenizer-1-llama.cpp ggml.o llama.o $(COMMON_DEPS) console.o $(OBJS)
1011+
tests/test-tokenizer-1-spm: tests/test-tokenizer-1-spm.cpp ggml.o llama.o $(COMMON_DEPS) console.o $(OBJS)
9871012
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
9881013
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
9891014

0 commit comments

Comments
 (0)