Skip to content

Commit a4b7b4c

Browse files
authored
Merge branch 'ggerganov:master' into master
2 parents 2e5c8ae + e9c13ff commit a4b7b4c

File tree

129 files changed

+13751
-10991
lines changed

Some content is hidden

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

129 files changed

+13751
-10991
lines changed

.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: 4 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,7 @@ models-mnt
4546
/infill
4647
/libllama.so
4748
/llama-bench
48-
/llava
49+
/llava-cli
4950
/main
5051
/metal
5152
/perplexity
@@ -63,8 +64,9 @@ models-mnt
6364
/speculative
6465
/parallel
6566
/train-text-from-scratch
67+
/tokenize
6668
/vdot
67-
build-info.h
69+
/common/build-info.cpp
6870
arm_neon.h
6971
compile_commands.json
7072
CMakeSettings.json

CMakeLists.txt

Lines changed: 20 additions & 36 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
@@ -100,39 +100,6 @@ option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALO
100100
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
101101
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
102102

103-
#
104-
# Build info header
105-
#
106-
107-
# Generate initial build-info.h
108-
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
109-
110-
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
111-
set(GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.git")
112-
113-
# Is git submodule
114-
if(NOT IS_DIRECTORY "${GIT_DIR}")
115-
file(READ ${GIT_DIR} REAL_GIT_DIR_LINK)
116-
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" REAL_GIT_DIR ${REAL_GIT_DIR_LINK})
117-
set(GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${REAL_GIT_DIR}")
118-
endif()
119-
120-
# Add a custom target for build-info.h
121-
add_custom_target(BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h")
122-
123-
# Add a custom command to rebuild build-info.h when .git/index changes
124-
add_custom_command(
125-
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h"
126-
COMMENT "Generating build details from Git"
127-
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"
128-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
129-
DEPENDS "${GIT_DIR}/index"
130-
VERBATIM
131-
)
132-
else()
133-
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.")
134-
endif()
135-
136103
#
137104
# Compile flags
138105
#
@@ -491,6 +458,15 @@ if (LLAMA_LTO)
491458
endif()
492459
endif()
493460

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+
494470
# Architecture specific
495471
# TODO: probably these flags need to be tweaked on some architectures
496472
# feel free to update the Makefile for your architecture and send a pull request or issue
@@ -543,6 +519,10 @@ if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") OR (${CMAKE_SYSTEM_PROCESSOR} MATC
543519
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GENERATOR_PLATFORM_LWR}" MATCHES "^(x86_64|i686|amd64|x64)$" )
544520
message(STATUS "x86 detected")
545521
if (MSVC)
522+
# instruction set detection for MSVC only
523+
if (LLAMA_NATIVE)
524+
include(cmake/FindSIMD.cmake)
525+
endif ()
546526
if (LLAMA_AVX512)
547527
add_compile_options($<$<COMPILE_LANGUAGE:C>:/arch:AVX512>)
548528
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/arch:AVX512>)
@@ -594,8 +574,12 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GE
594574
endif()
595575
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
596576
message(STATUS "PowerPC detected")
597-
add_compile_options(-mcpu=native -mtune=native)
598-
#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()
599583
else()
600584
message(STATUS "Unknown architecture")
601585
endif()

0 commit comments

Comments
 (0)