Skip to content

Commit d8b373c

Browse files
committed
Merge branch 'master' into grammar-token
2 parents 8f76ba5 + 917dc8c commit d8b373c

Some content is hidden

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

51 files changed

+12396
-7226
lines changed

.devops/nix/package.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ effectiveStdenv.mkDerivation (
214214
(cmakeBool "LLAMA_CUDA" useCuda)
215215
(cmakeBool "LLAMA_HIPBLAS" useRocm)
216216
(cmakeBool "LLAMA_METAL" useMetalKit)
217-
(cmakeBool "LLAMA_MPI" useMpi)
218217
(cmakeBool "LLAMA_VULKAN" useVulkan)
219218
(cmakeBool "LLAMA_STATIC" enableStatic)
220219
]

.github/labeler.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# https://github.com/actions/labeler
2+
3+
SYCL:
4+
- changed-files:
5+
- any-glob-to-any-file:
6+
- ggml-sycl.h
7+
- ggml-sycl.cpp
8+
- README-sycl.md
9+
Nvidia GPU:
10+
- changed-files:
11+
- any-glob-to-any-file:
12+
- ggml-cuda/**
13+
Vulkan:
14+
- changed-files:
15+
- any-glob-to-any-file:
16+
- ggml_vk_generate_shaders.py
17+
- ggml-vulkan*
18+
documentation:
19+
- changed-files:
20+
- any-glob-to-any-file:
21+
- docs/**
22+
- media/**
23+
testing:
24+
- changed-files:
25+
- any-glob-to-any-file:
26+
- tests/**
27+
build:
28+
- changed-files:
29+
- any-glob-to-any-file:
30+
- cmake/**
31+
- CMakeLists.txt
32+
- CMakePresets.json
33+
- codecov.yml
34+
examples:
35+
- changed-files:
36+
- any-glob-to-any-file: examples/**
37+
devops:
38+
- changed-files:
39+
- any-glob-to-any-file:
40+
- .devops/**
41+
- .github/**
42+
- ci/**
43+
python:
44+
- changed-files:
45+
- any-glob-to-any-file:
46+
- "**/*.py"
47+
- requirements/**
48+
- gguf-py/**
49+
- .flake8
50+
script:
51+
- changed-files:
52+
- any-glob-to-any-file:
53+
- scripts/**
54+
android:
55+
- changed-files:
56+
- any-glob-to-any-file:
57+
- examples/llama.android/**
58+
server:
59+
- changed-files:
60+
- any-glob-to-any-file:
61+
- examples/server/**
62+
ggml:
63+
- changed-files:
64+
- any-glob-to-any-file:
65+
- ggml-*.c
66+
- ggml-*.h
67+
- ggml-cuda/**
68+
nix:
69+
- changed-files:
70+
- any-glob-to-any-file:
71+
- "**/*.nix"
72+
- .github/workflows/nix-*.yml
73+
- .devops/nix/nixpkgs-instances.nix

.github/workflows/build.yml

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -271,49 +271,15 @@ jobs:
271271
path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
272272
name: llama-bin-ubuntu-x64.zip
273273

274-
# ubuntu-latest-cmake-sanitizer:
275-
# runs-on: ubuntu-latest
276-
#
277-
# continue-on-error: true
278-
#
279-
# strategy:
280-
# matrix:
281-
# sanitizer: [ADDRESS, THREAD, UNDEFINED]
282-
# build_type: [Debug, Release]
283-
#
284-
# steps:
285-
# - name: Clone
286-
# id: checkout
287-
# uses: actions/checkout@v4
288-
#
289-
# - name: Dependencies
290-
# id: depends
291-
# run: |
292-
# sudo apt-get update
293-
# sudo apt-get install build-essential
294-
#
295-
# - name: Build
296-
# id: cmake_build
297-
# run: |
298-
# mkdir build
299-
# cd build
300-
# cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
301-
# cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
302-
#
303-
# - name: Test
304-
# id: cmake_test
305-
# run: |
306-
# cd build
307-
# ctest -L main --verbose --timeout 900
308-
309-
ubuntu-latest-cmake-mpi:
274+
ubuntu-latest-cmake-sanitizer:
310275
runs-on: ubuntu-latest
311276

312277
continue-on-error: true
313278

314279
strategy:
315280
matrix:
316-
mpi_library: [mpich, libopenmpi-dev]
281+
sanitizer: [ADDRESS, THREAD, UNDEFINED]
282+
build_type: [Debug, Release]
317283

318284
steps:
319285
- name: Clone
@@ -324,21 +290,21 @@ jobs:
324290
id: depends
325291
run: |
326292
sudo apt-get update
327-
sudo apt-get install build-essential ${{ matrix.mpi_library }}
293+
sudo apt-get install build-essential
328294
329295
- name: Build
330296
id: cmake_build
331297
run: |
332298
mkdir build
333299
cd build
334-
cmake -DLLAMA_MPI=ON ..
335-
cmake --build . --config Release -j $(nproc)
300+
cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
301+
cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
336302
337303
- name: Test
338304
id: cmake_test
339305
run: |
340306
cd build
341-
ctest -L main --verbose
307+
ctest -L main --verbose --timeout 900
342308
343309
ubuntu-latest-cmake-rpc:
344310
runs-on: ubuntu-latest

.github/workflows/labeler.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Pull Request Labeler"
2+
on:
3+
- pull_request_target
4+
5+
jobs:
6+
labeler:
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
repository: "ggerganov/llama.cpp"
15+
- uses: actions/labeler@v5
16+
with:
17+
configuration-path: '.github/labeler.yml'

.github/workflows/server.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ jobs:
3232

3333
strategy:
3434
matrix:
35-
# TODO: temporary disabled due to linux kernel issues
36-
#sanitizer: [ADDRESS, THREAD, UNDEFINED]
37-
sanitizer: [UNDEFINED]
38-
build_type: [Debug]
35+
sanitizer: [ADDRESS, THREAD, UNDEFINED]
36+
build_type: [RelWithDebInfo]
3937
include:
4038
- build_type: Release
4139
sanitizer: ""
@@ -102,10 +100,8 @@ jobs:
102100
-DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
103101
cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target server
104102
105-
106103
- name: Tests
107104
id: server_integration_tests
108-
if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
109105
run: |
110106
cd examples/server/tests
111107
PORT=8888 ./tests.sh

CMakeLists.txt

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
1+
cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
22
project("llama.cpp" C CXX)
33
include(CheckIncludeFileCXX)
44

@@ -77,6 +77,7 @@ option(LLAMA_AVX2 "llama: enable AVX2"
7777
option(LLAMA_AVX512 "llama: enable AVX512" OFF)
7878
option(LLAMA_AVX512_VBMI "llama: enable AVX512-VBMI" OFF)
7979
option(LLAMA_AVX512_VNNI "llama: enable AVX512-VNNI" OFF)
80+
option(LLAMA_AVX512_BF16 "llama: enable AVX512-BF16" OFF)
8081
option(LLAMA_FMA "llama: enable FMA" ${INS_ENB})
8182
# in MSVC F16C is implied with AVX2/AVX512
8283
if (NOT MSVC)
@@ -122,7 +123,6 @@ set(LLAMA_METAL_MACOSX_VERSION_MIN "" CACHE STRING
122123
"llama: metal minimum macOS version")
123124
set(LLAMA_METAL_STD "" CACHE STRING "llama: metal standard version (-std flag)")
124125
option(LLAMA_KOMPUTE "llama: use Kompute" OFF)
125-
option(LLAMA_MPI "llama: use MPI" OFF)
126126
option(LLAMA_RPC "llama: use RPC" OFF)
127127
option(LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF)
128128
option(LLAMA_SYCL "llama: use SYCL" OFF)
@@ -134,6 +134,8 @@ set(LLAMA_SCHED_MAX_COPIES "4" CACHE STRING "llama: max input copies for pipeli
134134
option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
135135
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
136136
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
137+
option(LLAMA_LASX "llama: enable lasx" ON)
138+
option(LLAMA_LSX "llama: enable lsx" ON)
137139

138140
# add perf arguments
139141
option(LLAMA_PERF "llama: enable perf" OFF)
@@ -466,35 +468,6 @@ if (LLAMA_CUDA)
466468
endif()
467469
endif()
468470

469-
if (LLAMA_MPI)
470-
cmake_minimum_required(VERSION 3.10)
471-
find_package(MPI)
472-
if (MPI_C_FOUND)
473-
message(STATUS "MPI found")
474-
475-
set(GGML_HEADERS_MPI ggml-mpi.h)
476-
set(GGML_SOURCES_MPI ggml-mpi.c)
477-
478-
add_compile_definitions(GGML_USE_MPI)
479-
add_compile_definitions(${MPI_C_COMPILE_DEFINITIONS})
480-
481-
if (NOT MSVC)
482-
add_compile_options(-Wno-cast-qual)
483-
endif()
484-
485-
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${MPI_C_LIBRARIES})
486-
set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${MPI_C_INCLUDE_DIRS})
487-
488-
# Even if you're only using the C header, C++ programs may bring in MPI
489-
# C++ functions, so more linkage is needed
490-
if (MPI_CXX_FOUND)
491-
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${MPI_CXX_LIBRARIES})
492-
endif()
493-
else()
494-
message(WARNING "MPI not found")
495-
endif()
496-
endif()
497-
498471
if (LLAMA_RPC)
499472
add_compile_definitions(GGML_USE_RPC)
500473

@@ -1090,6 +1063,10 @@ elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" OR CMAKE_GENERATOR_PLATFORM_LW
10901063
add_compile_definitions($<$<COMPILE_LANGUAGE:C>:__AVX512VNNI__>)
10911064
add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:__AVX512VNNI__>)
10921065
endif()
1066+
if (LLAMA_AVX512_BF16)
1067+
add_compile_definitions($<$<COMPILE_LANGUAGE:C>:__AVX512BF16__>)
1068+
add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:__AVX512BF16__>)
1069+
endif()
10931070
elseif (LLAMA_AVX2)
10941071
list(APPEND ARCH_FLAGS /arch:AVX2)
10951072
elseif (LLAMA_AVX)
@@ -1121,6 +1098,9 @@ elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" OR CMAKE_GENERATOR_PLATFORM_LW
11211098
if (LLAMA_AVX512_VNNI)
11221099
list(APPEND ARCH_FLAGS -mavx512vnni)
11231100
endif()
1101+
if (LLAMA_AVX512_BF16)
1102+
list(APPEND ARCH_FLAGS -mavx512bf16)
1103+
endif()
11241104
endif()
11251105
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
11261106
message(STATUS "PowerPC detected")
@@ -1130,6 +1110,17 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
11301110
list(APPEND ARCH_FLAGS -mcpu=native -mtune=native)
11311111
#TODO: Add targets for Power8/Power9 (Altivec/VSX) and Power10(MMA) and query for big endian systems (ppc64/le/be)
11321112
endif()
1113+
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "loongarch64")
1114+
message(STATUS "loongarch64 detected")
1115+
1116+
list(APPEND ARCH_FLAGS -march=loongarch64)
1117+
if (LLAMA_LASX)
1118+
list(APPEND ARCH_FLAGS -mlasx)
1119+
endif()
1120+
if (LLAMA_LSX)
1121+
list(APPEND ARCH_FLAGS -mlsx)
1122+
endif()
1123+
11331124
else()
11341125
message(STATUS "Unknown architecture")
11351126
endif()
@@ -1218,7 +1209,6 @@ add_library(ggml OBJECT
12181209
${GGML_SOURCES_CUDA} ${GGML_HEADERS_CUDA}
12191210
${GGML_SOURCES_OPENCL} ${GGML_HEADERS_OPENCL}
12201211
${GGML_SOURCES_METAL} ${GGML_HEADERS_METAL}
1221-
${GGML_SOURCES_MPI} ${GGML_HEADERS_MPI}
12221212
${GGML_SOURCES_RPC} ${GGML_HEADERS_RPC}
12231213
${GGML_SOURCES_EXTRA} ${GGML_HEADERS_EXTRA}
12241214
${GGML_SOURCES_SYCL} ${GGML_HEADERS_SYCL}
@@ -1306,7 +1296,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LlamaConfig.cmake
13061296

13071297
set(GGML_PUBLIC_HEADERS "ggml.h" "ggml-alloc.h" "ggml-backend.h"
13081298
"${GGML_HEADERS_CUDA}" "${GGML_HEADERS_OPENCL}"
1309-
"${GGML_HEADERS_METAL}" "${GGML_HEADERS_MPI}" "${GGML_HEADERS_EXTRA}")
1299+
"${GGML_HEADERS_METAL}" "${GGML_HEADERS_EXTRA}")
13101300

13111301
set_target_properties(ggml PROPERTIES PUBLIC_HEADER "${GGML_PUBLIC_HEADERS}")
13121302
install(TARGETS ggml PUBLIC_HEADER)

Makefile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ ifneq ($(filter ppc64le%,$(UNAME_M)),)
379379
CUDA_POWER_ARCH = 1
380380
endif
381381

382+
ifneq ($(filter loongarch64%,$(UNAME_M)),)
383+
MK_CFLAGS += -mlasx
384+
MK_CXXFLAGS += -mlasx
385+
endif
386+
382387
else
383388
MK_CFLAGS += -march=rv64gcv -mabi=lp64d
384389
MK_CXXFLAGS += -march=rv64gcv -mabi=lp64d
@@ -399,13 +404,6 @@ ifndef LLAMA_NO_ACCELERATE
399404
endif
400405
endif # LLAMA_NO_ACCELERATE
401406

402-
ifdef LLAMA_MPI
403-
MK_CPPFLAGS += -DGGML_USE_MPI
404-
MK_CFLAGS += -Wno-cast-qual
405-
MK_CXXFLAGS += -Wno-cast-qual
406-
OBJS += ggml-mpi.o
407-
endif # LLAMA_MPI
408-
409407
ifdef LLAMA_OPENBLAS
410408
MK_CPPFLAGS += -DGGML_USE_OPENBLAS $(shell pkg-config --cflags-only-I openblas)
411409
MK_CFLAGS += $(shell pkg-config --cflags-only-other openblas)
@@ -629,11 +627,6 @@ ggml-metal-embed.o: ggml-metal.metal ggml-common.h
629627
endif
630628
endif # LLAMA_METAL
631629

632-
ifdef LLAMA_MPI
633-
ggml-mpi.o: ggml-mpi.c ggml-mpi.h
634-
$(CC) $(CFLAGS) -c $< -o $@
635-
endif # LLAMA_MPI
636-
637630
ifndef LLAMA_NO_LLAMAFILE
638631
sgemm.o: sgemm.cpp sgemm.h ggml.h
639632
$(CXX) $(CXXFLAGS) -c $< -o $@

0 commit comments

Comments
 (0)