Merge branch 'main' of hf.co:spaces/Mat17892/iris
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+23
- llama.cpp/.clang-formatAdded+161
- llama.cpp/.clang-tidyAdded+26
- llama.cpp/.devops/cloud-v-pipelineAdded+22
- llama.cpp/.devops/full-cuda.DockerfileAdded+33
- llama.cpp/.devops/full-musa.DockerfileAdded+33
- llama.cpp/.devops/full-rocm.DockerfileAdded+50
- llama.cpp/.devops/full.DockerfileAdded+25
- llama.cpp/.devops/llama-cli-cann.DockerfileAdded+44
- llama.cpp/.devops/llama-cli-cuda.DockerfileAdded+38
- llama.cpp/.devops/llama-cli-intel.DockerfileAdded+28
- llama.cpp/.devops/llama-cli-musa.DockerfileAdded+38
- llama.cpp/.devops/llama-cli-rocm.DockerfileAdded+45
- llama.cpp/.devops/llama-cli-vulkan.DockerfileAdded+27
- llama.cpp/.devops/llama-cli.DockerfileAdded+23
- llama.cpp/.devops/llama-cpp-cuda.srpm.specAdded+83
- llama.cpp/.devops/llama-cpp.srpm.specAdded+85
- llama.cpp/.devops/llama-server-cuda.DockerfileAdded+43
- llama.cpp/.devops/llama-server-intel.DockerfileAdded+34
- llama.cpp/.devops/llama-server-musa.DockerfileAdded+43
- llama.cpp/.devops/llama-server-rocm.DockerfileAdded+54
- llama.cpp/.devops/llama-server-vulkan.DockerfileAdded+31
- llama.cpp/.devops/llama-server.DockerfileAdded+41
- llama.cpp/.devops/nix/apps.nixAdded+21
- llama.cpp/.devops/nix/devshells.nixAdded+52
- llama.cpp/.devops/nix/docker.nixAdded+37
- llama.cpp/.devops/nix/jetson-support.nixAdded+39
- llama.cpp/.devops/nix/nixpkgs-instances.nixAdded+45
- llama.cpp/.devops/nix/package-gguf-py.nixAdded+36
- llama.cpp/.devops/nix/package.nixAdded+246
- llama.cpp/.devops/nix/python-scripts.nixAdded+66
- llama.cpp/.devops/nix/scope.nixAdded+41
- llama.cpp/.devops/nix/sif.nixAdded+27
- llama.cpp/.devops/tools.shAdded+41
- llama.cpp/.dockerignoreAdded+20
- llama.cpp/.ecrcAdded+6
- llama.cpp/.editorconfigAdded+42
- llama.cpp/.flake8Added+17
- llama.cpp/.github/ISSUE_TEMPLATE/010-bug-compilation.ymlAdded+77
- llama.cpp/.github/ISSUE_TEMPLATE/011-bug-results.ymlAdded+101
- llama.cpp/.github/ISSUE_TEMPLATE/019-bug-misc.ymlAdded+81
- llama.cpp/.github/ISSUE_TEMPLATE/020-enhancement.ymlAdded+51
- llama.cpp/.github/ISSUE_TEMPLATE/030-research.ymlAdded+52
- llama.cpp/.github/ISSUE_TEMPLATE/040-refactor.ymlAdded+28
- llama.cpp/.github/ISSUE_TEMPLATE/config.ymlAdded+11
- llama.cpp/.github/labeler.ymlAdded+86
- llama.cpp/.github/pull_request_template.mdAdded+1
- llama.cpp/.github/workflows/bench.yml.disabledAdded+315
- llama.cpp/.github/workflows/build.ymlAdded+1416
- llama.cpp/.github/workflows/close-issue.ymlAdded+28
34 unmodified lines35363734 unmodified lines*tfevents* filter=lfs diff=lfs merge=lfs -textllama_lora_model_1/tokenizer.json filter=lfs diff=lfs merge=lfs -textoutputs/checkpoint-100/tokenizer.json filter=lfs diff=lfs merge=lfs -text34 unmodified lines353637383940414243444546474849505152535455565758596034 unmodified lines*tfevents* filter=lfs diff=lfs merge=lfs -textllama_lora_model_1/tokenizer.json filter=lfs diff=lfs merge=lfs -textoutputs/checkpoint-100/tokenizer.json filter=lfs diff=lfs merge=lfs -textllama.cpp/build/bin/llama-export-lora filter=lfs diff=lfs merge=lfs -textllama.cpp/build/bin/llama-imatrix filter=lfs diff=lfs merge=lfs -textllama.cpp/build/bin/llama-llava-cli filter=lfs diff=lfs merge=lfs -textllama.cpp/build/bin/llama-minicpmv-cli filter=lfs diff=lfs merge=lfs -textllama.cpp/build/bin/llama-perplexity filter=lfs diff=lfs merge=lfs -textllama.cpp/build/bin/llama-server filter=lfs diff=lfs merge=lfs -textllama.cpp/build/common/libcommon.a filter=lfs diff=lfs merge=lfs -textllama.cpp/build/examples/server/CMakeFiles/llama-server.dir/server.cpp.o filter=lfs diff=lfs merge=lfs -textllama.cpp/build/src/CMakeFiles/llama.dir/llama.cpp.o filter=lfs diff=lfs merge=lfs -textllama.cpp/build/src/libllama.so filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-aquila.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-baichuan.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-command-r.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-deepseek-coder.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-deepseek-llm.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-falcon.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-gpt-2.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-gpt-neox.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-llama-bpe.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-mpt.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-qwen2.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-refact.gguf filter=lfs diff=lfs merge=lfs -textllama.cpp/models/ggml-vocab-starcoder.gguf filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161---Language: CppAlignAfterOpenBracket: AlignAlignArrayOfStructures: LeftAlignConsecutiveAssignments: AcrossCommentsAlignConsecutiveBitFields: AcrossCommentsAlignConsecutiveDeclarations: AcrossCommentsAlignConsecutiveMacros: AcrossComments# AlignConsecutiveShortCaseStatements: AcrossCommentsAlignEscapedNewlines: Left # LeftWithLastLineAlignOperands: AlignAlignTrailingComments: Kind: Always OverEmptyLines: 1AllowAllArgumentsOnNextLine: trueAllowAllParametersOfDeclarationOnNextLine: false# AllowBreakBeforeNoexceptSpecifier: OnlyWithParenAllowShortBlocksOnASingleLine: NeverAllowShortCaseLabelsOnASingleLine: falseAllowShortFunctionsOnASingleLine: InlineAllowShortIfStatementsOnASingleLine: NeverAllowShortLambdasOnASingleLine: InlineAllowShortLoopsOnASingleLine: falseAlwaysBreakBeforeMultilineStrings: trueBinPackArguments: trueBinPackParameters: true # OnePerLineBitFieldColonSpacing: BothBreakBeforeBraces: Custom # AttachBraceWrapping: AfterCaseLabel: true AfterClass: false AfterControlStatement: false AfterEnum: false AfterFunction: false AfterNamespace: false AfterObjCDeclaration: false AfterStruct: false AfterUnion: false AfterExternBlock: false BeforeCatch: false BeforeElse: false BeforeLambdaBody: false BeforeWhile: false IndentBraces: false SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false# BreakAdjacentStringLiterals: trueBreakAfterAttributes: NeverBreakBeforeBinaryOperators: NoneBreakBeforeInlineASMColon: OnlyMultilineBreakBeforeTernaryOperators: false# BreakBinaryOperations: NeverBreakConstructorInitializers: AfterColon# BreakFunctionDefinitionParameters: falseBreakInheritanceList: AfterCommaBreakStringLiterals: true# BreakTemplateDeclarations: YesColumnLimit: 120CommentPragmas: '^ IWYU pragma:'CompactNamespaces: falseConstructorInitializerIndentWidth: 4ContinuationIndentWidth: 4Cpp11BracedListStyle: falseDerivePointerAlignment: falseDisableFormat: falseEmptyLineBeforeAccessModifier: LeaveEmptyLineAfterAccessModifier: NeverExperimentalAutoDetectBinPacking: falseFixNamespaceComments: trueIncludeBlocks: RegroupIncludeCategories: - Regex: '^<.*\.h>' Priority: 1 SortPriority: 0 - Regex: '^<.*' Priority: 2 SortPriority: 0 - Regex: '.*' Priority: 3 SortPriority: 0IncludeIsMainRegex: '([-_](test|unittest))?$'IncludeIsMainSourceRegex: ''IndentAccessModifiers: falseIndentCaseBlocks: trueIndentCaseLabels: trueIndentExternBlock: NoIndentIndentGotoLabels: falseIndentPPDirectives: AfterHashIndentWidth: 4IndentWrappedFunctionNames: falseInsertBraces: true # NOTE: may lead to incorrect formattingInsertNewlineAtEOF: trueJavaScriptQuotes: LeaveJavaScriptWrapImports: trueKeepEmptyLinesAtTheStartOfBlocks: falseLambdaBodyIndentation: SignatureLineEnding: LFMacroBlockBegin: ''MacroBlockEnd: ''MaxEmptyLinesToKeep: 1NamespaceIndentation: NoneObjCBinPackProtocolList: AutoObjCBlockIndentWidth: 4ObjCSpaceAfterProperty: trueObjCSpaceBeforeProtocolList: truePPIndentWidth: -1PackConstructorInitializers: CurrentLinePenaltyBreakAssignment: 2PenaltyBreakBeforeFirstCallParameter: 1PenaltyBreakComment: 300PenaltyBreakFirstLessLess: 120PenaltyBreakString: 1000PenaltyBreakTemplateDeclaration: 10PenaltyExcessCharacter: 1000000PenaltyReturnTypeOnItsOwnLine: 200PointerAlignment: MiddleQualifierAlignment: Left#QualifierOrder: ['static', 'inline', 'friend', 'constexpr', 'const', 'volatile', 'type', 'restrict']RawStringFormats: - Language: Cpp Delimiters: - cc - CC - cpp - Cpp - CPP - 'c++' - 'C++' CanonicalDelimiter: ''ReferenceAlignment: MiddleReflowComments: false # IndentOnlySeparateDefinitionBlocks: AlwaysSortIncludes: CaseInsensitiveSortUsingDeclarations: LexicographicNumericSpaceAfterCStyleCast: trueSpaceAfterLogicalNot: falseSpaceAfterTemplateKeyword: trueSpaceBeforeAssignmentOperators: trueSpaceBeforeCpp11BracedList: falseSpaceBeforeCtorInitializerColon: trueSpaceBeforeInheritanceColon: trueSpaceBeforeParens: ControlStatementsSpaceBeforeRangeBasedForLoopColon: trueSpaceInEmptyBlock: falseSpaceInEmptyParentheses: falseSpacesBeforeTrailingComments: 2SpacesInAngles: NeverSpacesInContainerLiterals: trueSpacesInLineCommentPrefix: Minimum: 1 Maximum: -1SpacesInParentheses: falseSpacesInSquareBrackets: falseSpaceBeforeSquareBrackets: falseStandard: c++17TabWidth: 4UseTab: NeverWhitespaceSensitiveMacros: ['STRINGIZE']...
1234567891011121314151617181920212223242526---Checks: > bugprone-*, -bugprone-easily-swappable-parameters, -bugprone-implicit-widening-of-multiplication-result, -bugprone-misplaced-widening-cast, -bugprone-narrowing-conversions, readability-*, -readability-avoid-unconditional-preprocessor-if, -readability-function-cognitive-complexity, -readability-identifier-length, -readability-implicit-bool-conversion, -readability-magic-numbers, -readability-uppercase-literal-suffix, -readability-simplify-boolean-expr, clang-analyzer-*, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, performance-*, portability-*, -portability-simd-intrinsics, misc-*, -misc-const-correctness, -misc-non-private-member-variables-in-classes, -misc-no-recursion, -misc-use-anonymous-namespace,FormatStyle: none12345678910111213141516171819202122node('x86_runner1'){ // Running on x86 runner containing latest vector qemu, latest vector gcc and all the necessary libraries stage('Cleanup'){ cleanWs() // Cleaning previous CI build in workspace } stage('checkout repo'){ retry(5){ // Retry if the cloning fails due to some reason checkout scm // Clone the repo on Runner } } stage('Compiling llama.cpp'){ sh'''#!/bin/bash make RISCV=1 RISCV_CROSS_COMPILE=1 # Compiling llama for RISC-V ''' } stage('Running llama.cpp'){ sh'''#!/bin/bash module load gnu-bin2/0.1 # loading latest versions of vector qemu and vector gcc qemu-riscv64 -L /softwares/gnu-bin2/sysroot -cpu rv64,v=true,vlen=256,elen=64,vext_spec=v1.0 ./llama-cli -m /home/alitariq/codellama-7b.Q4_K_M.gguf -p "Anything" -n 9 > llama_log.txt # Running llama.cpp on vector qemu-riscv64 cat llama_log.txt # Printing results ''' }}123456789101112131415161718192021222324252627282930313233ARG UBUNTU_VERSION=22.04# This needs to generally match the container host's environment.ARG CUDA_VERSION=12.6.0# Target the CUDA build imageARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
# CUDA architecture to build for (defaults to all supported archs)ARG CUDA_DOCKER_ARCH=default
RUN apt-get update && \ apt-get install -y build-essential cmake python3 python3-pip git libcurl4-openssl-dev libgomp1
COPY requirements.txt requirements.txtCOPY requirements requirements
RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt
WORKDIR /app
COPY . .
# Use the default CUDA archs if not specifiedRUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \ fi && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release -j$(nproc) && \ cp build/bin/* .
ENTRYPOINT ["/app/.devops/tools.sh"]123456789101112131415161718192021222324252627282930313233ARG UBUNTU_VERSION=22.04# This needs to generally match the container host's environment.ARG MUSA_VERSION=rc3.1.0# Target the MUSA build imageARG BASE_MUSA_DEV_CONTAINER=mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
# MUSA architecture to build for (defaults to all supported archs)ARG MUSA_DOCKER_ARCH=default
RUN apt-get update && \ apt-get install -y build-essential cmake python3 python3-pip git libcurl4-openssl-dev libgomp1
COPY requirements.txt requirements.txtCOPY requirements requirements
RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt
WORKDIR /app
COPY . .
# Use the default MUSA archs if not specifiedRUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \ fi && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release -j$(nproc) && \ cp build/bin/* .
ENTRYPOINT ["/app/.devops/tools.sh"]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950ARG UBUNTU_VERSION=22.04
# This needs to generally match the container host's environment.ARG ROCM_VERSION=5.6
# Target the CUDA build imageARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
# Unless otherwise specified, we make a fat build.# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878# This is mostly tied to rocBLAS supported archs.ARG ROCM_DOCKER_ARCH="\ gfx803 \ gfx900 \ gfx906 \ gfx908 \ gfx90a \ gfx1010 \ gfx1030 \ gfx1100 \ gfx1101 \ gfx1102"
COPY requirements.txt requirements.txtCOPY requirements requirements
RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt
WORKDIR /app
COPY . .
# Set nvcc architectureENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}# Enable ROCmENV GGML_HIPBLAS=1ENV CC=/opt/rocm/llvm/bin/clangENV CXX=/opt/rocm/llvm/bin/clang++
# Enable cURLENV LLAMA_CURL=1RUN apt-get update && \ apt-get install -y libcurl4-openssl-dev
RUN make -j$(nproc)
ENTRYPOINT ["/app/.devops/tools.sh"]12345678910111213141516171819202122232425ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS build
RUN apt-get update && \ apt-get install -y build-essential python3 python3-pip git libcurl4-openssl-dev libgomp1
COPY requirements.txt requirements.txtCOPY requirements requirements
RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt
WORKDIR /app
COPY . .
ENV LLAMA_CURL=1
RUN make -j$(nproc)
ENV LC_ALL=C.utf8
ENTRYPOINT ["/app/.devops/tools.sh"]1234567891011121314151617181920212223242526272829303132333435363738394041424344ARG ASCEND_VERSION=8.0.rc2.alpha003-910b-openeuler22.03-py3.8
FROM ascendai/cann:$ASCEND_VERSION AS build
WORKDIR /app
COPY . .
RUN yum install -y gcc g++ cmake makeENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latestENV LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:$LIBRARY_PATHENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/lib64/plugin/opskernel:${ASCEND_TOOLKIT_HOME}/lib64/plugin/nnengine:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe/op_tiling:${LD_LIBRARY_PATH}ENV PYTHONPATH=${ASCEND_TOOLKIT_HOME}/python/site-packages:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe:${PYTHONPATH}ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${ASCEND_TOOLKIT_HOME}/compiler/ccec_compiler/bin:${PATH}ENV ASCEND_AICPU_PATH=${ASCEND_TOOLKIT_HOME}ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/oppENV TOOLCHAIN_HOME=${ASCEND_TOOLKIT_HOME}/toolkitENV ASCEND_HOME_PATH=${ASCEND_TOOLKIT_HOME}
# find libascend_hal.so, because the drive hasn`t been mounted.ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/runtime/lib64/stub:$LD_LIBRARY_PATH
RUN echo "Building with static libs" && \ source /usr/local/Ascend/ascend-toolkit/set_env.sh --force && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_CANN=ON -DBUILD_SHARED_LIBS=OFF && \ cmake --build build --config Release --target llama-cli
# TODO: use image with NNRTFROM ascendai/cann:$ASCEND_VERSION AS runtimeCOPY --from=build /app/build/bin/llama-cli /llama-cli
ENV LC_ALL=C.utf8
ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latestENV LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:$LIBRARY_PATHENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/lib64/plugin/opskernel:${ASCEND_TOOLKIT_HOME}/lib64/plugin/nnengine:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe/op_tiling:${LD_LIBRARY_PATH}ENV PYTHONPATH=${ASCEND_TOOLKIT_HOME}/python/site-packages:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe:${PYTHONPATH}ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${ASCEND_TOOLKIT_HOME}/compiler/ccec_compiler/bin:${PATH}ENV ASCEND_AICPU_PATH=${ASCEND_TOOLKIT_HOME}ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/oppENV TOOLCHAIN_HOME=${ASCEND_TOOLKIT_HOME}/toolkitENV ASCEND_HOME_PATH=${ASCEND_TOOLKIT_HOME}
ENTRYPOINT ["/llama-cli" ]1234567891011121314151617181920212223242526272829303132333435363738ARG UBUNTU_VERSION=22.04# This needs to generally match the container host's environment.ARG CUDA_VERSION=12.6.0# Target the CUDA build imageARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}# Target the CUDA runtime imageARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
# CUDA architecture to build for (defaults to all supported archs)ARG CUDA_DOCKER_ARCH=default
RUN apt-get update && \ apt-get install -y build-essential git cmake
WORKDIR /app
COPY . .
# Use the default CUDA archs if not specifiedRUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \ fi && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release --target llama-cli -j$(nproc) && \ mkdir -p /app/lib && \ find build -name "*.so" -exec cp {} /app/lib \;
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
RUN apt-get update && \ apt-get install -y libgomp1
COPY --from=build /app/lib/ /COPY --from=build /app/build/bin/llama-cli /
ENTRYPOINT [ "/llama-cli" ]12345678910111213141516171819202122232425262728ARG ONEAPI_VERSION=2025.0.0-0-devel-ubuntu22.04
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS build
ARG GGML_SYCL_F16=OFFRUN apt-get update && \ apt-get install -y git
WORKDIR /app
COPY . .
RUN if [ "${GGML_SYCL_F16}" = "ON" ]; then \ echo "GGML_SYCL_F16 is set" && \ export OPT_SYCL_F16="-DGGML_SYCL_F16=ON"; \ fi && \ echo "Building with static libs" && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx \ ${OPT_SYCL_F16} -DBUILD_SHARED_LIBS=OFF && \ cmake --build build --config Release --target llama-cli
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS runtime
COPY --from=build /app/build/bin/llama-cli /llama-cli
ENV LC_ALL=C.utf8
ENTRYPOINT [ "/llama-cli" ]1234567891011121314151617181920212223242526272829303132333435363738ARG UBUNTU_VERSION=22.04# This needs to generally match the container host's environment.ARG MUSA_VERSION=rc3.1.0# Target the MUSA build imageARG BASE_MUSA_DEV_CONTAINER=mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}# Target the MUSA runtime imageARG BASE_MUSA_RUN_CONTAINER=mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
# MUSA architecture to build for (defaults to all supported archs)ARG MUSA_DOCKER_ARCH=default
RUN apt-get update && \ apt-get install -y build-essential git cmake
WORKDIR /app
COPY . .
# Use the default MUSA archs if not specifiedRUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \ fi && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release --target llama-cli -j$(nproc) && \ mkdir -p /app/lib && \ find build -name "*.so" -exec cp {} /app/lib \;
FROM ${BASE_MUSA_RUN_CONTAINER} AS runtime
RUN apt-get update && \ apt-get install -y libgomp1
COPY --from=build /app/lib/ /COPY --from=build /app/build/bin/llama-cli /llama-cli
ENTRYPOINT [ "/llama-cli" ]123456789101112131415161718192021222324252627282930313233343536373839404142434445ARG UBUNTU_VERSION=22.04
# This needs to generally match the container host's environment.ARG ROCM_VERSION=5.6
# Target the CUDA build imageARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
# Unless otherwise specified, we make a fat build.# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878# This is mostly tied to rocBLAS supported archs.ARG ROCM_DOCKER_ARCH="\ gfx803 \ gfx900 \ gfx906 \ gfx908 \ gfx90a \ gfx1010 \ gfx1030 \ gfx1100 \ gfx1101 \ gfx1102"
COPY requirements.txt requirements.txtCOPY requirements requirements
RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt
WORKDIR /app
COPY . .
# Set nvcc architectureENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}# Enable ROCmENV GGML_HIPBLAS=1ENV CC=/opt/rocm/llvm/bin/clangENV CXX=/opt/rocm/llvm/bin/clang++
RUN make -j$(nproc) llama-cli
ENTRYPOINT [ "/app/llama-cli" ]123456789101112131415161718192021222324252627ARG UBUNTU_VERSION=jammy
FROM ubuntu:$UBUNTU_VERSION AS build
# Install build toolsRUN apt update && apt install -y git build-essential cmake wget libgomp1
# Install Vulkan SDKRUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add - && \ wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list && \ apt update -y && \ apt-get install -y vulkan-sdk
# Build itWORKDIR /appCOPY . .RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_VULKAN=1 && \ cmake --build build --config Release --target llama-cli
# Clean upWORKDIR /RUN cp /app/build/bin/llama-cli /llama-cli && \ rm -rf /app
ENV LC_ALL=C.utf8
ENTRYPOINT [ "/llama-cli" ]1234567891011121314151617181920212223ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS build
RUN apt-get update && \ apt-get install -y build-essential git
WORKDIR /app
COPY . .
RUN make -j$(nproc) llama-cli
FROM ubuntu:$UBUNTU_VERSION AS runtime
RUN apt-get update && \ apt-get install -y libgomp1
COPY --from=build /app/llama-cli /llama-cli
ENV LC_ALL=C.utf8
ENTRYPOINT [ "/llama-cli" ]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283# SRPM for building from source and packaging an RPM for RPM-based distros.# https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages# Built and maintained by John Boero - boeroboy@gmail.com# In honor of Seth Vidal https://www.redhat.com/it/blog/thank-you-seth-vidal
# Notes for llama.cpp:# 1. Tags are currently based on hash - which will not sort asciibetically.# We need to declare standard versioning if people want to sort latest releases.# 2. Builds for CUDA/OpenCL support are separate, with different depenedencies.# 3. NVidia's developer repo must be enabled with nvcc, cublas, clblas, etc installed.# Example: https://developer.download.nvidia.com/compute/cuda/repos/fedora37/x86_64/cuda-fedora37.repo# 4. OpenCL/CLBLAST support simply requires the ICD loader and basic opencl libraries.# It is up to the user to install the correct vendor-specific support.
Name: llama.cpp-cudaVersion: %( date "+%%Y%%m%%d" )Release: 1%{?dist}Summary: CPU Inference of LLaMA model in pure C/C++ (no CUDA/OpenCL)License: MITSource0: https://github.com/ggerganov/llama.cpp/archive/refs/heads/master.tar.gzBuildRequires: coreutils make gcc-c++ git cuda-toolkitRequires: cuda-toolkitURL: https://github.com/ggerganov/llama.cpp
%define debug_package %{nil}%define source_date_epoch_from_changelog 0
%descriptionCPU inference for Meta's Lllama2 models using default options.
%prep%setup -n llama.cpp-master
%buildmake -j GGML_CUDA=1
%installmkdir -p %{buildroot}%{_bindir}/cp -p llama-cli %{buildroot}%{_bindir}/llama-cuda-clicp -p llama-server %{buildroot}%{_bindir}/llama-cuda-servercp -p llama-simple %{buildroot}%{_bindir}/llama-cuda-simple
mkdir -p %{buildroot}/usr/lib/systemd/system%{__cat} <<EOF > %{buildroot}/usr/lib/systemd/system/llamacuda.service[Unit]Description=Llama.cpp server, CPU only (no GPU support in this build).After=syslog.target network.target local-fs.target remote-fs.target nss-lookup.target
[Service]Type=simpleEnvironmentFile=/etc/sysconfig/llamaExecStart=/usr/bin/llama-cuda-server $LLAMA_ARGSExecReload=/bin/kill -s HUP $MAINPIDRestart=never
[Install]WantedBy=default.targetEOF
mkdir -p %{buildroot}/etc/sysconfig%{__cat} <<EOF > %{buildroot}/etc/sysconfig/llamaLLAMA_ARGS="-m /opt/llama2/ggml-model-f32.bin"EOF
%cleanrm -rf %{buildroot}rm -rf %{_builddir}/*
%files%{_bindir}/llama-cuda-cli%{_bindir}/llama-cuda-server%{_bindir}/llama-cuda-simple/usr/lib/systemd/system/llamacuda.service%config /etc/sysconfig/llama
%pre
%post
%preun%postun
%changelog12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485# SRPM for building from source and packaging an RPM for RPM-based distros.# https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages# Built and maintained by John Boero - boeroboy@gmail.com# In honor of Seth Vidal https://www.redhat.com/it/blog/thank-you-seth-vidal
# Notes for llama.cpp:# 1. Tags are currently based on hash - which will not sort asciibetically.# We need to declare standard versioning if people want to sort latest releases.# In the meantime, YYYYMMDD format will be used.# 2. Builds for CUDA/OpenCL support are separate, with different depenedencies.# 3. NVidia's developer repo must be enabled with nvcc, cublas, clblas, etc installed.# Example: https://developer.download.nvidia.com/compute/cuda/repos/fedora37/x86_64/cuda-fedora37.repo# 4. OpenCL/CLBLAST support simply requires the ICD loader and basic opencl libraries.# It is up to the user to install the correct vendor-specific support.
Name: llama.cppVersion: %( date "+%%Y%%m%%d" )Release: 1%{?dist}Summary: CPU Inference of LLaMA model in pure C/C++ (no CUDA/OpenCL)License: MITSource0: https://github.com/ggerganov/llama.cpp/archive/refs/heads/master.tar.gzBuildRequires: coreutils make gcc-c++ git libstdc++-develRequires: libstdc++URL: https://github.com/ggerganov/llama.cpp
%define debug_package %{nil}%define source_date_epoch_from_changelog 0
%descriptionCPU inference for Meta's Lllama2 models using default options.Models are not included in this package and must be downloaded separately.
%prep%setup -n llama.cpp-master
%buildmake -j
%installmkdir -p %{buildroot}%{_bindir}/cp -p llama-cli %{buildroot}%{_bindir}/llama-clicp -p llama-server %{buildroot}%{_bindir}/llama-servercp -p llama-simple %{buildroot}%{_bindir}/llama-simple
mkdir -p %{buildroot}/usr/lib/systemd/system%{__cat} <<EOF > %{buildroot}/usr/lib/systemd/system/llama.service[Unit]Description=Llama.cpp server, CPU only (no GPU support in this build).After=syslog.target network.target local-fs.target remote-fs.target nss-lookup.target
[Service]Type=simpleEnvironmentFile=/etc/sysconfig/llamaExecStart=/usr/bin/llama-server $LLAMA_ARGSExecReload=/bin/kill -s HUP $MAINPIDRestart=never
[Install]WantedBy=default.targetEOF
mkdir -p %{buildroot}/etc/sysconfig%{__cat} <<EOF > %{buildroot}/etc/sysconfig/llamaLLAMA_ARGS="-m /opt/llama2/ggml-model-f32.bin"EOF
%cleanrm -rf %{buildroot}rm -rf %{_builddir}/*
%files%{_bindir}/llama-cli%{_bindir}/llama-server%{_bindir}/llama-simple/usr/lib/systemd/system/llama.service%config /etc/sysconfig/llama
%pre
%post
%preun%postun
%changelog12345678910111213141516171819202122232425262728293031323334353637383940414243ARG UBUNTU_VERSION=22.04# This needs to generally match the container host's environment.ARG CUDA_VERSION=12.6.0# Target the CUDA build imageARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}# Target the CUDA runtime imageARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
# CUDA architecture to build for (defaults to all supported archs)ARG CUDA_DOCKER_ARCH=default
RUN apt-get update && \ apt-get install -y build-essential git cmake libcurl4-openssl-dev
WORKDIR /app
COPY . .
# Use the default CUDA archs if not specifiedRUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \ fi && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release --target llama-server -j$(nproc) && \ mkdir -p /app/lib && \ find build -name "*.so" -exec cp {} /app/lib \;
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
RUN apt-get update && \ apt-get install -y libcurl4-openssl-dev libgomp1 curl
COPY --from=build /app/lib/ /COPY --from=build /app/build/bin/llama-server /llama-server
# Must be set to 0.0.0.0 so it can listen to requests from host machineENV LLAMA_ARG_HOST=0.0.0.0
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/llama-server" ]12345678910111213141516171819202122232425262728293031323334ARG ONEAPI_VERSION=2025.0.0-0-devel-ubuntu22.04
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS build
ARG GGML_SYCL_F16=OFFRUN apt-get update && \ apt-get install -y git libcurl4-openssl-dev
WORKDIR /app
COPY . .
RUN if [ "${GGML_SYCL_F16}" = "ON" ]; then \ echo "GGML_SYCL_F16 is set" && \ export OPT_SYCL_F16="-DGGML_SYCL_F16=ON"; \ fi && \ echo "Building with dynamic libs" && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_CURL=ON ${OPT_SYCL_F16} && \ cmake --build build --config Release --target llama-server
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS runtime
RUN apt-get update && \ apt-get install -y libcurl4-openssl-dev curl
COPY --from=build /app/build/bin/llama-server /llama-server
ENV LC_ALL=C.utf8# Must be set to 0.0.0.0 so it can listen to requests from host machineENV LLAMA_ARG_HOST=0.0.0.0
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/llama-server" ]12345678910111213141516171819202122232425262728293031323334353637383940414243ARG UBUNTU_VERSION=22.04# This needs to generally match the container host's environment.ARG MUSA_VERSION=rc3.1.0# Target the MUSA build imageARG BASE_MUSA_DEV_CONTAINER=mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}# Target the MUSA runtime imageARG BASE_MUSA_RUN_CONTAINER=mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
# MUSA architecture to build for (defaults to all supported archs)ARG MUSA_DOCKER_ARCH=default
RUN apt-get update && \ apt-get install -y build-essential git cmake libcurl4-openssl-dev
WORKDIR /app
COPY . .
# Use the default MUSA archs if not specifiedRUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \ export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \ fi && \ cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ cmake --build build --config Release --target llama-server -j$(nproc) && \ mkdir -p /app/lib && \ find build -name "*.so" -exec cp {} /app/lib \;
FROM ${BASE_MUSA_RUN_CONTAINER} AS runtime
RUN apt-get update && \ apt-get install -y libcurl4-openssl-dev libgomp1 curl
COPY --from=build /app/lib/ /COPY --from=build /app/build/bin/llama-server /llama-server
# Must be set to 0.0.0.0 so it can listen to requests from host machineENV LLAMA_ARG_HOST=0.0.0.0
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/llama-server" ]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354ARG UBUNTU_VERSION=22.04
# This needs to generally match the container host's environment.ARG ROCM_VERSION=5.6
# Target the CUDA build imageARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
# Unless otherwise specified, we make a fat build.# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878# This is mostly tied to rocBLAS supported archs.ARG ROCM_DOCKER_ARCH="\ gfx803 \ gfx900 \ gfx906 \ gfx908 \ gfx90a \ gfx1010 \ gfx1030 \ gfx1100 \ gfx1101 \ gfx1102"
COPY requirements.txt requirements.txtCOPY requirements requirements
RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt
WORKDIR /app
COPY . .
# Set nvcc architectureENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}# Enable ROCmENV GGML_HIPBLAS=1ENV CC=/opt/rocm/llvm/bin/clangENV CXX=/opt/rocm/llvm/bin/clang++# Must be set to 0.0.0.0 so it can listen to requests from host machineENV LLAMA_ARG_HOST=0.0.0.0
# Enable cURLENV LLAMA_CURL=1RUN apt-get update && \ apt-get install -y libcurl4-openssl-dev curl
RUN make -j$(nproc) llama-server
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/app/llama-server" ]12345678910111213141516171819202122232425262728293031ARG UBUNTU_VERSION=jammy
FROM ubuntu:$UBUNTU_VERSION AS build
# Install build toolsRUN apt update && apt install -y git build-essential cmake wget
# Install Vulkan SDK and cURLRUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add - && \ wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list && \ apt update -y && \ apt-get install -y vulkan-sdk libcurl4-openssl-dev curl
# Build itWORKDIR /appCOPY . .RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_VULKAN=1 -DLLAMA_CURL=1 && \ cmake --build build --config Release --target llama-server
# Clean upWORKDIR /RUN cp /app/build/bin/llama-server /llama-server && \ rm -rf /app
ENV LC_ALL=C.utf8# Must be set to 0.0.0.0 so it can listen to requests from host machineENV LLAMA_ARG_HOST=0.0.0.0
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/llama-server" ]1234567891011121314151617181920212223242526272829303132333435363738394041ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS build
RUN apt-get update && \ apt-get install -y build-essential git cmake libcurl4-openssl-dev
WORKDIR /app
COPY . .
RUN \ # Build multiple versions of the CPU backend scripts/build-cpu.sh avx -DGGML_AVX=ON -DGGML_AVX2=OFF && \ scripts/build-cpu.sh avx2 -DGGML_AVX=ON -DGGML_AVX2=ON && \ scripts/build-cpu.sh avx512 -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=ON && \ scripts/build-cpu.sh amx -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=ON -DGGML_AVX_VNNI=ON -DGGML_AVX512_VNNI=ON -DGGML_AMX_TILE=ON -DGGML_AMX_INT8=ON && \ # Build llama-server cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \ cmake --build build --target llama-server -j $(nproc) && \ # Copy the built libraries to /app/lib mkdir -p /app/lib && \ mv libggml-cpu* /app/lib/ && \ find build -name "*.so" -exec cp {} /app/lib/ \;
FROM ubuntu:$UBUNTU_VERSION AS runtime
RUN apt-get update && \ apt-get install -y libcurl4-openssl-dev libgomp1 curl
COPY --from=build /app/build/bin/llama-server /llama-serverCOPY --from=build /app/lib/ /
ENV LC_ALL=C.utf8# Must be set to 0.0.0.0 so it can listen to requests from host machineENV LLAMA_ARG_HOST=0.0.0.0
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/llama-server" ]123456789101112131415161718192021{ perSystem = { config, lib, ... }: { apps = let inherit (config.packages) default; binaries = [ "llama-cli" "llama-embedding" "llama-server" "llama-quantize" ]; mkApp = name: { type = "app"; program = "${default}/bin/${name}"; }; in lib.genAttrs binaries mkApp; };}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152{ inputs, ... }:
{ perSystem = { config, lib, system, ... }: { devShells = let pkgs = import inputs.nixpkgs { inherit system; }; stdenv = pkgs.stdenv; scripts = config.packages.python-scripts; in lib.pipe (config.packages) [ (lib.concatMapAttrs ( name: package: { ${name} = pkgs.mkShell { name = "${name}"; inputsFrom = [ package ]; shellHook = '' echo "Entering ${name} devShell" ''; }; "${name}-extra" = if (name == "python-scripts") then null else pkgs.mkShell { name = "${name}-extra"; inputsFrom = [ package scripts ]; # Extra packages that *may* be used by some scripts packages = [ pkgs.python3Packages.tiktoken ]; shellHook = '' echo "Entering ${name} devShell" addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib" ''; }; } )) (lib.filterAttrs (name: value: value != null)) ]; };}12345678910111213141516171819202122232425262728293031323334353637{ lib, dockerTools, buildEnv, llama-cpp, interactive ? true, coreutils,}:
# A tar that can be fed into `docker load`:## $ nix build .#llamaPackages.docker# $ docker load < result
# For details and variations cf.# - https://nixos.org/manual/nixpkgs/unstable/#ssec-pkgs-dockerTools-buildLayeredImage# - https://discourse.nixos.org/t/a-faster-dockertools-buildimage-prototype/16922# - https://nixery.dev/
# Approximate (compressed) sizes, at the time of writing, are:## .#llamaPackages.docker: 125M;# .#llamaPackagesCuda.docker: 537M;# .#legacyPackages.aarch64-linux.llamaPackagesXavier.docker: 415M.
dockerTools.buildLayeredImage { name = llama-cpp.pname; tag = "latest";
contents = [ llama-cpp ] ++ lib.optionals interactive [ coreutils dockerTools.binSh dockerTools.caCertificates ];}123456789101112131415161718192021222324252627282930313233343536373839{ inputs, ... }:{ perSystem = { config, system, lib, pkgsCuda, ... }: { legacyPackages = let caps.llamaPackagesXavier = "7.2"; caps.llamaPackagesOrin = "8.7"; caps.llamaPackagesTX2 = "6.2"; caps.llamaPackagesNano = "5.3";
pkgsFor = cap: import inputs.nixpkgs { inherit system; config = { cudaSupport = true; cudaCapabilities = [ cap ]; cudaEnableForwardCompat = false; inherit (pkgsCuda.config) allowUnfreePredicate; }; }; in builtins.mapAttrs (name: cap: (pkgsFor cap).callPackage ./scope.nix { }) caps;
packages = lib.optionalAttrs (system == "aarch64-linux") { jetson-xavier = config.legacyPackages.llamaPackagesXavier.llama-cpp; jetson-orin = config.legacyPackages.llamaPackagesOrin.llama-cpp; jetson-nano = config.legacyPackages.llamaPackagesNano.llama-cpp; }; };}123456789101112131415161718192021222324252627282930313233343536373839404142434445{ inputs, ... }:{ # The _module.args definitions are passed on to modules as arguments. E.g. # the module `{ pkgs ... }: { /* config */ }` implicitly uses # `_module.args.pkgs` (defined in this case by flake-parts). perSystem = { system, ... }: { _module.args = { # Note: bringing up https://zimbatm.com/notes/1000-instances-of-nixpkgs # again, the below creates several nixpkgs instances which the # flake-centric CLI will be forced to evaluate e.g. on `nix flake show`. # # This is currently "slow" and "expensive", on a certain scale. # This also isn't "right" in that this hinders dependency injection at # the level of flake inputs. This might get removed in the foreseeable # future. # # Note that you can use these expressions without Nix # (`pkgs.callPackage ./devops/nix/scope.nix { }` is the entry point).
pkgsCuda = import inputs.nixpkgs { inherit system; # Ensure dependencies use CUDA consistently (e.g. that openmpi, ucc, # and ucx are built with CUDA support) config.cudaSupport = true; config.allowUnfreePredicate = p: builtins.all ( license: license.free || builtins.elem license.shortName [ "CUDA EULA" "cuDNN EULA" ] ) (p.meta.licenses or [ p.meta.license ]); }; # Ensure dependencies use ROCm consistently pkgsRocm = import inputs.nixpkgs { inherit system; config.rocmSupport = true; }; }; };}123456789101112131415161718192021222324252627282930313233343536{ lib, llamaVersion, numpy, tqdm, sentencepiece, pyyaml, poetry-core, buildPythonPackage, pytestCheckHook,}:
buildPythonPackage { pname = "gguf"; version = llamaVersion; pyproject = true; nativeBuildInputs = [ poetry-core ]; propagatedBuildInputs = [ numpy tqdm sentencepiece pyyaml ]; src = lib.cleanSource ../../gguf-py; pythonImportsCheck = [ "numpy" "gguf" ]; nativeCheckInputs = [ pytestCheckHook ]; doCheck = true; meta = with lib; { description = "Python package for writing binary files in the GGUF format"; license = licenses.mit; maintainers = [ maintainers.ditsuke ]; };}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246{ lib, glibc, config, stdenv, runCommand, cmake, ninja, pkg-config, git, mpi, blas, cudaPackages, autoAddDriverRunpath, darwin, rocmPackages, vulkan-headers, vulkan-loader, curl, shaderc, useBlas ? builtins.all (x: !x) [ useCuda useMetalKit useRocm useVulkan ] && blas.meta.available, useCuda ? config.cudaSupport, useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin, # Increases the runtime closure size by ~700M useMpi ? false, useRocm ? config.rocmSupport, enableCurl ? true, useVulkan ? false, llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
# It's necessary to consistently use backendStdenv when building with CUDA support, # otherwise we get libstdc++ errors downstream. effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv, enableStatic ? effectiveStdenv.hostPlatform.isStatic, precompileMetalShaders ? false,}:
let inherit (lib) cmakeBool cmakeFeature optionals strings ;
stdenv = throw "Use effectiveStdenv instead";
suffices = lib.optionals useBlas [ "BLAS" ] ++ lib.optionals useCuda [ "CUDA" ] ++ lib.optionals useMetalKit [ "MetalKit" ] ++ lib.optionals useMpi [ "MPI" ] ++ lib.optionals useRocm [ "ROCm" ] ++ lib.optionals useVulkan [ "Vulkan" ];
pnameSuffix = strings.optionalString (suffices != [ ]) "-${strings.concatMapStringsSep "-" strings.toLower suffices}"; descriptionSuffix = strings.optionalString ( suffices != [ ] ) ", accelerated with ${strings.concatStringsSep ", " suffices}";
xcrunHost = runCommand "xcrunHost" { } '' mkdir -p $out/bin ln -s /usr/bin/xcrun $out/bin '';
# apple_sdk is supposed to choose sane defaults, no need to handle isAarch64 # separately darwinBuildInputs = with darwin.apple_sdk.frameworks; [ Accelerate CoreVideo CoreGraphics ] ++ optionals useMetalKit [ MetalKit ];
cudaBuildInputs = with cudaPackages; [ cuda_cudart cuda_cccl # <nv/target> libcublas ];
rocmBuildInputs = with rocmPackages; [ clr hipblas rocblas ];
vulkanBuildInputs = [ vulkan-headers vulkan-loader shaderc ];in
effectiveStdenv.mkDerivation (finalAttrs: { pname = "llama-cpp${pnameSuffix}"; version = llamaVersion;
# Note: none of the files discarded here are visible in the sandbox or # affect the output hash. This also means they can be modified without # triggering a rebuild. src = lib.cleanSourceWith { filter = name: type: let noneOf = builtins.all (x: !x); baseName = baseNameOf name; in noneOf [ (lib.hasSuffix ".nix" name) # Ignore *.nix files when computing outPaths (lib.hasSuffix ".md" name) # Ignore *.md changes whe computing outPaths (lib.hasPrefix "." baseName) # Skip hidden files and directories (baseName == "flake.lock") ]; src = lib.cleanSource ../../.; };
postPatch = '' substituteInPlace ./ggml/src/ggml-metal/ggml-metal.m \ --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";" substituteInPlace ./ggml/src/ggml-metal/ggml-metal.m \ --replace '[bundle pathForResource:@"default" ofType:@"metallib"];' "@\"$out/bin/default.metallib\";" '';
# With PR#6015 https://github.com/ggerganov/llama.cpp/pull/6015, # `default.metallib` may be compiled with Metal compiler from XCode # and we need to escape sandbox on MacOS to access Metal compiler. # `xcrun` is used find the path of the Metal compiler, which is varible # and not on $PATH # see https://github.com/ggerganov/llama.cpp/pull/6118 for discussion __noChroot = effectiveStdenv.isDarwin && useMetalKit && precompileMetalShaders;
nativeBuildInputs = [ cmake ninja pkg-config git ] ++ optionals useCuda [ cudaPackages.cuda_nvcc
autoAddDriverRunpath ] ++ optionals (effectiveStdenv.hostPlatform.isGnu && enableStatic) [ glibc.static ] ++ optionals (effectiveStdenv.isDarwin && useMetalKit && precompileMetalShaders) [ xcrunHost ];
buildInputs = optionals effectiveStdenv.isDarwin darwinBuildInputs ++ optionals useCuda cudaBuildInputs ++ optionals useMpi [ mpi ] ++ optionals useRocm rocmBuildInputs ++ optionals useBlas [ blas ] ++ optionals useVulkan vulkanBuildInputs ++ optionals enableCurl [ curl ];
cmakeFlags = [ (cmakeBool "LLAMA_BUILD_SERVER" true) (cmakeBool "BUILD_SHARED_LIBS" (!enableStatic)) (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) (cmakeBool "LLAMA_CURL" enableCurl) (cmakeBool "GGML_NATIVE" false) (cmakeBool "GGML_BLAS" useBlas) (cmakeBool "GGML_CUDA" useCuda) (cmakeBool "GGML_HIP" useRocm) (cmakeBool "GGML_METAL" useMetalKit) (cmakeBool "GGML_VULKAN" useVulkan) (cmakeBool "GGML_STATIC" enableStatic) ] ++ optionals useCuda [ ( with cudaPackages.flags; cmakeFeature "CMAKE_CUDA_ARCHITECTURES" ( builtins.concatStringsSep ";" (map dropDot cudaCapabilities) ) ) ] ++ optionals useRocm [ (cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.llvm.clang}/bin/clang") (cmakeFeature "CMAKE_HIP_ARCHITECTURES" (builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets)) ] ++ optionals useMetalKit [ (lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1") (cmakeBool "GGML_METAL_EMBED_LIBRARY" (!precompileMetalShaders)) ];
# Environment variables needed for ROCm env = optionals useRocm { ROCM_PATH = "${rocmPackages.clr}"; HIP_DEVICE_LIB_PATH = "${rocmPackages.rocm-device-libs}/amdgcn/bitcode"; };
# TODO(SomeoneSerge): It's better to add proper install targets at the CMake level, # if they haven't been added yet. postInstall = '' mkdir -p $out/include cp $src/include/llama.h $out/include/ '';
meta = { # Configurations we don't want even the CI to evaluate. Results in the # "unsupported platform" messages. This is mostly a no-op, because # cudaPackages would've refused to evaluate anyway. badPlatforms = optionals useCuda lib.platforms.darwin;
# Configurations that are known to result in build failures. Can be # overridden by importing Nixpkgs with `allowBroken = true`. broken = (useMetalKit && !effectiveStdenv.isDarwin);
description = "Inference of LLaMA model in pure C/C++${descriptionSuffix}"; homepage = "https://github.com/ggerganov/llama.cpp/"; license = lib.licenses.mit;
# Accommodates `nix run` and `lib.getExe` mainProgram = "llama-cli";
# These people might respond, on the best effort basis, if you ping them # in case of Nix-specific regressions or for reviewing Nix-specific PRs. # Consider adding yourself to this list if you want to ensure this flake # stays maintained and you're willing to invest your time. Do not add # other people without their consent. Consider removing people after # they've been unreachable for long periods of time.
# Note that lib.maintainers is defined in Nixpkgs, but you may just add # an attrset following the same format as in # https://github.com/NixOS/nixpkgs/blob/f36a80e54da29775c78d7eff0e628c2b4e34d1d7/maintainers/maintainer-list.nix maintainers = with lib.maintainers; [ philiptaron SomeoneSerge ];
# Extend `badPlatforms` instead platforms = lib.platforms.all; };})123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566{ lib, stdenv, buildPythonPackage, poetry-core, mkShell, python3Packages, gguf-py,}@inputs:
let llama-python-deps = with python3Packages; [ numpy sentencepiece transformers protobuf torchWithoutCuda gguf-py tqdm
# for scripts/compare-llama-bench.py gitpython tabulate
# for examples/pydantic-models-to-grammar-examples.py docstring-parser pydantic
];
llama-python-test-deps = with python3Packages; [ # Server bench matplotlib
# server tests openai pytest prometheus-client ];in
buildPythonPackage ({ pname = "llama-scripts"; version = "0.0.0"; pyproject = true;
# NOTE: The files filtered out here are not visible in the build sandbox, neither # do they affect the output hash. They can be modified without triggering a rebuild. src = lib.cleanSourceWith { filter = name: type: let any = builtins.any (x: x); baseName = builtins.baseNameOf name; in any [ (lib.hasSuffix ".py" name) (baseName == "README.md") (baseName == "pyproject.toml") ]; src = lib.cleanSource ../../.; }; nativeBuildInputs = [ poetry-core ]; nativeCheckInputs = llama-python-test-deps; dependencies = llama-python-deps;})1234567891011121314151617181920212223242526272829303132333435363738394041{ lib, newScope, python3, llamaVersion ? "0.0.0",}:
let pythonPackages = python3.pkgs; buildPythonPackage = pythonPackages.buildPythonPackage; numpy = pythonPackages.numpy; tqdm = pythonPackages.tqdm; sentencepiece = pythonPackages.sentencepiece; pyyaml = pythonPackages.pyyaml; poetry-core = pythonPackages.poetry-core; pytestCheckHook = pythonPackages.pytestCheckHook;in
# We're using `makeScope` instead of just writing out an attrset# because it allows users to apply overlays later using `overrideScope'`.# Cf. https://noogle.dev/f/lib/makeScope
lib.makeScope newScope (self: { inherit llamaVersion; gguf-py = self.callPackage ./package-gguf-py.nix { inherit buildPythonPackage numpy tqdm sentencepiece poetry-core pyyaml pytestCheckHook ; }; python-scripts = self.callPackage ./python-scripts.nix { inherit buildPythonPackage poetry-core; }; llama-cpp = self.callPackage ./package.nix { }; docker = self.callPackage ./docker.nix { }; docker-min = self.callPackage ./docker.nix { interactive = false; }; sif = self.callPackage ./sif.nix { };})123456789101112131415161718192021222324252627{ lib, singularity-tools, llama-cpp, bashInteractive, interactive ? false,}:
let optionalInt = cond: x: if cond then x else 0;insingularity-tools.buildImage rec { inherit (llama-cpp) name; contents = [ llama-cpp ] ++ lib.optionals interactive [ bashInteractive ];
# These are excessive (but safe) for most variants. Building singularity # images requires superuser privileges, so we build them inside a VM in a # writable image of pre-determined size. # # ROCm is currently affected by https://github.com/NixOS/nixpkgs/issues/276846 # # Expected image sizes: # - cpu/blas: 150M, # - cuda, all gencodes: 560M, diskSize = 4096 + optionalInt llama-cpp.useRocm 16384; memSize = diskSize;}1234567891011121314151617181920212223242526272829303132333435363738394041#!/bin/bashset -e
# Read the first argument into a variablearg1="$1"
# Shift the arguments to remove the first oneshift
if [[ "$arg1" == '--convert' || "$arg1" == '-c' ]]; then python3 ./convert_hf_to_gguf.py "$@"elif [[ "$arg1" == '--quantize' || "$arg1" == '-q' ]]; then ./llama-quantize "$@"elif [[ "$arg1" == '--run' || "$arg1" == '-r' ]]; then ./llama-cli "$@"elif [[ "$arg1" == '--all-in-one' || "$arg1" == '-a' ]]; then echo "Converting PTH to GGML..." for i in `ls $1/$2/ggml-model-f16.bin*`; do if [ -f "${i/f16/q4_0}" ]; then echo "Skip model quantization, it already exists: ${i/f16/q4_0}" else echo "Converting PTH to GGML: $i into ${i/f16/q4_0}..." ./llama-quantize "$i" "${i/f16/q4_0}" q4_0 fi doneelif [[ "$arg1" == '--server' || "$arg1" == '-s' ]]; then ./llama-server "$@"else echo "Unknown command: $arg1" echo "Available commands: " echo " --run (-r): Run a model previously converted into ggml" echo " ex: -m /models/7B/ggml-model-q4_0.bin -p \"Building a website can be done in 10 simple steps:\" -n 512" echo " --convert (-c): Convert a llama model into ggml" echo " ex: --outtype f16 \"/models/7B/\" " echo " --quantize (-q): Optimize with quantization process ggml" echo " ex: \"/models/7B/ggml-model-f16.bin\" \"/models/7B/ggml-model-q4_0.bin\" 2" echo " --all-in-one (-a): Execute --convert & --quantize" echo " ex: \"/models/\" 7B" echo " --server (-s): Run a model on the server" echo " ex: -m /models/7B/ggml-model-q4_0.bin -c 2048 -ngl 43 -mg 1 --port 8080"fi1234567891011121314151617181920*.o*.a.cache/# Do not ignore .git directory, otherwise the reported build number will always be 0.github/.gitignore.vs/.vscode/.DS_Store
build*/
models/*
/llama-cli/llama-quantize
arm_neon.hcompile_commands.jsonDockerfile123456{ "Exclude": ["^\\.gitmodules$", "stb_image\\.h"], "Disable": { "IndentSize": true }}123456789101112131415161718192021222324252627282930313233343536373839404142# https://EditorConfig.org
# Top-most EditorConfig fileroot = true
# Unix-style newlines with a newline ending every file, utf-8 charset[*]end_of_line = lfinsert_final_newline = truetrim_trailing_whitespace = truecharset = utf-8indent_style = spaceindent_size = 4
[Makefile]indent_style = tab
[scripts/*.mk]indent_style = tab
[prompts/*.txt]insert_final_newline = unset
[examples/server/public/*]indent_size = 2
[examples/server/public/deps_*]trim_trailing_whitespace = unsetindent_style = unsetindent_size = unset
[examples/server/deps_*]trim_trailing_whitespace = unsetindent_style = unsetindent_size = unset
[examples/llama.swiftui/llama.swiftui.xcodeproj/*]indent_style = tab
[examples/cvector-generator/*.txt]trim_trailing_whitespace = unsetinsert_final_newline = unset1234567891011121314151617[flake8]max-line-length = 125ignore = E203,E211,E221,E225,E231,E241,E251,E261,E266,E501,E701,E704,W503exclude = # Do not traverse examples examples, # Do not include package initializers __init__.py, # No need to traverse our git directory .git, # There's no value in checking cache directories __pycache__, # No need to include the build path build, # This contains builds that we don't want to check dist # This is generated with `python build .` for package releases# max-complexity = 101234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677name: Bug (compilation)description: Something goes wrong when trying to compile llama.cpp.title: "Compile bug: "labels: ["bug-unconfirmed", "compilation"]body: - type: markdown attributes: value: > Thanks for taking the time to fill out this bug report! This issue template is intended for bug reports where the compilation of llama.cpp fails. Before opening an issue, please confirm that the compilation still fails with `-DGGML_CCACHE=OFF`. If the compilation succeeds with ccache disabled you should be able to permanently fix the issue by clearing `~/.cache/ccache` (on Linux). - type: textarea id: commit attributes: label: Git commit description: Which commit are you trying to compile? placeholder: | $git rev-parse HEAD 84a07a17b1b08cf2b9747c633a2372782848a27f validations: required: true - type: dropdown id: operating-system attributes: label: Operating systems description: Which operating systems do you know to be affected? multiple: true options: - Linux - Mac - Windows - BSD - Other? (Please let us know in description) validations: required: true - type: dropdown id: backends attributes: label: GGML backends description: Which GGML backends do you know to be affected? options: [AMX, BLAS, CPU, CUDA, HIP, Kompute, Metal, Musa, RPC, SYCL, Vulkan] multiple: true validations: required: true - type: textarea id: info attributes: label: Problem description & steps to reproduce description: > Please give us a summary of the problem and tell us how to reproduce it. If you can narrow down the bug to specific compile flags, that information would be very much appreciated by us. placeholder: > I'm trying to compile llama.cpp with CUDA support on a fresh install of Ubuntu and get error XY. Here are the exact commands that I used: ... validations: required: true - type: textarea id: first_bad_commit attributes: label: First Bad Commit description: > If the bug was not present on an earlier version: when did it start appearing? If possible, please do a git bisect and identify the exact commit that introduced the bug. validations: required: false - type: textarea id: logs attributes: label: Relevant log output description: > Please copy and paste any relevant log output, including the command that you entered and any generated text. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101name: Bug (model use)description: Something goes wrong when using a model (in general, not specific to a single llama.cpp module).title: "Eval bug: "labels: ["bug-unconfirmed", "model evaluation"]body: - type: markdown attributes: value: > Thanks for taking the time to fill out this bug report! This issue template is intended for bug reports where the model evaluation results (i.e. the generated text) are incorrect or llama.cpp crashes during model evaluation. If you encountered the issue while using an external UI (e.g. ollama), please reproduce your issue using one of the examples/binaries in this repository. The `llama-cli` binary can be used for simple and reproducible model inference. - type: textarea id: version attributes: label: Name and Version description: Which version of our software are you running? (use `--version` to get a version string) placeholder: | $./llama-cli --version version: 2999 (42b4109e) built with cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 for x86_64-linux-gnu validations: required: true - type: dropdown id: operating-system attributes: label: Operating systems description: Which operating systems do you know to be affected? multiple: true options: - Linux - Mac - Windows - BSD - Other? (Please let us know in description) validations: required: true - type: dropdown id: backends attributes: label: GGML backends description: Which GGML backends do you know to be affected? options: [AMX, BLAS, CPU, CUDA, HIP, Kompute, Metal, Musa, RPC, SYCL, Vulkan] multiple: true validations: required: true - type: textarea id: hardware attributes: label: Hardware description: Which CPUs/GPUs are you using? placeholder: > e.g. Ryzen 5950X + 2x RTX 4090 validations: required: true - type: textarea id: model attributes: label: Models description: > Which model(s) at which quantization were you using when encountering the bug? If you downloaded a GGUF file off of Huggingface, please provide a link. placeholder: > e.g. Meta LLaMA 3.1 Instruct 8b q4_K_M validations: required: false - type: textarea id: info attributes: label: Problem description & steps to reproduce description: > Please give us a summary of the problem and tell us how to reproduce it. If you can narrow down the bug to specific hardware, compile flags, or command line arguments, that information would be very much appreciated by us. placeholder: > e.g. when I run llama-cli with -ngl 99 I get garbled outputs. When I use -ngl 0 it works correctly. Here are the exact commands that I used: ... validations: required: true - type: textarea id: first_bad_commit attributes: label: First Bad Commit description: > If the bug was not present on an earlier version: when did it start appearing? If possible, please do a git bisect and identify the exact commit that introduced the bug. validations: required: false - type: textarea id: logs attributes: label: Relevant log output description: > Please copy and paste any relevant log output, including the command that you entered and any generated text. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081name: Bug (misc.)description: Something is not working the way it should (and it's not covered by any of the above cases).title: "Misc. bug: "labels: ["bug-unconfirmed"]body: - type: markdown attributes: value: > Thanks for taking the time to fill out this bug report! This issue template is intended for miscellaneous bugs that don't fit into any other category. If you encountered the issue while using an external UI (e.g. ollama), please reproduce your issue using one of the examples/binaries in this repository. - type: textarea id: version attributes: label: Name and Version description: Which version of our software is affected? (You can use `--version` to get a version string.) placeholder: | $./llama-cli --version version: 2999 (42b4109e) built with cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 for x86_64-linux-gnu validations: required: true - type: dropdown id: operating-system attributes: label: Operating systems description: Which operating systems do you know to be affected? multiple: true options: - Linux - Mac - Windows - BSD - Other? (Please let us know in description) validations: required: false - type: dropdown id: module attributes: label: Which llama.cpp modules do you know to be affected? multiple: true options: - Documentation/Github - libllama (core library) - llama-cli - llama-server - llama-bench - llama-quantize - Python/Bash scripts - Test code - Other (Please specify in the next section) validations: required: false - type: textarea id: info attributes: label: Problem description & steps to reproduce description: > Please give us a summary of the problem and tell us how to reproduce it (if applicable). validations: required: true - type: textarea id: first_bad_commit attributes: label: First Bad Commit description: > If the bug was not present on an earlier version and it's not trivial to track down: when did it start appearing? If possible, please do a git bisect and identify the exact commit that introduced the bug. validations: required: false - type: textarea id: logs attributes: label: Relevant log output description: > If applicable, please copy and paste any relevant log output, including the command that you entered and any generated text. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: false123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051name: Enhancementdescription: Used to request enhancements for llama.cpp.title: "Feature Request: "labels: ["enhancement"]body: - type: markdown attributes: value: | [Please post your idea first in Discussion if there is not yet a consensus for this enhancement request. This will help to keep this issue tracker focused on enhancements that the community has agreed needs to be implemented.](https://github.com/ggerganov/llama.cpp/discussions/categories/ideas)
- type: checkboxes id: prerequisites attributes: label: Prerequisites description: Please confirm the following before submitting your enhancement request. options: - label: I am running the latest code. Mention the version if possible as well. required: true - label: I carefully followed the [README.md](https://github.com/ggerganov/llama.cpp/blob/master/README.md). required: true - label: I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed). required: true - label: I reviewed the [Discussions](https://github.com/ggerganov/llama.cpp/discussions), and have a new and useful enhancement to share. required: true
- type: textarea id: feature-description attributes: label: Feature Description description: Please provide a detailed written description of what you were trying to do, and what you expected `llama.cpp` to do as an enhancement. placeholder: Detailed description of the enhancement validations: required: true
- type: textarea id: motivation attributes: label: Motivation description: Please provide a detailed written description of reasons why this feature is necessary and how it is useful to `llama.cpp` users. placeholder: Explanation of why this feature is needed and its benefits validations: required: true
- type: textarea id: possible-implementation attributes: label: Possible Implementation description: If you have an idea as to how it can be implemented, please write a detailed description. Feel free to give links to external sources or share visuals that might be helpful to understand the details better. placeholder: Detailed description of potential implementation validations: required: false12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152name: Researchdescription: Track new technical research area.title: "Research: "labels: ["research 🔬"]body: - type: markdown attributes: value: | Don't forget to check for any [duplicate research issue tickets](https://github.com/ggerganov/llama.cpp/issues?q=is%3Aopen+is%3Aissue+label%3A%22research+%F0%9F%94%AC%22)
- type: checkboxes id: research-stage attributes: label: Research Stage description: Track general state of this research ticket options: - label: Background Research (Let's try to avoid reinventing the wheel) - label: Hypothesis Formed (How do you think this will work and it's effect?) - label: Strategy / Implementation Forming - label: Analysis of results - label: Debrief / Documentation (So people in the future can learn from us)
- type: textarea id: background attributes: label: Previous existing literature and research description: Whats the current state of the art and whats the motivation for this research?
- type: textarea id: hypothesis attributes: label: Hypothesis description: How do you think this will work and it's effect?
- type: textarea id: implementation attributes: label: Implementation description: Got an approach? e.g. a PR ready to go?
- type: textarea id: analysis attributes: label: Analysis description: How does the proposed implementation behave?
- type: textarea id: logs attributes: label: Relevant log output description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. render: shell12345678910111213141516171819202122232425262728name: Refactor (Maintainers)description: Used to track refactoring opportunities.title: "Refactor: "labels: ["refactor"]body: - type: markdown attributes: value: | Don't forget to [check for existing refactor issue tickets](https://github.com/ggerganov/llama.cpp/issues?q=is%3Aopen+is%3Aissue+label%3Arefactoring) in case it's already covered. Also you may want to check [Pull request refactor label as well](https://github.com/ggerganov/llama.cpp/pulls?q=is%3Aopen+is%3Apr+label%3Arefactoring) for duplicates too.
- type: textarea id: background-description attributes: label: Background Description description: Please provide a detailed written description of the pain points you are trying to solve. placeholder: Detailed description behind your motivation to request refactor validations: required: true
- type: textarea id: possible-approaches attributes: label: Possible Refactor Approaches description: If you have some idea of possible approaches to solve this problem. You may want to make it a todo list. placeholder: Your idea of possible refactoring opportunity/approaches validations: required: false1234567891011blank_issues_enabled: truecontact_links: - name: Got an idea? url: https://github.com/ggerganov/llama.cpp/discussions/categories/ideas about: Pop it there. It may then become an enhancement ticket. - name: Got a question? url: https://github.com/ggerganov/llama.cpp/discussions/categories/q-a about: Ask a question there! - name: Want to contribute? url: https://github.com/ggerganov/llama.cpp/wiki/contribute about: Head to the contribution guide page of the wiki for areas you can help with1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586# https://github.com/actions/labelerKompute: - changed-files: - any-glob-to-any-file: - ggml/include/ggml-kompute.h - ggml/src/ggml-kompute/** - README-kompute.mdApple Metal: - changed-files: - any-glob-to-any-file: - ggml/include/ggml-metal.h - ggml/src/ggml-metal/** - README-metal.mdSYCL: - changed-files: - any-glob-to-any-file: - ggml/include/ggml-sycl.h - ggml/src/ggml-sycl/** - docs/backend/SYCL.md - examples/sycl/**Nvidia GPU: - changed-files: - any-glob-to-any-file: - ggml/include/ggml-cuda.h - ggml/src/ggml-cuda/**Vulkan: - changed-files: - any-glob-to-any-file: - ggml/include/ggml-vulkan.h - ggml/src/ggml-vulkan/**documentation: - changed-files: - any-glob-to-any-file: - docs/** - media/**testing: - changed-files: - any-glob-to-any-file: - tests/**build: - changed-files: - any-glob-to-any-file: - cmake/** - CMakeLists.txt - CMakePresets.jsonexamples: - changed-files: - any-glob-to-any-file: examples/**devops: - changed-files: - any-glob-to-any-file: - .devops/** - .github/** - ci/**python: - changed-files: - any-glob-to-any-file: - "**/*.py" - requirements/** - gguf-py/** - .flake8script: - changed-files: - any-glob-to-any-file: - scripts/**android: - changed-files: - any-glob-to-any-file: - examples/llama.android/**server: - changed-files: - any-glob-to-any-file: - examples/server/**ggml: - changed-files: - any-glob-to-any-file: - ggml/**nix: - changed-files: - any-glob-to-any-file: - "**/*.nix" - .github/workflows/nix-*.yml - .devops/nix/nixpkgs-instances.nixembedding: - changed-files: - any-glob-to-any-file: examples/embedding/1*Make sure to read the [contributing guidelines](https://github.com/ggerganov/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315# TODO: there have been some issues with the workflow, so disabling for now# https://github.com/ggerganov/llama.cpp/issues/7893## Benchmarkname: Benchmark
on: workflow_dispatch: inputs: gpu-series: description: 'Azure GPU series to run with' required: true type: choice options: - Standard_NC4as_T4_v3 - Standard_NC24ads_A100_v4 - Standard_NC80adis_H100_v5 sha: description: 'Commit SHA1 to build' required: false type: string duration: description: 'Duration of the bench' type: string default: 10m
push: branches: - master paths: ['llama.cpp', 'ggml.c', 'ggml-backend.cpp', 'ggml-quants.c', '**/*.cu', 'examples/server/*.h*', 'examples/server/*.cpp'] pull_request_target: types: [opened, synchronize, reopened] paths: ['llama.cpp', 'ggml.c', 'ggml-backend.cpp', 'ggml-quants.c', '**/*.cu', 'examples/server/*.h*', 'examples/server/*.cpp'] schedule: - cron: '04 2 * * *'
concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}-${{ github.event.inputs.sha }} cancel-in-progress: true
jobs: bench-server-baseline: runs-on: Standard_NC4as_T4_v3 env: RUNNER_LABEL: Standard_NC4as_T4_v3 # FIXME Do not find a way to not duplicate it N_USERS: 8 DURATION: 10m
strategy: matrix: model: [phi-2] ftype: [q4_0, q8_0, f16] include: - model: phi-2 ftype: q4_0 pr_comment_enabled: "true"
if: | inputs.gpu-series == 'Standard_NC4as_T4_v3' || ( github.event_name == 'schedule' && github.ref_name == 'master' && github.repository_owner == 'ggerganov' ) || github.event_name == 'pull_request_target' || ( github.event_name == 'push' && github.event.ref == 'refs/heads/master' && github.repository_owner == 'ggerganov' ) steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
- name: Install python env id: pipenv run: | cd examples/server/bench python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
- name: Prometheus id: install_prometheus run: | wget --quiet https://github.com/prometheus/prometheus/releases/download/v2.51.0/prometheus-2.51.0.linux-amd64.tar.gz tar xzf prometheus*.tar.gz --strip-components=1 ./prometheus --config.file=examples/server/bench/prometheus.yml & while ! nc -z localhost 9090; do sleep 0.1 done
- name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.21'
- name: Install k6 and xk6-sse id: k6_installation run: | cd examples/server/bench go install go.k6.io/xk6/cmd/xk6@latest xk6 build master \ --with github.com/phymbert/xk6-sse
- name: Build id: cmake_build run: | set -eux cmake -B build \ -DGGML_NATIVE=OFF \ -DLLAMA_BUILD_SERVER=ON \ -DLLAMA_CURL=ON \ -DLLAMA_CUBLAS=ON \ -DCUDAToolkit_ROOT=/usr/local/cuda \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ -DCMAKE_CUDA_ARCHITECTURES=75 \ -DLLAMA_FATAL_WARNINGS=OFF \ -DLLAMA_ALL_WARNINGS=OFF \ -DCMAKE_BUILD_TYPE=Release; cmake --build build --config Release -j $(nproc) --target llama-server
- name: Download the dataset id: download_dataset run: | cd examples/server/bench wget --quiet https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
- name: Server bench id: server_bench env: HEAD_REF: ${{ github.head_ref || github.ref_name }} run: | set -eux
cd examples/server/bench source venv/bin/activate python bench.py \ --runner-label ${{ env.RUNNER_LABEL }} \ --name ${{ github.job }} \ --branch $HEAD_REF \ --commit ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha }} \ --scenario script.js \ --duration ${{ github.event.inputs.duration || env.DURATION }} \ --hf-repo ggml-org/models \ --hf-file ${{ matrix.model }}/ggml-model-${{ matrix.ftype }}.gguf \ --model-path-prefix /models \ --parallel ${{ env.N_USERS }} \ -ngl 33 \ --batch-size 2048 \ --ubatch-size 256 \ --ctx-size 16384 \ --n-prompts 1000 \ --max-prompt-tokens 1024 \ --max-tokens 2048
cat results.github.env >> $GITHUB_ENV
# Remove dataset as we do not want it in the artefact rm ShareGPT_V3_unfiltered_cleaned_split.json
- uses: actions/upload-artifact@v4 with: name: bench-server-${{ github.job }}-${{ env.RUNNER_LABEL }}-${{ matrix.model }}-${{ matrix.ftype }} compression-level: 9 path: | examples/server/bench/*.jpg examples/server/bench/*.json examples/server/bench/*.log
- name: Commit status uses: Sibz/github-status-action@v1 with: authToken: ${{secrets.GITHUB_TOKEN}} sha: ${{ inputs.sha || github.event.pull_request.head.sha || github.sha }} context: bench-server-${{ github.job }}-${{ env.RUNNER_LABEL }}-${{ matrix.model }}-${{ matrix.ftype }} description: | ${{ env.BENCH_RESULTS }} state: 'success'
- name: Upload benchmark images uses: devicons/public-upload-to-imgur@v2.2.2 continue-on-error: true # Important as it looks unstable: 503 id: imgur_step with: client_id: ${{secrets.IMGUR_CLIENT_ID}} path: | examples/server/bench/prompt_tokens_seconds.jpg examples/server/bench/predicted_tokens_seconds.jpg examples/server/bench/kv_cache_usage_ratio.jpg examples/server/bench/requests_processing.jpg
- name: Extract mermaid id: set_mermaid run: | set -eux
cd examples/server/bench PROMPT_TOKENS_SECONDS=$(cat prompt_tokens_seconds.mermaid) echo "PROMPT_TOKENS_SECONDS<<EOF" >> $GITHUB_ENV echo "$PROMPT_TOKENS_SECONDS" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
PREDICTED_TOKENS_SECONDS=$(cat predicted_tokens_seconds.mermaid) echo "PREDICTED_TOKENS_SECONDS<<EOF" >> $GITHUB_ENV echo "$PREDICTED_TOKENS_SECONDS" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
KV_CACHE_USAGE_RATIO=$(cat kv_cache_usage_ratio.mermaid) echo "KV_CACHE_USAGE_RATIO<<EOF" >> $GITHUB_ENV echo "$KV_CACHE_USAGE_RATIO" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
REQUESTS_PROCESSING=$(cat requests_processing.mermaid) echo "REQUESTS_PROCESSING<<EOF" >> $GITHUB_ENV echo "$REQUESTS_PROCESSING" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
- name: Extract image url id: extract_image_url continue-on-error: true run: | set -eux
echo "IMAGE_O=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[0] }}" >> $GITHUB_ENV echo "IMAGE_1=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[1] }}" >> $GITHUB_ENV echo "IMAGE_2=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[2] }}" >> $GITHUB_ENV echo "IMAGE_3=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[3] }}" >> $GITHUB_ENV
- name: Comment PR uses: mshick/add-pr-comment@v2 id: comment_pr if: ${{ github.event.pull_request != '' && matrix.pr_comment_enabled == 'true' }} with: message-id: bench-server-${{ github.job }}-${{ env.RUNNER_LABEL }}-${{ matrix.model }}-${{ matrix.ftype }} message: | <p align="center">
📈 **llama.cpp server** for _${{ github.job }}_ on _${{ env.RUNNER_LABEL }}_ for `${{ matrix.model }}`-`${{ matrix.ftype }}`: **${{ env.BENCH_ITERATIONS}} iterations** 🚀
</p>
<details>
<summary>Expand details for performance related PR only</summary>
- Concurrent users: ${{ env.N_USERS }}, duration: ${{ github.event.inputs.duration || env.DURATION }} - HTTP request : avg=${{ env.HTTP_REQ_DURATION_AVG }}ms p(95)=${{ env.HTTP_REQ_DURATION_P_95_ }}ms fails=${{ env.HTTP_REQ_FAILED_PASSES }}, finish reason: stop=${{ env.LLAMACPP_COMPLETIONS_STOP_RATE_PASSES }} truncated=${{ env.LLAMACPP_COMPLETIONS_TRUNCATED_RATE_PASSES }} - Prompt processing (pp): avg=${{ env.LLAMACPP_PROMPT_PROCESSING_SECOND_AVG }}tk/s p(95)=${{ env.LLAMACPP_PROMPT_PROCESSING_SECOND_P_95_ }}tk/s - Token generation (tg): avg=${{ env.LLAMACPP_TOKENS_SECOND_AVG }}tk/s p(95)=${{ env.LLAMACPP_TOKENS_SECOND_P_95_ }}tk/s - ${{ env.BENCH_GRAPH_XLABEL }}
<p align="center">
<img width="100%" height="100%" src="${{ env.IMAGE_O }}" alt="prompt_tokens_seconds" />
<details>
<summary>More</summary>
```mermaid ${{ env.PROMPT_TOKENS_SECONDS }} ```
</details>
<img width="100%" height="100%" src="${{ env.IMAGE_1 }}" alt="predicted_tokens_seconds"/>
<details> <summary>More</summary>
```mermaid ${{ env.PREDICTED_TOKENS_SECONDS }} ```
</details>
</p>
<details>
<summary>Details</summary>
<p align="center">
<img width="100%" height="100%" src="${{ env.IMAGE_2 }}" alt="kv_cache_usage_ratio" />
<details> <summary>More</summary>
```mermaid ${{ env.KV_CACHE_USAGE_RATIO }} ```
</details>
<img width="100%" height="100%" src="${{ env.IMAGE_3 }}" alt="requests_processing"/>
<details> <summary>More</summary>
```mermaid ${{ env.REQUESTS_PROCESSING }} ```
</details>
</p> </details> </details>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416name: CI
on: workflow_dispatch: # allows manual triggering inputs: create_release: description: 'Create new release' required: true type: boolean push: branches: - master paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal'] pull_request: types: [opened, synchronize, reopened] paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
concurrency: group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} cancel-in-progress: true
# Fine-grant permission# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_tokenpermissions: contents: write # for creating release
env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} GGML_NLOOP: 3 GGML_N_THREADS: 1 LLAMA_LOG_COLORS: 1 LLAMA_LOG_PREFIX: 1 LLAMA_LOG_TIMESTAMPS: 1
jobs: macOS-latest-cmake-arm64: runs-on: macos-14
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Dependencies id: depends continue-on-error: true run: | brew update
- name: Build id: cmake_build run: | sysctl -a mkdir build cd build cmake .. \ -DLLAMA_FATAL_WARNINGS=ON \ -DLLAMA_CURL=ON \ -DGGML_METAL_USE_BF16=ON \ -DGGML_METAL_EMBED_LIBRARY=ON \ -DGGML_RPC=ON \ -DBUILD_SHARED_LIBS=OFF cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
- name: Test id: cmake_test run: | cd build ctest -L 'main|curl' --verbose --timeout 900
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Pack artifacts id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | cp LICENSE ./build/bin/ zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
- name: Upload artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip name: llama-bin-macos-arm64.zip
macOS-latest-cmake-x64: runs-on: macos-13
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Dependencies id: depends continue-on-error: true run: | brew update
- name: Build id: cmake_build run: | sysctl -a # Metal is disabled due to intermittent failures with Github runners not having a GPU: # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313 cmake -B build \ -DLLAMA_FATAL_WARNINGS=ON \ -DLLAMA_CURL=ON \ -DGGML_METAL=OFF \ -DGGML_RPC=ON \ -DBUILD_SHARED_LIBS=OFF cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
- name: Test id: cmake_test run: | cd build ctest -L main --verbose --timeout 900
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Pack artifacts id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | cp LICENSE ./build/bin/ zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
- name: Upload artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip name: llama-bin-macos-x64.zip
ubuntu-latest-cmake: runs-on: ubuntu-latest
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Dependencies id: depends run: | sudo apt-get update sudo apt-get install build-essential libcurl4-openssl-dev
- name: Build id: cmake_build run: | mkdir build cd build cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF cmake --build . --config Release -j $(nproc)
- name: Test id: cmake_test run: | cd build ctest -L 'main|curl' --verbose --timeout 900
- name: Test llama2c conversion id: llama2c_test run: | cd build echo "Fetch tokenizer" wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin echo "Fetch llama2c model" wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Pack artifacts id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | cp LICENSE ./build/bin/ zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
- name: Upload artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip name: llama-bin-ubuntu-x64.zip
ubuntu-latest-cmake-sanitizer: runs-on: ubuntu-latest
continue-on-error: true
strategy: matrix: sanitizer: [ADDRESS, THREAD, UNDEFINED] build_type: [Debug, Release]
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends run: | sudo apt-get update sudo apt-get install build-essential
- name: Build id: cmake_build if: ${{ matrix.sanitizer != 'THREAD' }} run: | mkdir build cd build cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
- name: Build (no OpenMP) id: cmake_build_no_openmp if: ${{ matrix.sanitizer == 'THREAD' }} run: | mkdir build cd build cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGGML_OPENMP=OFF cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
- name: Test id: cmake_test run: | cd build ctest -L main --verbose --timeout 900
ubuntu-latest-cmake-rpc: runs-on: ubuntu-latest
continue-on-error: true
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends run: | sudo apt-get update sudo apt-get install build-essential
- name: Build id: cmake_build run: | mkdir build cd build cmake -DGGML_RPC=ON .. cmake --build . --config Release -j $(nproc)
- name: Test id: cmake_test run: | cd build ctest -L main --verbose
ubuntu-22-cmake-vulkan: runs-on: ubuntu-22.04
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends run: | wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list sudo apt-get update -y sudo apt-get install -y build-essential vulkan-sdk
- name: Build id: cmake_build run: | mkdir build cd build cmake -DGGML_VULKAN=ON .. cmake --build . --config Release -j $(nproc)
ubuntu-22-cmake-hip: runs-on: ubuntu-22.04 container: rocm/dev-ubuntu-22.04:6.0.2
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends run: | sudo apt-get update sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
- name: Build with native CMake HIP support id: cmake_build run: | cmake -B build -S . -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DGGML_HIP=ON cmake --build build --config Release -j $(nproc)
- name: Build with legacy HIP support id: cmake_build_legacy_hip run: | cmake -B build2 -S . -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc -DGGML_HIP=ON cmake --build build2 --config Release -j $(nproc)
ubuntu-22-cmake-musa: runs-on: ubuntu-22.04 container: mthreads/musa:rc3.1.0-devel-ubuntu22.04
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends run: | apt-get update apt-get install -y build-essential git cmake libcurl4-openssl-dev
- name: Build with native CMake MUSA support id: cmake_build run: | cmake -B build -S . -DGGML_MUSA=ON cmake --build build --config Release -j $(nproc)
ubuntu-22-cmake-sycl: runs-on: ubuntu-22.04
continue-on-error: true
steps: - uses: actions/checkout@v4
- name: add oneAPI to apt shell: bash run: | cd /tmp wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
- name: install oneAPI dpcpp compiler shell: bash run: | sudo apt update sudo apt install intel-oneapi-compiler-dpcpp-cpp
- name: install oneAPI MKL library shell: bash run: | sudo apt install intel-oneapi-mkl-devel
- name: Clone id: checkout uses: actions/checkout@v4
- name: Build id: cmake_build run: | source /opt/intel/oneapi/setvars.sh mkdir build cd build cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx .. cmake --build . --config Release -j $(nproc)
ubuntu-22-cmake-sycl-fp16: runs-on: ubuntu-22.04
continue-on-error: true
steps: - uses: actions/checkout@v4
- name: add oneAPI to apt shell: bash run: | cd /tmp wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
- name: install oneAPI dpcpp compiler shell: bash run: | sudo apt update sudo apt install intel-oneapi-compiler-dpcpp-cpp
- name: install oneAPI MKL library shell: bash run: | sudo apt install intel-oneapi-mkl-devel
- name: Clone id: checkout uses: actions/checkout@v4
- name: Build id: cmake_build run: | source /opt/intel/oneapi/setvars.sh mkdir build cd build cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON .. cmake --build . --config Release -j $(nproc)
# TODO: build with GGML_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know # how to debug it. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584 # would be great if we fix these macOS-latest-cmake: runs-on: macos-latest
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends continue-on-error: true run: | brew update
- name: Build id: cmake_build run: | sysctl -a mkdir build cd build cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF .. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
- name: Test id: cmake_test run: | cd build ctest -L main --verbose --timeout 900
macOS-latest-cmake-ios: runs-on: macos-latest
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends continue-on-error: true run: | brew update
- name: Build id: cmake_build run: | sysctl -a mkdir build cd build cmake -G Xcode .. \ -DGGML_METAL_USE_BF16=ON \ -DGGML_METAL_EMBED_LIBRARY=ON \ -DLLAMA_BUILD_EXAMPLES=OFF \ -DLLAMA_BUILD_TESTS=OFF \ -DLLAMA_BUILD_SERVER=OFF \ -DCMAKE_SYSTEM_NAME=iOS \ -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \ -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
macOS-latest-cmake-tvos: runs-on: macos-latest
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Dependencies id: depends continue-on-error: true run: | brew update
- name: Build id: cmake_build run: | sysctl -a mkdir build cd build cmake -G Xcode .. \ -DGGML_METAL_USE_BF16=ON \ -DGGML_METAL_EMBED_LIBRARY=ON \ -DLLAMA_BUILD_EXAMPLES=OFF \ -DLLAMA_BUILD_TESTS=OFF \ -DLLAMA_BUILD_SERVER=OFF \ -DCMAKE_SYSTEM_NAME=tvOS \ -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \ -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
# TODO: tmp disabled. see for possible re-enable:# https://github.com/ggerganov/llama.cpp/pull/10525# macOS-latest-swift:# runs-on: macos-latest## strategy:# matrix:# destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']## steps:# - name: Clone# id: checkout# uses: actions/checkout@v4## - name: Dependencies# id: depends# continue-on-error: true# run: |# brew update## - name: xcodebuild for swift package# id: xcodebuild# run: |# xcodebuild -scheme llama -destination "${{ matrix.destination }}"## - name: Build Swift Example# id: make_build_swift_example# run: |# make swift
windows-msys2: runs-on: windows-latest
strategy: fail-fast: false matrix: include: - { sys: UCRT64, env: ucrt-x86_64, build: Release } - { sys: CLANG64, env: clang-x86_64, build: Release }
steps: - name: Clone uses: actions/checkout@v4
- name: Setup ${{ matrix.sys }} uses: msys2/setup-msys2@v2 with: update: true msystem: ${{matrix.sys}} install: >- base-devel mingw-w64-${{matrix.env}}-toolchain mingw-w64-${{matrix.env}}-cmake mingw-w64-${{matrix.env}}-openblas
- name: Build using CMake shell: msys2 {0} run: | cmake -B build cmake --build build --config ${{ matrix.build }} -j $(nproc)
- name: Clean after building using CMake shell: msys2 {0} run: | rm -rf build
- name: Build using CMake w/ OpenBLAS shell: msys2 {0} run: | cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS cmake --build build --config ${{ matrix.build }} -j $(nproc)
windows-latest-cmake: runs-on: windows-latest
env: OPENBLAS_VERSION: 0.3.23 SDE_VERSION: 9.33.0-2024-01-07 VULKAN_VERSION: 1.3.261.1
strategy: matrix: include: - build: 'noavx-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DBUILD_SHARED_LIBS=ON' - build: 'avx2-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=ON' - build: 'avx-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF -DBUILD_SHARED_LIBS=ON' - build: 'avx512-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON -DBUILD_SHARED_LIBS=ON' - build: 'openblas-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BLAS=ON -DBUILD_SHARED_LIBS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"' - build: 'kompute-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON' - build: 'vulkan-x64' defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=ON' - build: 'llvm-arm64' defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON' - build: 'msvc-arm64' defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Clone Kompute submodule id: clone_kompute if: ${{ matrix.build == 'kompute-x64' }} run: | git submodule update --init ggml/src/ggml-kompute/kompute
- name: Download OpenBLAS id: get_openblas if: ${{ matrix.build == 'openblas-x64' }} run: | curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip" curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE" mkdir $env:RUNNER_TEMP/openblas tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath) $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim())) $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe') & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
- name: Install Vulkan SDK id: get_vulkan if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }} run: | curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe" & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}" Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
- name: Install Ninja id: install_ninja run: | choco install ninja
- name: Build id: cmake_build run: | cmake -S . -B build ${{ matrix.defines }} cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
- name: Add libopenblas.dll id: add_libopenblas_dll if: ${{ matrix.build == 'openblas-x64' }} run: | cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
- name: Check AVX512F support id: check_avx512f if: ${{ matrix.build == 'avx512-x64' }} continue-on-error: true run: | cd build $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath) $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim())) $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe') echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
- name: Test id: cmake_test # not all machines have native AVX-512 if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }} run: | cd build ctest -L main -C Release --verbose --timeout 900
- name: Test (Intel SDE) id: cmake_test_sde if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation run: | curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz" # for some weird reason windows tar doesn't like sde tar.xz 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe) cd build $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1 & $sde -future -- ctest -L main -C Release --verbose --timeout 900
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Pack artifacts id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
- name: Upload artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip name: llama-bin-win-${{ matrix.build }}.zip
ubuntu-latest-cmake-cuda: runs-on: ubuntu-latest container: nvidia/cuda:12.6.2-devel-ubuntu24.04
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Install dependencies env: DEBIAN_FRONTEND: noninteractive run: | apt update apt install -y cmake build-essential ninja-build libgomp1 git
- name: Build with CMake run: | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=89-real -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined -DLLAMA_FATAL_WARNINGS=ON cmake --build build
windows-2019-cmake-cuda: runs-on: windows-2019
strategy: matrix: cuda: ['12.4', '11.7'] build: ['cuda']
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Install Cuda Toolkit 11.7 if: ${{ matrix.cuda == '11.7' }} run: | mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" choco install unzip -y curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-11.7.99-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-11.7.99-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-11.7.99-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-11.7.4.6-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-11.7.91-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-11.7.91-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-11.7.101-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-11.7.91-archive.zip" unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_cudart-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvcc-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvrtc-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libcublas-windows-x86_64-11.7.4.6-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvtx-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\visual_studio_integration-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvprof-windows-x86_64-11.7.101-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_cccl-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 echo "CUDA_PATH_V11_7=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Install Cuda Toolkit 12.4 if: ${{ matrix.cuda == '12.4' }} run: | mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" choco install unzip -y curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.4.127-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-12.4.131-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.4.127-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.4.5.8-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-12.4.127-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_profiler_api/windows-x86_64/cuda_profiler_api-windows-x86_64-12.4.127-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-12.4.127-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-12.4.127-archive.zip" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-12.4.127-archive.zip" unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_cudart-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvcc-windows-x86_64-12.4.131-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvrtc-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libcublas-windows-x86_64-12.4.5.8-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvtx-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_profiler_api-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\visual_studio_integration-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvprof-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_cccl-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 echo "CUDA_PATH_V12_4=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Install ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.job }}-${{ matrix.cuda }}-${{ matrix.build }}
- name: Install Ninja id: install_ninja run: | choco install ninja
- name: Build id: cmake_build shell: cmd run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cmake -S . -B build -G "Ninja Multi-Config" -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON -DGGML_RPC=ON set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1 cmake --build build --config Release -j %NINJA_JOBS% -t ggml cmake --build build --config Release
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Pack artifacts id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
- name: Upload artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
- name: Copy and pack Cuda runtime if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} run: | echo "Cuda install location: ${{ env.CUDA_PATH }}" $dst='.\build\bin\cudart\' robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
- name: Upload Cuda runtime if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
windows-latest-cmake-sycl: runs-on: windows-latest
defaults: run: shell: bash
env: WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b380d914-366b-4b77-a74a-05e3c38b3514/intel-oneapi-base-toolkit-2025.0.0.882_offline.exe WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI" steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Install run: | scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
- name: Build id: cmake_build run: examples/sycl/win-build-sycl.bat
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Build the release package id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
echo "cp oneAPI running time dll files to ./build/bin done" 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
- name: Upload the release package if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip name: llama-bin-win-sycl-x64.zip
windows-latest-cmake-hip: if: ${{ github.event.inputs.create_release != 'true' }} runs-on: windows-latest
steps: - name: Clone id: checkout uses: actions/checkout@v4
- name: Install id: depends run: | $ErrorActionPreference = "Stop" write-host "Downloading AMD HIP SDK Installer" Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe" write-host "Installing AMD HIP SDK" Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait write-host "Completed AMD HIP SDK installation"
- name: Verify ROCm id: verify run: | & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
- name: Install ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.job }}
- name: Build id: cmake_build run: | $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path) $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}" cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIP=ON -DCMAKE_BUILD_TYPE=Release -DGGML_RPC=ON cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
windows-latest-cmake-hip-release: if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} runs-on: windows-latest
strategy: matrix: gpu_target: [gfx1100, gfx1101, gfx1030]
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Install id: depends run: | $ErrorActionPreference = "Stop" write-host "Downloading AMD HIP SDK Installer" Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe" write-host "Installing AMD HIP SDK" Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait write-host "Completed AMD HIP SDK installation"
- name: Verify ROCm id: verify run: | & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
- name: Build id: cmake_build run: | $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path) $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}" cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIP=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS=${{ matrix.gpu_target }} -DGGML_RPC=ON cmake --build build -j ${env:NUMBER_OF_PROCESSORS} md "build\bin\rocblas\library\" cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\" cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\" cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Pack artifacts id: pack_artifacts run: | 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
- name: Upload artifacts uses: actions/upload-artifact@v4 with: path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
ios-xcode-build: runs-on: macos-latest
steps: - name: Checkout code uses: actions/checkout@v4
- name: Build Xcode project run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' build
android-build: runs-on: ubuntu-latest
steps: - name: Clone uses: actions/checkout@v4
- name: Set up JDK uses: actions/setup-java@v3 with: java-version: 17 distribution: zulu
- name: Setup Android SDK uses: android-actions/setup-android@v3 with: log-accepted-android-sdk-licenses: false
- name: Build run: | cd examples/llama.android
./gradlew build --no-daemon
# freeBSD-latest:# runs-on: macos-12# steps:# - name: Clone# uses: actions/checkout@v4## - name: Build# uses: cross-platform-actions/action@v0.19.0# with:# operating_system: freebsd# version: '13.2'# hypervisor: 'qemu'# run: |# sudo pkg update# sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas# gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
release: if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
runs-on: ubuntu-latest
needs: - ubuntu-latest-cmake - macOS-latest-cmake - windows-latest-cmake - windows-2019-cmake-cuda - windows-latest-cmake-hip-release - macOS-latest-cmake-arm64 - macOS-latest-cmake-x64
steps: - name: Clone id: checkout uses: actions/checkout@v4 with: fetch-depth: 0
- name: Determine tag name id: tag shell: bash run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT fi
- name: Download artifacts id: download-artifact uses: actions/download-artifact@v4 with: path: ./artifact
- name: Move artifacts id: move_artifacts run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
- name: Create release id: create_release uses: anzz1/action-create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.tag.outputs.name }}
- name: Upload release id: upload_release uses: actions/github-script@v3 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | const path = require('path'); const fs = require('fs'); const release_id = '${{ steps.create_release.outputs.id }}'; for (let file of await fs.readdirSync('./artifact/release')) { if (path.extname(file) === '.zip') { console.log('uploadReleaseAsset', file); await github.repos.uploadReleaseAsset({ owner: context.repo.owner, repo: context.repo.repo, release_id: release_id, name: file, data: await fs.readFileSync(`./artifact/release/${file}`) }); } }
# ubuntu-latest-gcc:# runs-on: ubuntu-latest## strategy:# matrix:# build: [Debug, Release]## steps:# - name: Clone# uses: actions/checkout@v4## - name: Dependencies# run: |# sudo apt-get update# sudo apt-get install build-essential# sudo apt-get install cmake## - name: Configure# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}## - name: Build# run: |# make## ubuntu-latest-clang:# runs-on: ubuntu-latest## strategy:# matrix:# build: [Debug, Release]## steps:# - name: Clone# uses: actions/checkout@v4## - name: Dependencies# run: |# sudo apt-get update# sudo apt-get install build-essential# sudo apt-get install cmake## - name: Configure# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang## - name: Build# run: |# make## ubuntu-latest-gcc-sanitized:# runs-on: ubuntu-latest## strategy:# matrix:# sanitizer: [ADDRESS, THREAD, UNDEFINED]## steps:# - name: Clone# uses: actions/checkout@v4## - name: Dependencies# run: |# sudo apt-get update# sudo apt-get install build-essential# sudo apt-get install cmake## - name: Configure# run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON## - name: Build# run: |# make## windows:# runs-on: windows-latest## strategy:# matrix:# build: [Release]# arch: [Win32, x64]# include:# - arch: Win32# s2arc: x86# - arch: x64# s2arc: x64## steps:# - name: Clone# uses: actions/checkout@v4## - name: Add msbuild to PATH# uses: microsoft/setup-msbuild@v1## - name: Configure# run: ># cmake -S . -B ./build -A ${{ matrix.arch }}# -DCMAKE_BUILD_TYPE=${{ matrix.build }}## - name: Build# run: |# cd ./build# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}## - name: Upload binaries# uses: actions/upload-artifact@v4# with:# name: llama-bin-${{ matrix.arch }}# path: build/bin/${{ matrix.build }}## windows-blas:# runs-on: windows-latest## strategy:# matrix:# build: [Release]# arch: [Win32, x64]# blas: [ON]# include:# - arch: Win32# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip# s2arc: x86# - arch: x64# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip# s2arc: x64## steps:# - name: Clone# uses: actions/checkout@v4## - name: Add msbuild to PATH# uses: microsoft/setup-msbuild@v1## - name: Fetch OpenBLAS# if: matrix.blas == 'ON'# run: |# C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}# 7z x blas.zip -oblas -y# copy blas/include/cblas.h .# copy blas/include/openblas_config.h .# echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV## - name: Configure# run: ># cmake -S . -B ./build -A ${{ matrix.arch }}# -DCMAKE_BUILD_TYPE=${{ matrix.build }}# -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}# -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"## - name: Build# run: |# cd ./build# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}## - name: Copy libopenblas.dll# if: matrix.blas == 'ON'# run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}## - name: Upload binaries# if: matrix.blas == 'ON'# uses: actions/upload-artifact@v4# with:# name: llama-blas-bin-${{ matrix.arch }}# path: build/bin/${{ matrix.build }}## emscripten:# runs-on: ubuntu-latest## strategy:# matrix:# build: [Release]## steps:# - name: Clone# uses: actions/checkout@v4## - name: Dependencies# run: |# wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz# tar -xvf master.tar.gz# emsdk-master/emsdk update# emsdk-master/emsdk install latest# emsdk-master/emsdk activate latest## - name: Configure# run: echo "tmp"## - name: Build# run: |# pushd emsdk-master# source ./emsdk_env.sh# popd# emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}# make12345678910111213141516171819202122232425262728name: Close inactive issueson: schedule: - cron: "42 0 * * *"
# Fine-grant permission# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_tokenpermissions: issues: write
jobs: close-issues: runs-on: ubuntu-latest permissions: issues: write pull-requests: write steps: - uses: actions/stale@v5 with: exempt-issue-labels: "refactor,help wanted,good first issue,research,bug" days-before-issue-stale: 30 days-before-issue-close: 14 stale-issue-label: "stale" close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." days-before-pr-stale: -1 days-before-pr-close: -1 operations-per-run: 10000 repo-token: ${{ secrets.GITHUB_TOKEN }}.gitattributes+23
llama.cpp/.clang-formatAdded+161
llama.cpp/.clang-tidyAdded+26
llama.cpp/.devops/cloud-v-pipelineAdded+22
llama.cpp/.devops/full-cuda.DockerfileAdded+33
llama.cpp/.devops/full-musa.DockerfileAdded+33
llama.cpp/.devops/full-rocm.DockerfileAdded+50
llama.cpp/.devops/full.DockerfileAdded+25
llama.cpp/.devops/llama-cli-cann.DockerfileAdded+44
llama.cpp/.devops/llama-cli-cuda.DockerfileAdded+38
llama.cpp/.devops/llama-cli-intel.DockerfileAdded+28
llama.cpp/.devops/llama-cli-musa.DockerfileAdded+38
llama.cpp/.devops/llama-cli-rocm.DockerfileAdded+45
llama.cpp/.devops/llama-cli-vulkan.DockerfileAdded+27
llama.cpp/.devops/llama-cli.DockerfileAdded+23
llama.cpp/.devops/llama-cpp-cuda.srpm.specAdded+83
llama.cpp/.devops/llama-cpp.srpm.specAdded+85
llama.cpp/.devops/llama-server-cuda.DockerfileAdded+43
llama.cpp/.devops/llama-server-intel.DockerfileAdded+34
llama.cpp/.devops/llama-server-musa.DockerfileAdded+43
llama.cpp/.devops/llama-server-rocm.DockerfileAdded+54
llama.cpp/.devops/llama-server-vulkan.DockerfileAdded+31
llama.cpp/.devops/llama-server.DockerfileAdded+41
llama.cpp/.devops/nix/apps.nixAdded+21
llama.cpp/.devops/nix/devshells.nixAdded+52
llama.cpp/.devops/nix/docker.nixAdded+37
llama.cpp/.devops/nix/jetson-support.nixAdded+39
llama.cpp/.devops/nix/nixpkgs-instances.nixAdded+45
llama.cpp/.devops/nix/package-gguf-py.nixAdded+36
llama.cpp/.devops/nix/package.nixAdded+246
llama.cpp/.devops/nix/python-scripts.nixAdded+66
llama.cpp/.devops/nix/scope.nixAdded+41
llama.cpp/.devops/nix/sif.nixAdded+27
llama.cpp/.devops/tools.shAdded+41
llama.cpp/.dockerignoreAdded+20
llama.cpp/.ecrcAdded+6
llama.cpp/.editorconfigAdded+42
llama.cpp/.flake8Added+17
llama.cpp/.github/ISSUE_TEMPLATE/010-bug-compilation.ymlAdded+77
llama.cpp/.github/ISSUE_TEMPLATE/011-bug-results.ymlAdded+101
llama.cpp/.github/ISSUE_TEMPLATE/019-bug-misc.ymlAdded+81
llama.cpp/.github/ISSUE_TEMPLATE/020-enhancement.ymlAdded+51
llama.cpp/.github/ISSUE_TEMPLATE/030-research.ymlAdded+52
llama.cpp/.github/ISSUE_TEMPLATE/040-refactor.ymlAdded+28
llama.cpp/.github/ISSUE_TEMPLATE/config.ymlAdded+11
llama.cpp/.github/labeler.ymlAdded+86
llama.cpp/.github/pull_request_template.mdAdded+1
llama.cpp/.github/workflows/bench.yml.disabledAdded+315
llama.cpp/.github/workflows/build.ymlAdded+1416
llama.cpp/.github/workflows/close-issue.ymlAdded+28