Skip to content

Commit d61dd22

Browse files
authored
ci: add ROCm/HIP build to menlo-build.yml (#543)
Add Linux and Windows AMD GPU (ROCm/HIP) builds mirroring jan's release.yml. Linux installs rocm-hip-sdk via the radeon apt repo on the existing ubuntu-22-04 runner; Windows reuses windows-cuda-11-7, installs the AMD PRO HIP SDK (cached, gated on cache-hit) and bundles the rocblas/ hipblas runtime DLLs into the package. HIP compiler is exported via HIPCXX/HIP_PATH rather than passed through cmake-flags, since make would re-expand $(...)/${...} as make variables. Windows HIP needs clang as the C/CXX compiler plus DLL bundling that the shared make build-lib step can't express, so it gets a dedicated build step with the shared step gated off. Artifacts are named hip-common_cpus-x64 to match the canonical backend ids jan downloads (linux-hip-common_cpus-x64 / win-hip-common_cpus-x64).
1 parent 3dfe3cf commit d61dd22

1 file changed

Lines changed: 89 additions & 1 deletion

File tree

.github/workflows/menlo-build.yml

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ on:
2727

2828
env:
2929
VULKAN_VERSION: 1.4.328.1
30+
ROCM_VERSION: 7.2.1
31+
HIPSDK_INSTALLER_VERSION: "26.Q1"
3032

3133
jobs:
3234
create-draft-release:
@@ -198,6 +200,15 @@ jobs:
198200
vulkan: true
199201
ccache: true
200202
ccache-dir: "/home/runner/.ccache"
203+
- os: "linux"
204+
name: "hip-common_cpus-x64"
205+
runs-on: "ubuntu-22-04"
206+
cmake-flags: "-DLLAMA_CURL=OFF -DGGML_HIP=ON -DHIP_PLATFORM=amd -DGPU_TARGETS='gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201' -DGGML_HIP_ROCWMMA_FATTN=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_NATIVE=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH='$ORIGIN' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE='Release'"
207+
run-e2e: false
208+
vulkan: false
209+
rocm: true
210+
ccache: true
211+
ccache-dir: "/home/runner/.ccache"
201212
# DEPRECATED: macos-selfhosted-12 (Intel x64) runner is being phased out.
202213
# - os: "macos"
203214
# name: "x64"
@@ -359,6 +370,16 @@ jobs:
359370
vulkan: true
360371
ccache: true
361372
ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache'
373+
- os: "win"
374+
name: "hip-common_cpus-x64"
375+
runs-on: "windows-cuda-11-7"
376+
cmake-flags: ""
377+
run-e2e: false
378+
vulkan: false
379+
rocm: true
380+
gpu-targets: "gfx1150;gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
381+
ccache: false
382+
ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache'
362383
- os: "win"
363384
name: "arm64"
364385
runs-on: "windows-11-arm"
@@ -432,7 +453,49 @@ jobs:
432453
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
433454
sudo apt-get update -y
434455
sudo apt-get install -y build-essential vulkan-sdk
435-
456+
457+
- name: Prepare ROCm SDK Linux
458+
if: ${{ matrix.rocm && (matrix.os == 'linux') }}
459+
run: |
460+
sudo apt-get install -y build-essential git cmake wget
461+
sudo mkdir --parents --mode=0755 /etc/apt/keyrings
462+
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
463+
gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
464+
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${ROCM_VERSION} jammy main" \
465+
| sudo tee /etc/apt/sources.list.d/rocm.list
466+
printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600\n' \
467+
| sudo tee /etc/apt/preferences.d/rocm-pin-600
468+
sudo apt-get update
469+
sudo apt-get install -y libssl-dev rocm-hip-sdk rocwmma-dev
470+
# HIP compiler can't be passed via cmake-flags (make would re-expand $(...)), so export it.
471+
echo "HIPCXX=$(hipconfig -l)/clang" >> $GITHUB_ENV
472+
echo "HIP_PATH=$(hipconfig -R)" >> $GITHUB_ENV
473+
echo "/opt/rocm/bin" >> $GITHUB_PATH
474+
475+
- name: Cache ROCm install (Windows)
476+
id: cache-rocm-win
477+
if: ${{ matrix.rocm && (matrix.os == 'win') }}
478+
uses: actions/cache@v4
479+
with:
480+
path: 'C:\Program Files\AMD\ROCm'
481+
key: cache-gha-rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
482+
483+
- name: Prepare ROCm SDK Windows
484+
if: ${{ matrix.rocm && (matrix.os == 'win') }}
485+
run: |
486+
# rocWMMA headers ship only in the Linux .deb; extract them for the FATTN build.
487+
curl -o rocwmma.deb "https://repo.radeon.com/rocm/apt/${env:ROCM_VERSION}/pool/main/r/rocwmma-dev/rocwmma-dev_2.2.0.70201-81~24.04_amd64.deb"
488+
7z x rocwmma.deb
489+
7z x data.tar
490+
if ("${{ steps.cache-rocm-win.outputs.cache-hit }}" -ne "true") {
491+
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${env:HIPSDK_INSTALLER_VERSION}-Win11-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
492+
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
493+
$completed = $proc.WaitForExit(600000)
494+
if (-not $completed) { $proc.Kill(); throw "ROCm install timed out" }
495+
}
496+
$hipPath = (Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Split-Path | Split-Path)
497+
Add-Content $env:GITHUB_ENV "HIP_PATH=$hipPath"
498+
436499
- name: Install Clang for Windows Arm64
437500
if: ${{ matrix.os == 'win' && matrix.name == 'arm64' }}
438501
run: |
@@ -479,9 +542,34 @@ jobs:
479542

480543
- name: Build
481544
id: build-and-test
545+
if: ${{ !(matrix.os == 'win' && matrix.rocm) }}
482546
run: |
483547
make build-lib CMAKE_EXTRA_FLAGS="${{ matrix.cmake-flags }}"
484548
549+
- name: Build (Windows ROCm)
550+
if: ${{ matrix.os == 'win' && matrix.rocm }}
551+
run: |
552+
cmake -G "Unix Makefiles" -B build -S . `
553+
-DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
554+
-DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
555+
-DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/opt/rocm-${env:ROCM_VERSION}/include/ -Wno-ignored-attributes -Wno-nested-anon-types" `
556+
-DCMAKE_BUILD_TYPE=Release `
557+
-DLLAMA_CURL=OFF `
558+
-DLLAMA_BUILD_TESTS=OFF `
559+
-DLLAMA_BUILD_UI=OFF `
560+
-DGGML_BACKEND_DL=ON `
561+
-DGGML_CPU_ALL_VARIANTS=ON `
562+
-DGGML_NATIVE=OFF `
563+
-DBUILD_SHARED_LIBS=ON `
564+
-DGPU_TARGETS="${{ matrix.gpu-targets }}" `
565+
-DGGML_HIP_ROCWMMA_FATTN=ON `
566+
-DGGML_HIP=ON
567+
cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
568+
# Bundle ROCm runtime DLLs alongside the binaries so the artifact is self-contained.
569+
Copy-Item "${env:HIP_PATH}\bin\hipblas.dll","${env:HIP_PATH}\bin\hipblaslt.dll","${env:HIP_PATH}\bin\rocblas.dll" build\bin\ -ErrorAction SilentlyContinue
570+
Copy-Item "${env:HIP_PATH}\bin\rocblas\library" build\bin\rocblas\library -Recurse -Force -ErrorAction SilentlyContinue
571+
Copy-Item "${env:HIP_PATH}\bin\hipblaslt\library" build\bin\hipblaslt\library -Recurse -Force -ErrorAction SilentlyContinue
572+
485573
- uses: 1arp/create-a-file-action@0.4.5
486574
with:
487575
path: 'llama'

0 commit comments

Comments
 (0)