Skip to content

Commit 2cfcbbe

Browse files
committed
Merge branch 'master' of https://github.com/JoanFM/llama.cpp into feat-jina-embeddings-v2-zh
2 parents afd76e6 + 01aec4a commit 2cfcbbe

File tree

201 files changed

+24710
-157140
lines changed

Some content is hidden

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

201 files changed

+24710
-157140
lines changed

.devops/full-cuda.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG CUDA_VERSION=11.7.1
66
# Target the CUDA build image
77
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
88

9-
FROM ${BASE_CUDA_DEV_CONTAINER} as build
9+
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
1010

1111
# Unless otherwise specified, we make a fat build.
1212
ARG CUDA_DOCKER_ARCH=all

.devops/full-rocm.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG ROCM_VERSION=5.6
66
# Target the CUDA build image
77
ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
88

9-
FROM ${BASE_ROCM_DEV_CONTAINER} as build
9+
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
1010

1111
# Unless otherwise specified, we make a fat build.
1212
# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878

.devops/full.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=22.04
22

3-
FROM ubuntu:$UBUNTU_VERSION as build
3+
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
66
apt-get install -y build-essential python3 python3-pip git libcurl4-openssl-dev libgomp1

.devops/llama-cli-cuda.Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VER
66
# Target the CUDA runtime image
77
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
88

9-
FROM ${BASE_CUDA_DEV_CONTAINER} as build
9+
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
1010

1111
# Unless otherwise specified, we make a fat build.
1212
ARG CUDA_DOCKER_ARCH=all
@@ -25,7 +25,7 @@ ENV GGML_CUDA=1
2525

2626
RUN make -j$(nproc) llama-cli
2727

28-
FROM ${BASE_CUDA_RUN_CONTAINER} as runtime
28+
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
2929

3030
RUN apt-get update && \
3131
apt-get install -y libgomp1

.devops/llama-cli-intel.Dockerfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG ONEAPI_VERSION=2024.1.1-devel-ubuntu22.04
22

3-
FROM intel/oneapi-basekit:$ONEAPI_VERSION as build
3+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS build
44

55
ARG GGML_SYCL_F16=OFF
66
RUN apt-get update && \
@@ -14,10 +14,12 @@ RUN if [ "${GGML_SYCL_F16}" = "ON" ]; then \
1414
echo "GGML_SYCL_F16 is set" && \
1515
export OPT_SYCL_F16="-DGGML_SYCL_F16=ON"; \
1616
fi && \
17-
cmake -B build -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ${OPT_SYCL_F16} && \
17+
echo "Building with static libs" && \
18+
cmake -B build -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx \
19+
${OPT_SYCL_F16} -DBUILD_SHARED_LIBS=OFF && \
1820
cmake --build build --config Release --target llama-cli
1921

20-
FROM intel/oneapi-basekit:$ONEAPI_VERSION as runtime
22+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS runtime
2123

2224
COPY --from=build /app/build/bin/llama-cli /llama-cli
2325

.devops/llama-cli-rocm.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG ROCM_VERSION=5.6
66
# Target the CUDA build image
77
ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
88

9-
FROM ${BASE_ROCM_DEV_CONTAINER} as build
9+
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
1010

1111
# Unless otherwise specified, we make a fat build.
1212
# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878

.devops/llama-cli-vulkan.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=jammy
22

3-
FROM ubuntu:$UBUNTU_VERSION as build
3+
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
# Install build tools
66
RUN apt update && apt install -y git build-essential cmake wget libgomp1

.devops/llama-cli.Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=22.04
22

3-
FROM ubuntu:$UBUNTU_VERSION as build
3+
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
66
apt-get install -y build-essential git
@@ -11,7 +11,7 @@ COPY . .
1111

1212
RUN make -j$(nproc) llama-cli
1313

14-
FROM ubuntu:$UBUNTU_VERSION as runtime
14+
FROM ubuntu:$UBUNTU_VERSION AS runtime
1515

1616
RUN apt-get update && \
1717
apt-get install -y libgomp1

.devops/llama-server-cuda.Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VER
66
# Target the CUDA runtime image
77
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
88

9-
FROM ${BASE_CUDA_DEV_CONTAINER} as build
9+
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
1010

1111
# Unless otherwise specified, we make a fat build.
1212
ARG CUDA_DOCKER_ARCH=all
@@ -27,7 +27,7 @@ ENV LLAMA_CURL=1
2727

2828
RUN make -j$(nproc) llama-server
2929

30-
FROM ${BASE_CUDA_RUN_CONTAINER} as runtime
30+
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
3131

3232
RUN apt-get update && \
3333
apt-get install -y libcurl4-openssl-dev libgomp1 curl

.devops/llama-server-intel.Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG ONEAPI_VERSION=2024.1.1-devel-ubuntu22.04
22

3-
FROM intel/oneapi-basekit:$ONEAPI_VERSION as build
3+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS build
44

55
ARG GGML_SYCL_F16=OFF
66
RUN apt-get update && \
@@ -14,10 +14,11 @@ RUN if [ "${GGML_SYCL_F16}" = "ON" ]; then \
1414
echo "GGML_SYCL_F16 is set" && \
1515
export OPT_SYCL_F16="-DGGML_SYCL_F16=ON"; \
1616
fi && \
17+
echo "Building with dynamic libs" && \
1718
cmake -B build -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_CURL=ON ${OPT_SYCL_F16} && \
1819
cmake --build build --config Release --target llama-server
1920

20-
FROM intel/oneapi-basekit:$ONEAPI_VERSION as runtime
21+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS runtime
2122

2223
RUN apt-get update && \
2324
apt-get install -y libcurl4-openssl-dev curl

.devops/llama-server-rocm.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG ROCM_VERSION=5.6
66
# Target the CUDA build image
77
ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
88

9-
FROM ${BASE_ROCM_DEV_CONTAINER} as build
9+
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
1010

1111
# Unless otherwise specified, we make a fat build.
1212
# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878

.devops/llama-server-vulkan.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=jammy
22

3-
FROM ubuntu:$UBUNTU_VERSION as build
3+
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
# Install build tools
66
RUN apt update && apt install -y git build-essential cmake wget

.devops/llama-server.Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=22.04
22

3-
FROM ubuntu:$UBUNTU_VERSION as build
3+
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
66
apt-get install -y build-essential git libcurl4-openssl-dev curl
@@ -13,7 +13,7 @@ ENV LLAMA_CURL=1
1313

1414
RUN make -j$(nproc) llama-server
1515

16-
FROM ubuntu:$UBUNTU_VERSION as runtime
16+
FROM ubuntu:$UBUNTU_VERSION AS runtime
1717

1818
RUN apt-get update && \
1919
apt-get install -y libcurl4-openssl-dev libgomp1

.devops/nix/apps.nix

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"llama-embedding"
1111
"llama-server"
1212
"llama-quantize"
13-
"llama-train-text-from-scratch"
1413
];
1514
mkApp = name: {
1615
type = "app";

.devops/nix/package.nix

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
vulkan-headers,
1919
vulkan-loader,
2020
curl,
21+
shaderc,
2122
useBlas ? builtins.all (x: !x) [
2223
useCuda
2324
useMetalKit
@@ -146,6 +147,7 @@ let
146147
vulkanBuildInputs = [
147148
vulkan-headers
148149
vulkan-loader
150+
shaderc
149151
];
150152
in
151153

.devops/tools.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ arg1="$1"
88
shift
99

1010
if [[ "$arg1" == '--convert' || "$arg1" == '-c' ]]; then
11-
python3 ./convert-hf-to-gguf.py "$@"
11+
python3 ./convert_hf_to_gguf.py "$@"
1212
elif [[ "$arg1" == '--quantize' || "$arg1" == '-q' ]]; then
1313
./llama-quantize "$@"
1414
elif [[ "$arg1" == '--run' || "$arg1" == '-r' ]]; then
1515
./llama-cli "$@"
16-
elif [[ "$arg1" == '--finetune' || "$arg1" == '-f' ]]; then
17-
./llama-finetune "$@"
1816
elif [[ "$arg1" == '--all-in-one' || "$arg1" == '-a' ]]; then
1917
echo "Converting PTH to GGML..."
2018
for i in `ls $1/$2/ggml-model-f16.bin*`; do
@@ -36,8 +34,6 @@ else
3634
echo " ex: --outtype f16 \"/models/7B/\" "
3735
echo " --quantize (-q): Optimize with quantization process ggml"
3836
echo " ex: \"/models/7B/ggml-model-f16.bin\" \"/models/7B/ggml-model-q4_0.bin\" 2"
39-
echo " --finetune (-f): Run finetune command to create a lora finetune of the model"
40-
echo " See documentation for finetune for command-line parameters"
4137
echo " --all-in-one (-a): Execute --convert & --quantize"
4238
echo " ex: \"/models/\" 7B"
4339
echo " --server (-s): Run a model on the server"

.github/labeler.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ SYCL:
1616
- any-glob-to-any-file:
1717
- ggml/include/ggml-sycl.h
1818
- ggml/src/ggml-sycl.cpp
19-
- README-sycl.md
19+
- ggml/src/ggml-sycl/**
20+
- docs/backend/SYCL.md
21+
- examples/sycl/**
2022
Nvidia GPU:
2123
- changed-files:
2224
- any-glob-to-any-file:

.github/workflows/build.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,10 @@ jobs:
355355
- name: Dependencies
356356
id: depends
357357
run: |
358-
sudo apt-get update
359-
sudo apt-get install build-essential libvulkan-dev
358+
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
359+
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
360+
sudo apt-get update -y
361+
sudo apt-get install -y build-essential vulkan-sdk
360362
361363
- name: Build
362364
id: cmake_build
@@ -858,7 +860,7 @@ jobs:
858860
mkdir build
859861
cd build
860862
cmake .. -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON
861-
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
863+
cmake --build . --config Release -j $((${env:NUMBER_OF_PROCESSORS} - 1))
862864
863865
- name: Determine tag name
864866
id: tag

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ llama-batched-swift
6161
out/
6262
tmp/
6363

64+
# Deprecated
65+
66+
/main
67+
/server
68+
6469
# CI
6570

6671
!.github/workflows/*.yml

CMakeLists.txt

+15-6
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ endif()
5050
# option list
5151
#
5252

53-
# general
54-
option(LLAMA_CCACHE "llama: use ccache if available" ON)
55-
5653
# debug
5754
option(LLAMA_ALL_WARNINGS "llama: enable all compiler warnings" ON)
5855
option(LLAMA_ALL_WARNINGS_3RD_PARTY "llama: enable all compiler warnings in 3rd party libs" OFF)
@@ -77,7 +74,6 @@ option(LLAMA_CURL "llama: use libcurl to download model from an URL" OFF)
7774
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake)
7875

7976
# override ggml options
80-
set(GGML_CCACHE ${LLAMA_CCACHE})
8177
set(GGML_SANITIZE_THREAD ${LLAMA_SANITIZE_THREAD})
8278
set(GGML_SANITIZE_ADDRESS ${LLAMA_SANITIZE_ADDRESS})
8379
set(GGML_SANITIZE_UNDEFINED ${LLAMA_SANITIZE_UNDEFINED})
@@ -110,12 +106,16 @@ llama_option_depr(WARNING LLAMA_NATIVE GGML_NATIVE)
110106
llama_option_depr(WARNING LLAMA_RPC GGML_RPC)
111107
llama_option_depr(WARNING LLAMA_SYCL GGML_SYCL)
112108
llama_option_depr(WARNING LLAMA_SYCL_F16 GGML_SYCL_F16)
109+
llama_option_depr(WARNING LLAMA_CANN GGML_CANN)
113110

114111
#
115112
# build the library
116113
#
117114

118-
add_subdirectory(ggml)
115+
if (NOT TARGET ggml)
116+
add_subdirectory(ggml)
117+
# ... otherwise assume ggml is added by a parent CMakeLists.txt
118+
endif()
119119
add_subdirectory(src)
120120

121121
#
@@ -133,7 +133,16 @@ set(LLAMA_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location o
133133
set(LLAMA_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
134134
set(LLAMA_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")
135135

136-
get_directory_property(LLAMA_TRANSIENT_DEFINES COMPILE_DEFINITIONS)
136+
137+
# At the moment some compile definitions are placed within the ggml/src
138+
# directory but not exported on the `ggml` target. This could be improved by
139+
# determining _precisely_ which defines are necessary for the llama-config
140+
# package.
141+
#
142+
get_directory_property(GGML_DIR_DEFINES DIRECTORY ggml/src COMPILE_DEFINITIONS)
143+
get_target_property(GGML_TARGET_DEFINES ggml COMPILE_DEFINITIONS)
144+
set(GGML_TRANSIENT_DEFINES ${GGML_TARGET_DEFINES} ${GGML_DIR_DEFINES})
145+
get_target_property(GGML_LINK_LIBRARIES ggml LINK_LIBRARIES)
137146

138147
set_target_properties(llama PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/llama.h)
139148
install(TARGETS llama LIBRARY PUBLIC_HEADER)

CONTRIBUTING.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
# Pull requests
1+
# Pull requests (for contributors)
22

3-
- Always squash-merge the PR before merging
4-
- Use the following format for your final commit: `<module> : <commit title> (#<issue_number>)`. For example: `utils : fix typo in utils.py (#1234)`
53
- Test your changes:
64
- Using the commands in the [`tests`](tests) folder. For instance, running the `./tests/test-backend-ops` command tests different backend implementations of the GGML library
75
- Execute [the full CI locally on your machine](ci/README.md) before publishing
8-
- If the pull request contains only documentation changes (e.g., updating READMEs, adding new wiki pages), please add `[no ci]` to the commit title. This will skip unnecessary CI checks and help reduce build times
96
- Please rate the complexity of your PR (i.e. `Review Complexity : Low`, `Review Complexity : Medium`, `Review Complexity : High`). This makes it easier for maintainers to triage the PRs.
10-
- The PR template has a series of review complexity checkboxes `[ ]` that [you can mark as](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists) `[X]` for your conveience
7+
- The PR template has a series of review complexity checkboxes `[ ]` that [you can mark as](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists) `[X]` for your convenience
8+
- If your PR becomes stale, don't hesitate to ping the maintainers in the comments
9+
10+
# Pull requests (for collaborators)
11+
12+
- Squash-merge PRs
13+
- Use the following format for the squashed commit title: `<module> : <commit title> (#<issue_number>)`. For example: `utils : fix typo in utils.py (#1234)`
14+
- Optionally, pick a `<module>` from here: https://github.com/ggerganov/llama.cpp/wiki/Modules
1115

1216
# Coding guidelines
1317

0 commit comments

Comments
 (0)