Skip to content

Commit 73bd64f

Browse files
authored
Merge branch 'master' into apertus-implementation
2 parents d009194 + f1fbffb commit 73bd64f

File tree

110 files changed

+12706
-6161
lines changed

Some content is hidden

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

110 files changed

+12706
-6161
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: 42 additions & 11 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: latest
140142

141143
steps:
142144
- name: Clone
@@ -1050,9 +1052,13 @@ jobs:
10501052
run: examples/sycl/win-build-sycl.bat
10511053

10521054
windows-latest-cmake-hip:
1053-
if: ${{ github.event.inputs.create_release != 'true' }}
10541055
runs-on: windows-2022
10551056

1057+
env:
1058+
# The ROCm version must correspond to the version used in the HIP SDK.
1059+
ROCM_VERSION: "6.4.2"
1060+
HIPSDK_INSTALLER_VERSION: "25.Q3"
1061+
10561062
steps:
10571063
- name: Clone
10581064
id: checkout
@@ -1061,23 +1067,46 @@ jobs:
10611067
- name: Clone rocWMMA repository
10621068
id: clone_rocwmma
10631069
run: |
1064-
git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
1070+
git clone https://github.com/rocm/rocwmma --branch rocm-${{ env.ROCM_VERSION }} --depth 1
10651071
1066-
- name: Install
1072+
- name: Cache ROCm Installation
1073+
id: cache-rocm
1074+
uses: actions/cache@v4
1075+
with:
1076+
path: C:\Program Files\AMD\ROCm
1077+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
1078+
1079+
- name: Install ROCm
1080+
if: steps.cache-rocm.outputs.cache-hit != 'true'
10671081
id: depends
10681082
run: |
10691083
$ErrorActionPreference = "Stop"
10701084
write-host "Downloading AMD HIP SDK Installer"
1071-
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"
1085+
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"
10721086
write-host "Installing AMD HIP SDK"
10731087
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
1074-
$proc.WaitForExit(600000)
1088+
$completed = $proc.WaitForExit(600000)
1089+
if (-not $completed) {
1090+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
1091+
$proc.Kill()
1092+
exit 1
1093+
}
1094+
if ($proc.ExitCode -ne 0) {
1095+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
1096+
exit 1
1097+
}
10751098
write-host "Completed AMD HIP SDK installation"
10761099
10771100
- name: Verify ROCm
10781101
id: verify
10791102
run: |
1080-
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
1103+
# Find and test ROCm installation
1104+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
1105+
if (-not $clangPath) {
1106+
Write-Error "ROCm installation not found"
1107+
exit 1
1108+
}
1109+
& $clangPath.FullName --version
10811110
10821111
- name: Install ccache
10831112
uses: ggml-org/[email protected]
@@ -1142,7 +1171,9 @@ jobs:
11421171
./build-xcframework.sh
11431172
11441173
- name: Build Xcode project
1145-
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
1174+
run: |
1175+
xcodebuild -downloadPlatform iOS
1176+
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
11461177
11471178
android-build:
11481179
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 38 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,29 +546,52 @@ 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
550+
551+
- name: Cache ROCm Installation
552+
id: cache-rocm
553+
uses: actions/cache@v4
554+
with:
555+
path: C:\Program Files\AMD\ROCm
556+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
546557

547558
- name: ccache
548559
uses: ggml-org/[email protected]
549560
with:
550-
key: windows-latest-cmake-hip-${{ matrix.name }}-x64
561+
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ matrix.name }}-x64
551562
evict-old-files: 1d
552563

553-
- name: Install
564+
- name: Install ROCm
565+
if: steps.cache-rocm.outputs.cache-hit != 'true'
554566
id: depends
555567
run: |
556568
$ErrorActionPreference = "Stop"
557569
write-host "Downloading AMD HIP SDK Installer"
558-
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"
559571
write-host "Installing AMD HIP SDK"
560572
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
561-
$proc.WaitForExit(600000)
573+
$completed = $proc.WaitForExit(600000)
574+
if (-not $completed) {
575+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
576+
$proc.Kill()
577+
exit 1
578+
}
579+
if ($proc.ExitCode -ne 0) {
580+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
581+
exit 1
582+
}
562583
write-host "Completed AMD HIP SDK installation"
563584
564585
- name: Verify ROCm
565586
id: verify
566587
run: |
567-
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
588+
# Find and test ROCm installation
589+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
590+
if (-not $clangPath) {
591+
Write-Error "ROCm installation not found"
592+
exit 1
593+
}
594+
& $clangPath.FullName --version
568595
569596
- name: Build
570597
id: cmake_build
@@ -585,9 +612,12 @@ jobs:
585612
-DLLAMA_CURL=OFF
586613
cmake --build build --target ggml-hip -j ${env:NUMBER_OF_PROCESSORS}
587614
md "build\bin\rocblas\library\"
615+
md "build\bin\hipblaslt\library"
588616
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
617+
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
589618
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
590619
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
620+
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
591621
592622
- name: Pack artifacts
593623
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)