Skip to content

Commit 2648647

Browse files
committed
Merge branch 'master' into cuda-cublas-opts
2 parents e374227 + f3b2698 commit 2648647

File tree

137 files changed

+25183
-21330
lines changed

Some content is hidden

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

137 files changed

+25183
-21330
lines changed

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Bug template
33
about: Used to report bugs in llama.cpp
4-
labels: ["bug"]
4+
labels: ["bug-unconfirmed"]
55
assignees: ''
66

77
---

.github/workflows/build.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ jobs:
288288
OPENBLAS_VERSION: 0.3.23
289289
OPENCL_VERSION: 2023.04.17
290290
CLBLAST_VERSION: 1.6.0
291+
SDE_VERSION: 9.21.1-2023-04-24
291292

292293
strategy:
293294
matrix:
@@ -383,11 +384,23 @@ jobs:
383384
384385
- name: Test
385386
id: cmake_test
386-
if: ${{ matrix.build != 'clblast' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }} # Test AVX-512 only when possible
387+
if: ${{ matrix.build != 'clblast' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }} # not all machines have native AVX-512
387388
run: |
388389
cd build
389390
ctest -C Release --verbose --timeout 900
390391
392+
- name: Test (Intel SDE)
393+
id: cmake_test_sde
394+
if: ${{ matrix.build == 'avx512' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
395+
run: |
396+
curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/777395/sde-external-${env:SDE_VERSION}-win.tar.xz"
397+
# for some weird reason windows tar doesn't like sde tar.xz
398+
7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
399+
7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
400+
$sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
401+
cd build
402+
& $sde -future -- ctest -C Release --verbose --timeout 900
403+
391404
- name: Determine tag name
392405
id: tag
393406
shell: bash

.github/workflows/python-lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: flake8 Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
flake8-lint:
7+
runs-on: ubuntu-latest
8+
name: Lint
9+
steps:
10+
- name: Check out source repository
11+
uses: actions/checkout@v3
12+
- name: Set up Python environment
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: "3.11"
16+
- name: flake8 Lint
17+
uses: py-actions/flake8@v2
18+
with:
19+
ignore: "E203,E211,E221,E225,E231,E241,E251,E261,E266,E501,E701,E704"
20+
exclude: "examples/*,examples/*/**,*/**/__init__.py"

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
.DS_Store
1616
.build/
1717
.cache/
18+
.ccls-cache/
1819
.direnv/
1920
.envrc
2021
.swiftpm
@@ -45,7 +46,8 @@ models-mnt
4546
/infill
4647
/libllama.so
4748
/llama-bench
48-
/llava
49+
/llava-cli
50+
/lookahead
4951
/main
5052
/metal
5153
/perplexity
@@ -63,8 +65,9 @@ models-mnt
6365
/speculative
6466
/parallel
6567
/train-text-from-scratch
68+
/tokenize
6669
/vdot
67-
build-info.h
70+
/common/build-info.cpp
6871
arm_neon.h
6972
compile_commands.json
7073
CMakeSettings.json

CMakeLists.txt

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif()
1010

1111
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1212

13-
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
13+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1414
set(LLAMA_STANDALONE ON)
1515

1616
# configure project version
@@ -94,46 +94,12 @@ option(LLAMA_CLBLAST "llama: use CLBlast"
9494
option(LLAMA_METAL "llama: use Metal" ${LLAMA_METAL_DEFAULT})
9595
option(LLAMA_METAL_NDEBUG "llama: disable Metal debugging" OFF)
9696
option(LLAMA_MPI "llama: use MPI" OFF)
97-
option(LLAMA_K_QUANTS "llama: use k-quants" ON)
9897
option(LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF)
9998

10099
option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
101100
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
102101
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
103102

104-
#
105-
# Build info header
106-
#
107-
108-
# Generate initial build-info.h
109-
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
110-
111-
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
112-
set(GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.git")
113-
114-
# Is git submodule
115-
if(NOT IS_DIRECTORY "${GIT_DIR}")
116-
file(READ ${GIT_DIR} REAL_GIT_DIR_LINK)
117-
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" REAL_GIT_DIR ${REAL_GIT_DIR_LINK})
118-
set(GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${REAL_GIT_DIR}")
119-
endif()
120-
121-
# Add a custom target for build-info.h
122-
add_custom_target(BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h")
123-
124-
# Add a custom command to rebuild build-info.h when .git/index changes
125-
add_custom_command(
126-
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h"
127-
COMMENT "Generating build details from Git"
128-
COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_VS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake"
129-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
130-
DEPENDS "${GIT_DIR}/index"
131-
VERBATIM
132-
)
133-
else()
134-
message(WARNING "Git repository not found; to enable automatic generation of build info, make sure Git is installed and the project is a Git repository.")
135-
endif()
136-
137103
#
138104
# Compile flags
139105
#
@@ -278,13 +244,8 @@ if (LLAMA_BLAS)
278244
endif()
279245
endif()
280246

281-
if (LLAMA_K_QUANTS)
282-
set(GGML_HEADERS_EXTRA k_quants.h)
283-
set(GGML_SOURCES_EXTRA k_quants.c)
284-
add_compile_definitions(GGML_USE_K_QUANTS)
285-
if (LLAMA_QKK_64)
286-
add_compile_definitions(GGML_QKK_64)
287-
endif()
247+
if (LLAMA_QKK_64)
248+
add_compile_definitions(GGML_QKK_64)
288249
endif()
289250

290251
if (LLAMA_CUBLAS)
@@ -497,6 +458,15 @@ if (LLAMA_LTO)
497458
endif()
498459
endif()
499460

461+
# this version of Apple ld64 is buggy
462+
execute_process(
463+
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} -Wl,-v
464+
ERROR_VARIABLE output
465+
)
466+
if (output MATCHES "dyld-1015\.7")
467+
add_compile_definitions(HAVE_BUGGY_APPLE_LINKER)
468+
endif()
469+
500470
# Architecture specific
501471
# TODO: probably these flags need to be tweaked on some architectures
502472
# feel free to update the Makefile for your architecture and send a pull request or issue
@@ -549,6 +519,10 @@ if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") OR (${CMAKE_SYSTEM_PROCESSOR} MATC
549519
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GENERATOR_PLATFORM_LWR}" MATCHES "^(x86_64|i686|amd64|x64)$" )
550520
message(STATUS "x86 detected")
551521
if (MSVC)
522+
# instruction set detection for MSVC only
523+
if (LLAMA_NATIVE)
524+
include(cmake/FindSIMD.cmake)
525+
endif ()
552526
if (LLAMA_AVX512)
553527
add_compile_options($<$<COMPILE_LANGUAGE:C>:/arch:AVX512>)
554528
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/arch:AVX512>)
@@ -600,8 +574,12 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GE
600574
endif()
601575
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
602576
message(STATUS "PowerPC detected")
603-
add_compile_options(-mcpu=native -mtune=native)
604-
#TODO: Add targets for Power8/Power9 (Altivec/VSX) and Power10(MMA) and query for big endian systems (ppc64/le/be)
577+
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le")
578+
add_compile_options(-mcpu=powerpc64le)
579+
else()
580+
add_compile_options(-mcpu=native -mtune=native)
581+
#TODO: Add targets for Power8/Power9 (Altivec/VSX) and Power10(MMA) and query for big endian systems (ppc64/le/be)
582+
endif()
605583
else()
606584
message(STATUS "Unknown architecture")
607585
endif()
@@ -673,6 +651,8 @@ add_library(ggml OBJECT
673651
ggml-alloc.h
674652
ggml-backend.c
675653
ggml-backend.h
654+
ggml-quants.c
655+
ggml-quants.h
676656
${GGML_SOURCES_CUDA} ${GGML_HEADERS_CUDA}
677657
${GGML_SOURCES_OPENCL} ${GGML_HEADERS_OPENCL}
678658
${GGML_SOURCES_METAL} ${GGML_HEADERS_METAL}

0 commit comments

Comments
 (0)