Skip to content

Commit 9c2cc11

Browse files
author
ochafik
committed
Merge remote-tracking branch 'origin/master' into json-type
2 parents 4de4dc0 + b5a5f34 commit 9c2cc11

File tree

144 files changed

+50792
-43174
lines changed

Some content is hidden

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

144 files changed

+50792
-43174
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ indent_size = 2
2626

2727
[examples/llama.swiftui/llama.swiftui.xcodeproj/*]
2828
indent_style = tab
29+
30+
[examples/cvector-generator/*.txt]
31+
trim_trailing_whitespace = unset
32+
insert_final_newline = unset

.github/labeler.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ build:
4242
- cmake/**
4343
- CMakeLists.txt
4444
- CMakePresets.json
45-
- codecov.yml
4645
examples:
4746
- changed-files:
4847
- any-glob-to-any-file: examples/**

.github/pull_request_template.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
- Self Reported Review Complexity:
2-
- [ ] Review Complexity : Low
3-
- [ ] Review Complexity : Medium
4-
- [ ] Review Complexity : High
5-
- [ ] I have read the [contributing guidelines](https://github.com/ggerganov/llama.cpp/blob/master/CONTRIBUTING.md)
1+
2+
3+
- [x] I have read the [contributing guidelines](https://github.com/ggerganov/llama.cpp/blob/master/CONTRIBUTING.md)
4+
- Self-reported review complexity:
5+
- [ ] Low
6+
- [ ] Medium
7+
- [ ] High

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
name: llama-bin-macos-arm64.zip
8585

8686
macOS-latest-cmake-x64:
87-
runs-on: macos-latest
87+
runs-on: macos-12
8888

8989
steps:
9090
- name: Clone

.github/workflows/code-coverage.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/server.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,22 @@ jobs:
8787
exit 1
8888
fi
8989
90+
- name: Build (no OpenMP)
91+
id: cmake_build_no_openmp
92+
if: ${{ matrix.sanitizer == 'THREAD' }}
93+
run: |
94+
cmake -B build \
95+
-DLLAMA_NATIVE=OFF \
96+
-DLLAMA_BUILD_SERVER=ON \
97+
-DLLAMA_CURL=ON \
98+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
99+
-DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
100+
-DLLAMA_OPENMP=OFF ;
101+
cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
102+
90103
- name: Build
91104
id: cmake_build
105+
if: ${{ matrix.sanitizer != 'THREAD' }}
92106
run: |
93107
cmake -B build \
94108
-DLLAMA_NATIVE=OFF \

.gitignore

Lines changed: 71 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,123 @@
1-
*.o
1+
# Extensions
2+
23
*.a
3-
*.so
4-
*.gguf
5-
*.gguf.json
4+
*.bat
65
*.bin
7-
*.exe
86
*.dll
9-
*.log
10-
*.gcov
11-
*.gcno
12-
*.gcda
137
*.dot
14-
*.bat
15-
*.tmp
16-
*.metallib
178
*.etag
9+
*.exe
10+
*.gcda
11+
*.gcno
12+
*.gcov
13+
*.gguf
14+
*.gguf.json
1815
*.lastModified
19-
.DS_Store
20-
.build/
16+
*.log
17+
*.metallib
18+
*.o
19+
*.so
20+
*.tmp
21+
22+
# IDE / OS
23+
2124
.cache/
2225
.ccls-cache/
2326
.direnv/
27+
.DS_Store
2428
.envrc
29+
.idea/
2530
.swiftpm
26-
.venv
27-
.clang-tidy
2831
.vs/
2932
.vscode/
30-
.idea/
33+
nppBackup
3134

32-
ggml-metal-embed.metal
3335

34-
lcov-report/
36+
# Coverage
37+
3538
gcovr-report/
39+
lcov-report/
40+
41+
# Build Artifacts
3642

3743
tags
44+
.build/
3845
build*
46+
!build-info.cmake
47+
!build-info.cpp.in
48+
!build-info.sh
3949
!build.zig
40-
cmake-build-*
50+
/libllama.so
51+
/llama-*
4152
android-ndk-*
53+
arm_neon.h
54+
cmake-build-*
55+
CMakeSettings.json
56+
compile_commands.json
57+
ggml-metal-embed.metal
58+
llama-batched-swift
4259
out/
4360
tmp/
4461

62+
# CI
63+
64+
!.github/workflows/*.yml
65+
66+
# Models
67+
4568
models/*
4669
models-mnt
70+
!models/.editorconfig
71+
!models/ggml-vocab-*.gguf*
4772

48-
/Pipfile
49-
/libllama.so
50-
/llama-*
51-
llama-batched-swift
52-
/common/build-info.cpp
53-
arm_neon.h
54-
compile_commands.json
55-
CMakeSettings.json
56-
57-
__pycache__
58-
dist
73+
# Zig
5974

6075
zig-out/
6176
zig-cache/
6277

78+
# Logs
79+
6380
ppl-*.txt
6481
qnt-*.txt
6582
perf-*.txt
6683

84+
# Examples
85+
6786
examples/jeopardy/results.txt
87+
examples/server/*.css.hpp
6888
examples/server/*.html.hpp
6989
examples/server/*.js.hpp
7090
examples/server/*.mjs.hpp
71-
examples/server/*.css.hpp
91+
!build_64.sh
92+
!examples/*.bat
93+
!examples/*/*.kts
94+
!examples/*/*/*.kts
95+
!examples/sycl/*.bat
96+
!examples/sycl/*.sh
7297

98+
# Python
99+
100+
__pycache__
101+
.venv
102+
/Pipfile
103+
dist
73104
poetry.lock
74105
poetry.toml
75-
nppBackup
76106

77107
# Test binaries
78-
/tests/test-grammar-parser
79-
/tests/test-llama-grammar
108+
/tests/test-backend-ops
80109
/tests/test-double-float
81110
/tests/test-grad0
111+
/tests/test-grammar-parser
112+
/tests/test-llama-grammar
82113
/tests/test-opt
83114
/tests/test-quantize-fns
84115
/tests/test-quantize-perf
116+
/tests/test-rope
85117
/tests/test-sampling
86118
/tests/test-tokenizer-0
87-
/tests/test-tokenizer-1-spm
88119
/tests/test-tokenizer-1-bpe
89-
/tests/test-rope
90-
/tests/test-backend-ops
120+
/tests/test-tokenizer-1-spm
121+
122+
# Scripts
123+
!/scripts/install-oneapi.bat

CMakeLists.txt

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ endif()
3939

4040
if (APPLE)
4141
set(LLAMA_METAL_DEFAULT ON)
42+
set(LLAMA_BLAS_DEFAULT ON)
43+
set(LLAMA_BLAS_VENDOR_DEFAULT "Apple")
4244
else()
4345
set(LLAMA_METAL_DEFAULT OFF)
46+
set(LLAMA_BLAS_DEFAULT OFF)
47+
set(LLAMA_BLAS_VENDOR_DEFAULT "Generic")
4448
endif()
4549

4650
set(LLAMA_LLAMAFILE_DEFAULT ON)
@@ -91,9 +95,10 @@ endif()
9195

9296
# 3rd party libs
9397
option(LLAMA_ACCELERATE "llama: enable Accelerate framework" ON)
94-
option(LLAMA_BLAS "llama: use BLAS" OFF)
98+
option(LLAMA_BLAS "llama: use BLAS" ${LLAMA_BLAS_DEFAULT})
99+
set(LLAMA_BLAS_VENDOR ${LLAMA_BLAS_VENDOR_DEFAULT} CACHE STRING
100+
"llama: BLAS library vendor")
95101
option(LLAMA_LLAMAFILE "llama: use llamafile SGEMM" ${LLAMA_LLAMAFILE_DEFAULT})
96-
set(LLAMA_BLAS_VENDOR "Generic" CACHE STRING "llama: BLAS library vendor")
97102
option(LLAMA_CUDA "llama: use CUDA" OFF)
98103
option(LLAMA_CUBLAS "llama: use CUDA (deprecated, use LLAMA_CUDA)" OFF)
99104
option(LLAMA_CUDA_FORCE_DMMV "llama: use dmmv instead of mmvq CUDA kernels" OFF)
@@ -114,6 +119,7 @@ option(LLAMA_HIP_UMA "llama: use HIP unified memory arch
114119
option(LLAMA_VULKAN "llama: use Vulkan" OFF)
115120
option(LLAMA_VULKAN_CHECK_RESULTS "llama: run Vulkan op checks" OFF)
116121
option(LLAMA_VULKAN_DEBUG "llama: enable Vulkan debug output" OFF)
122+
option(LLAMA_VULKAN_MEMORY_DEBUG "llama: enable Vulkan memory debug output" OFF)
117123
option(LLAMA_VULKAN_VALIDATE "llama: enable Vulkan validation" OFF)
118124
option(LLAMA_VULKAN_RUN_TESTS "llama: run Vulkan tests" OFF)
119125
option(LLAMA_METAL "llama: use Metal" ${LLAMA_METAL_DEFAULT})
@@ -311,17 +317,17 @@ if (LLAMA_BLAS)
311317
if (LLAMA_STATIC)
312318
set(BLA_STATIC ON)
313319
endif()
314-
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
315-
set(BLA_SIZEOF_INTEGER 8)
316-
endif()
320+
#if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
321+
# set(BLA_SIZEOF_INTEGER 8)
322+
#endif()
317323

318324
set(BLA_VENDOR ${LLAMA_BLAS_VENDOR})
319325
find_package(BLAS)
320326

321327
if (BLAS_FOUND)
322328
message(STATUS "BLAS found, Libraries: ${BLAS_LIBRARIES}")
323329

324-
if ("${BLAS_INCLUDE_DIRS}" STREQUAL "")
330+
if (("${BLAS_INCLUDE_DIRS}" STREQUAL "") AND NOT (${LLAMA_BLAS_VENDOR} MATCHES "Apple"))
325331
# BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake.
326332
# see https://gitlab.kitware.com/cmake/cmake/-/issues/20268
327333
find_package(PkgConfig REQUIRED)
@@ -374,12 +380,15 @@ if (LLAMA_BLAS)
374380

375381
add_compile_options(${BLAS_LINKER_FLAGS})
376382

377-
add_compile_definitions(GGML_USE_OPENBLAS)
383+
add_compile_definitions(GGML_USE_BLAS)
378384

379385
if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${LLAMA_BLAS_VENDOR} MATCHES "Generic" OR ${LLAMA_BLAS_VENDOR} MATCHES "Intel"))
380386
add_compile_definitions(GGML_BLAS_USE_MKL)
381387
endif()
382388

389+
set(GGML_HEADERS_BLAS ggml-blas.h)
390+
set(GGML_SOURCES_BLAS ggml-blas.cpp)
391+
383392
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${BLAS_LIBRARIES})
384393
set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${BLAS_INCLUDE_DIRS})
385394
else()
@@ -526,6 +535,10 @@ if (LLAMA_VULKAN)
526535
add_compile_definitions(GGML_VULKAN_DEBUG)
527536
endif()
528537

538+
if (LLAMA_VULKAN_MEMORY_DEBUG)
539+
add_compile_definitions(GGML_VULKAN_MEMORY_DEBUG)
540+
endif()
541+
529542
if (LLAMA_VULKAN_VALIDATE)
530543
add_compile_definitions(GGML_VULKAN_VALIDATE)
531544
endif()
@@ -652,6 +665,7 @@ if (LLAMA_SYCL)
652665
#todo: AOT
653666

654667
find_package(IntelSYCL REQUIRED)
668+
find_package(MKL REQUIRED)
655669

656670
message(STATUS "SYCL found")
657671

@@ -666,21 +680,22 @@ if (LLAMA_SYCL)
666680
endif()
667681

668682
add_compile_options(-I./) #include DPCT
669-
add_compile_options(-I/${SYCL_INCLUDE_DIR})
670683

671684
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
672685
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
673-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -L${MKLROOT}/lib")
674686
if (LLAMA_SYCL_TARGET STREQUAL "NVIDIA")
675687
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
676688
endif()
677689

678690
set(GGML_HEADERS_SYCL ggml-sycl.h)
679-
set(GGML_SOURCES_SYCL ggml-sycl.cpp)
691+
file(GLOB GGML_SOURCES_SYCL "ggml-sycl/*.cpp")
692+
list(APPEND GGML_SOURCES_SYCL "ggml-sycl.cpp")
680693

681694
if (WIN32)
682-
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} -fsycl sycl7 OpenCL mkl_sycl_blas_dll.lib mkl_intel_ilp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib)
695+
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL)
683696
else()
697+
add_compile_options(-I/${SYCL_INCLUDE_DIR})
698+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -L${MKLROOT}/lib")
684699
if (LLAMA_SYCL_TARGET STREQUAL "INTEL")
685700
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} -fsycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
686701
elseif (LLAMA_SYCL_TARGET STREQUAL "NVIDIA")
@@ -1258,6 +1273,7 @@ add_library(ggml OBJECT
12581273
${GGML_SOURCES_KOMPUTE} ${GGML_HEADERS_KOMPUTE}
12591274
${GGML_SOURCES_VULKAN} ${GGML_HEADERS_VULKAN}
12601275
${GGML_SOURCES_ROCM} ${GGML_HEADERS_ROCM}
1276+
${GGML_SOURCES_BLAS} ${GGML_HEADERS_BLAS}
12611277
${GGML_SOURCES_LLAMAFILE} ${GGML_HEADERS_LLAMAFILE}
12621278
)
12631279

0 commit comments

Comments
 (0)