Skip to content

Commit 188ce93

Browse files
authored
Merge branch 'ggml-org:master' into PAD_REFLECT_1D_expriment
2 parents e280cb8 + 8ff2060 commit 188ce93

Some content is hidden

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

75 files changed

+10563
-5016
lines changed

.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ AllowShortIfStatementsOnASingleLine: Never
2222
AllowShortLambdasOnASingleLine: Inline
2323
AllowShortLoopsOnASingleLine: false
2424
AlwaysBreakBeforeMultilineStrings: true
25+
# Treat CUDA keywords/attributes as "attribute macros" and avoid breaking lines inside them
26+
AttributeMacros:
27+
- __host__
28+
- __device__
29+
- __global__
30+
- __forceinline__
31+
- __launch_bounds__
2532
BinPackArguments: true
2633
BinPackParameters: false # OnePerLine
2734
BitFieldColonSpacing: Both

.devops/rocm.Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG UBUNTU_VERSION=24.04
44
ARG ROCM_VERSION=6.4
55
ARG AMDGPU_VERSION=6.4
66

7-
# Target the CUDA build image
7+
# Target the ROCm build image
88
ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
99

1010
### Build image
@@ -15,16 +15,13 @@ FROM ${BASE_ROCM_DEV_CONTAINER} AS build
1515
# This is mostly tied to rocBLAS supported archs.
1616
# gfx803, gfx900, gfx1032, gfx1101, gfx1102,not officialy supported
1717
# gfx906 is deprecated
18-
#check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.2.4/reference/system-requirements.html
18+
#check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.4.1/reference/system-requirements.html
1919

20-
ARG ROCM_DOCKER_ARCH='gfx803,gfx900,gfx906,gfx908,gfx90a,gfx942,gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102'
21-
#ARG ROCM_DOCKER_ARCH=gfx1100
20+
ARG ROCM_DOCKER_ARCH='gfx803;gfx900;gfx906;gfx908;gfx90a;gfx942;gfx1010;gfx1030;gfx1032;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201;gfx1151'
21+
#ARG ROCM_DOCKER_ARCH='gfx1151'
2222

23-
# Set nvcc architectured
23+
# Set ROCm architectures
2424
ENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}
25-
# Enable ROCm
26-
# ENV CC=/opt/rocm/llvm/bin/clang
27-
# ENV CXX=/opt/rocm/llvm/bin/clang++
2825

2926
RUN apt-get update \
3027
&& apt-get install -y \
@@ -39,8 +36,16 @@ WORKDIR /app
3936

4037
COPY . .
4138

39+
RUN git clone https://github.com/rocm/rocwmma --branch develop --depth 1
40+
4241
RUN HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \
43-
cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=$ROCM_DOCKER_ARCH -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_TESTS=OFF \
42+
cmake -S . -B build \
43+
-DGGML_HIP=ON \
44+
-DGGML_HIP_ROCWMMA_FATTN=ON \
45+
-DCMAKE_HIP_FLAGS="-I$(pwd)/rocwmma/library/include/" \
46+
-DAMDGPU_TARGETS="$ROCM_DOCKER_ARCH" \
47+
-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON \
48+
-DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_TESTS=OFF \
4449
&& cmake --build build --config Release -j$(nproc)
4550

4651
RUN mkdir -p /app/lib \

.github/workflows/build.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ env:
5656

5757
jobs:
5858
macOS-latest-cmake-arm64:
59-
runs-on: macos-14
59+
runs-on: macos-latest
6060

6161
steps:
6262
- name: Clone
@@ -88,6 +88,7 @@ jobs:
8888
-DGGML_METAL_SHADER_DEBUG=ON \
8989
-DGGML_RPC=ON
9090
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
91+
leaks -atExit -- ./build/bin/test-thread-safety -hf ggml-org/gemma-3-270m-qat-GGUF -ngl 99 -p "$(printf 'hello %.0s' {1..128})" -n 16 -c 512 -ub 32 -np 2 -t 2 -lv 1
9192
9293
- name: Test
9394
id: cmake_test
@@ -96,7 +97,7 @@ jobs:
9697
ctest -L 'main|curl' --verbose --timeout 900
9798
9899
macOS-latest-cmake-x64:
99-
runs-on: macos-13
100+
runs-on: macos-latest
100101

101102
steps:
102103
- name: Clone
@@ -126,7 +127,8 @@ jobs:
126127
-DCMAKE_BUILD_RPATH="@loader_path" \
127128
-DLLAMA_FATAL_WARNINGS=ON \
128129
-DGGML_METAL=OFF \
129-
-DGGML_RPC=ON
130+
-DGGML_RPC=ON \
131+
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
130132
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
131133
132134
- name: Test
@@ -136,7 +138,7 @@ jobs:
136138
ctest -L main --verbose --timeout 900
137139
138140
macOS-latest-cmake-arm64-webgpu:
139-
runs-on: macos-14
141+
runs-on: macos-latest
140142

141143
steps:
142144
- name: Clone
@@ -709,6 +711,7 @@ jobs:
709711
710712
macOS-latest-swift:
711713
runs-on: macos-latest
714+
needs: ios-xcode-build
712715

713716
strategy:
714717
matrix:
@@ -725,6 +728,12 @@ jobs:
725728
key: macOS-latest-swift
726729
evict-old-files: 1d
727730

731+
- name: Download xcframework artifact
732+
uses: actions/download-artifact@v4
733+
with:
734+
name: llama-xcframework
735+
path: build-apple/llama.xcframework/
736+
728737
- name: Dependencies
729738
id: depends
730739
continue-on-error: true
@@ -746,11 +755,6 @@ jobs:
746755
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
747756
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
748757
749-
- name: xcodebuild for swift package
750-
id: xcodebuild
751-
run: |
752-
./build-xcframework.sh
753-
754758
windows-msys2:
755759
runs-on: windows-2025
756760

@@ -1050,9 +1054,13 @@ jobs:
10501054
run: examples/sycl/win-build-sycl.bat
10511055

10521056
windows-latest-cmake-hip:
1053-
if: ${{ github.event.inputs.create_release != 'true' }}
10541057
runs-on: windows-2022
10551058

1059+
env:
1060+
# The ROCm version must correspond to the version used in the HIP SDK.
1061+
ROCM_VERSION: "6.4.2"
1062+
HIPSDK_INSTALLER_VERSION: "25.Q3"
1063+
10561064
steps:
10571065
- name: Clone
10581066
id: checkout
@@ -1061,24 +1069,22 @@ jobs:
10611069
- name: Clone rocWMMA repository
10621070
id: clone_rocwmma
10631071
run: |
1064-
git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
1072+
git clone https://github.com/rocm/rocwmma --branch rocm-${{ env.ROCM_VERSION }} --depth 1
10651073
10661074
- name: Cache ROCm Installation
10671075
id: cache-rocm
10681076
uses: actions/cache@v4
10691077
with:
10701078
path: C:\Program Files\AMD\ROCm
1071-
key: rocm-6.1-${{ runner.os }}-v1
1072-
restore-keys: |
1073-
rocm-6.1-${{ runner.os }}-
1079+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
10741080

10751081
- name: Install ROCm
10761082
if: steps.cache-rocm.outputs.cache-hit != 'true'
10771083
id: depends
10781084
run: |
10791085
$ErrorActionPreference = "Stop"
10801086
write-host "Downloading AMD HIP SDK Installer"
1081-
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"
1087+
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ env.HIPSDK_INSTALLER_VERSION }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
10821088
write-host "Installing AMD HIP SDK"
10831089
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
10841090
$completed = $proc.WaitForExit(600000)
@@ -1166,8 +1172,17 @@ jobs:
11661172
run: |
11671173
./build-xcframework.sh
11681174
1175+
- name: Upload xcframework artifact
1176+
uses: actions/upload-artifact@v4
1177+
with:
1178+
name: llama-xcframework
1179+
path: build-apple/llama.xcframework/
1180+
retention-days: 1
1181+
11691182
- name: Build Xcode project
1170-
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' FRAMEWORK_FOLDER_PATH=./build-ios build
1183+
run: |
1184+
xcodebuild -downloadPlatform iOS
1185+
xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' FRAMEWORK_FOLDER_PATH=./build-ios build
11711186
11721187
android-build:
11731188
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ jobs:
108108
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
109109
-DLLAMA_FATAL_WARNINGS=ON \
110110
-DGGML_METAL=OFF \
111-
-DGGML_RPC=ON
111+
-DGGML_RPC=ON \
112+
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
112113
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
113114
114115
- name: Determine tag name
@@ -528,11 +529,14 @@ jobs:
528529
windows-hip:
529530
runs-on: windows-2022
530531

532+
env:
533+
HIPSDK_INSTALLER_VERSION: "25.Q3"
534+
531535
strategy:
532536
matrix:
533537
include:
534538
- name: "radeon"
535-
gpu_targets: "gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
539+
gpu_targets: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
536540

537541
steps:
538542
- name: Clone
@@ -542,21 +546,19 @@ jobs:
542546
- name: Clone rocWMMA repository
543547
id: clone_rocwmma
544548
run: |
545-
git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
549+
git clone https://github.com/rocm/rocwmma --branch develop --depth 1
546550
547551
- name: Cache ROCm Installation
548552
id: cache-rocm
549553
uses: actions/cache@v4
550554
with:
551555
path: C:\Program Files\AMD\ROCm
552-
key: rocm-6.1-${{ runner.os }}-v1
553-
restore-keys: |
554-
rocm-6.1-${{ runner.os }}-
556+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
555557

556558
- name: ccache
557559
uses: ggml-org/[email protected]
558560
with:
559-
key: windows-latest-cmake-hip-${{ matrix.name }}-x64
561+
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ matrix.name }}-x64
560562
evict-old-files: 1d
561563

562564
- name: Install ROCm
@@ -565,7 +567,7 @@ jobs:
565567
run: |
566568
$ErrorActionPreference = "Stop"
567569
write-host "Downloading AMD HIP SDK Installer"
568-
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"
570+
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ env.HIPSDK_INSTALLER_VERSION }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
569571
write-host "Installing AMD HIP SDK"
570572
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
571573
$completed = $proc.WaitForExit(600000)
@@ -610,9 +612,12 @@ jobs:
610612
-DLLAMA_CURL=OFF
611613
cmake --build build --target ggml-hip -j ${env:NUMBER_OF_PROCESSORS}
612614
md "build\bin\rocblas\library\"
615+
md "build\bin\hipblaslt\library"
613616
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
617+
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
614618
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
615619
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
620+
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
616621
617622
- name: Pack artifacts
618623
id: pack_artifacts

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ if (MSVC)
5858
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
5959
endif()
6060

61+
if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
62+
set(LLAMA_TOOLS_INSTALL_DEFAULT OFF)
63+
else()
64+
set(LLAMA_TOOLS_INSTALL_DEFAULT ${LLAMA_STANDALONE})
65+
endif()
66+
6167
#
6268
# option list
6369
#
@@ -82,6 +88,7 @@ option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
8288
option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
8389
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
8490
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
91+
option(LLAMA_TOOLS_INSTALL "llama: install tools" ${LLAMA_TOOLS_INSTALL_DEFAULT})
8592

8693
# 3rd party libs
8794
option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON)

ci/run.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ function gg_run_ctest_with_model_debug {
270270
local model; model=$(gg_get_model)
271271
cd build-ci-debug
272272
set -e
273+
273274
(LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
275+
274276
set +e
275277
cd ..
276278
}
@@ -281,7 +283,15 @@ function gg_run_ctest_with_model_release {
281283
local model; model=$(gg_get_model)
282284
cd build-ci-release
283285
set -e
286+
284287
(LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
288+
289+
# test memory leaks
290+
#if [[ ! -z ${GG_BUILD_METAL} ]]; then
291+
# # TODO: this hangs for some reason ...
292+
# (time leaks -quiet -atExit -- ./bin/test-thread-safety -m $model --parallel 2 -t 2 -p "hello") 2>&1 | tee -a $OUT/${ci}-leaks.log
293+
#fi
294+
285295
set +e
286296
cd ..
287297
}
@@ -860,20 +870,15 @@ if [ -z ${GG_BUILD_LOW_PERF} ]; then
860870
fi
861871

862872
ret=0
863-
if [ -z ${GG_BUILD_SYCL} ]; then
864-
# SYCL build breaks with debug build flags
865-
test $ret -eq 0 && gg_run ctest_debug
866-
fi
873+
test $ret -eq 0 && gg_run ctest_debug
867874
test $ret -eq 0 && gg_run ctest_release
868875

869876
if [ -z ${GG_BUILD_LOW_PERF} ]; then
870877
test $ret -eq 0 && gg_run embd_bge_small
871878
test $ret -eq 0 && gg_run rerank_tiny
872879

873880
if [ -z ${GG_BUILD_CLOUD} ] || [ ${GG_BUILD_EXTRA_TESTS_0} ]; then
874-
if [ -z ${GG_BUILD_SYCL} ]; then
875-
test $ret -eq 0 && gg_run test_scripts_debug
876-
fi
881+
test $ret -eq 0 && gg_run test_scripts_debug
877882
test $ret -eq 0 && gg_run test_scripts_release
878883
fi
879884

@@ -884,9 +889,7 @@ if [ -z ${GG_BUILD_LOW_PERF} ]; then
884889
test $ret -eq 0 && gg_run pythia_2_8b
885890
#test $ret -eq 0 && gg_run open_llama_7b_v2
886891
fi
887-
if [ -z ${GG_BUILD_SYCL} ]; then
888-
test $ret -eq 0 && gg_run ctest_with_model_debug
889-
fi
892+
test $ret -eq 0 && gg_run ctest_with_model_debug
890893
test $ret -eq 0 && gg_run ctest_with_model_release
891894
fi
892895
fi

0 commit comments

Comments
 (0)