Skip to content

Commit 3a002af

Browse files
authored
ci : refactor sdk caching to minimize storage (ggml-org#16414)
* refactor sdk caching to minimize storage * use correct action * add myself as owner to /.github/actions/ [no ci]
1 parent a23b9bd commit 3a002af

File tree

9 files changed

+235
-45
lines changed

9 files changed

+235
-45
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Install exe"
2+
description: "Download and install exe"
3+
inputs:
4+
url:
5+
description: "URL of the exe installer"
6+
required: true
7+
args:
8+
description: "Installer arguments"
9+
required: true
10+
timeout:
11+
description: "Timeout (in ms)"
12+
required: false
13+
default: "600000"
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Install EXE
19+
shell: pwsh
20+
run: |
21+
$ErrorActionPreference = "Stop"
22+
write-host "Downloading Installer EXE"
23+
Invoke-WebRequest -Uri "${{ inputs.url }}" -OutFile "${env:RUNNER_TEMP}\temp-install.exe"
24+
write-host "Installing"
25+
$proc = Start-Process "${env:RUNNER_TEMP}\temp-install.exe" -ArgumentList '${{ inputs.args }}' -NoNewWindow -PassThru
26+
$completed = $proc.WaitForExit(${{ inputs.timeout }})
27+
if (-not $completed) {
28+
Write-Error "Installer timed out. Killing the process"
29+
$proc.Kill()
30+
exit 1
31+
}
32+
if ($proc.ExitCode -ne 0) {
33+
Write-Error "Installer failed with exit code $($proc.ExitCode)"
34+
exit 1
35+
}
36+
write-host "Completed installation"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "Linux - Setup SpacemiT Toolchain"
2+
description: "Setup SpacemiT Toolchain for Linux"
3+
inputs:
4+
path:
5+
description: "Installation path"
6+
required: true
7+
version:
8+
description: "SpacemiT toolchain version"
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Setup SpacemiT Toolchain
15+
id: setup
16+
uses: ./.github/actions/unarchive-tar
17+
with:
18+
url: https://archive.spacemit.com/toolchain/spacemit-toolchain-linux-glibc-x86_64-v${{ inputs.version }}.tar.xz
19+
path: ${{ inputs.path }}
20+
strip: 1
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "Linux - Setup Vulkan SDK"
2+
description: "Setup Vulkan SDK for Linux"
3+
inputs:
4+
path:
5+
description: "Installation path"
6+
required: true
7+
version:
8+
description: "Vulkan SDK version"
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Setup Vulkan SDK
15+
id: setup
16+
uses: ./.github/actions/unarchive-tar
17+
with:
18+
url: https://sdk.lunarg.com/sdk/download/${{ inputs.version }}/linux/vulkan_sdk.tar.xz
19+
path: ${{ inputs.path }}
20+
strip: 1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Unarchive tar"
2+
description: "Download and unarchive tar into directory"
3+
inputs:
4+
url:
5+
description: "URL of the tar archive"
6+
required: true
7+
path:
8+
description: "Directory to unarchive into"
9+
required: true
10+
type:
11+
description: "Compression type (tar option)"
12+
required: false
13+
default: "J"
14+
strip:
15+
description: "Strip components"
16+
required: false
17+
default: "0"
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Unarchive into directory
23+
shell: bash
24+
run: |
25+
mkdir -p ${{ inputs.path }}
26+
cd ${{ inputs.path }}
27+
curl --no-progress-meter ${{ inputs.url }} | tar -${{ inputs.type }}x --strip-components=${{ inputs.strip }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Windows - Setup ROCm"
2+
description: "Setup ROCm for Windows"
3+
inputs:
4+
version:
5+
description: "ROCm version"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Setup ROCm
12+
uses: ./.github/actions/install-exe
13+
with:
14+
url: https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ inputs.version }}-WinSvr2022-For-HIP.exe
15+
args: -install

.github/workflows/build-cache.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build Actions Cache
2+
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
schedule:
6+
- cron: '0 * * * *'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
ubuntu-24-vulkan-cache:
14+
runs-on: ubuntu-24.04
15+
16+
steps:
17+
- name: Clone
18+
id: checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Get latest Vulkan SDK version
22+
id: vulkan_sdk_version
23+
run: |
24+
echo "VULKAN_SDK_VERSION=$(curl https://vulkan.lunarg.com/sdk/latest/linux.txt)" >> "$GITHUB_ENV"
25+
26+
- name: Setup Cache
27+
uses: actions/cache@v4
28+
id: cache-sdk
29+
with:
30+
path: ./vulkan_sdk
31+
key: vulkan-sdk-${{ env.VULKAN_SDK_VERSION }}-${{ runner.os }}
32+
33+
- name: Setup Vulkan SDK
34+
if: steps.cache-sdk.outputs.cache-hit != 'true'
35+
uses: ./.github/actions/linux-setup-vulkan
36+
with:
37+
path: ./vulkan_sdk
38+
version: ${{ env.VULKAN_SDK_VERSION }}
39+
40+
ubuntu-24-spacemit-cache:
41+
runs-on: ubuntu-24.04
42+
43+
env:
44+
# Make sure this is in sync with build-linux-cross.yml
45+
SPACEMIT_IME_TOOLCHAIN_VERSION: "1.1.2"
46+
47+
steps:
48+
- name: Clone
49+
id: checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Cache
53+
uses: actions/cache@v4
54+
id: cache-toolchain
55+
with:
56+
path: ./spacemit_toolchain
57+
key: spacemit-ime-toolchain-v${{ env.SPACEMIT_IME_TOOLCHAIN_VERSION }}-${{ runner.os }}
58+
59+
- name: Setup SpacemiT Toolchain
60+
if: steps.cache-toolchain.outputs.cache-hit != 'true'
61+
uses: ./.github/actions/linux-setup-spacemit
62+
with:
63+
path: ./spacemit_toolchain
64+
version: ${{ env.SPACEMIT_IME_TOOLCHAIN_VERSION }}
65+
66+
windows-2022-rocm-cache:
67+
runs-on: windows-2022
68+
69+
env:
70+
# Make sure this is in sync with build.yml
71+
HIPSDK_INSTALLER_VERSION: "25.Q3"
72+
73+
steps:
74+
- name: Clone
75+
id: checkout
76+
uses: actions/checkout@v4
77+
78+
- name: Setup Cache
79+
uses: actions/cache@v4
80+
id: cache-rocm
81+
with:
82+
path: C:\Program Files\AMD\ROCm
83+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
84+
85+
- name: Setup ROCm
86+
if: steps.cache-rocm.outputs.cache-hit != 'true'
87+
uses: ./.github/actions/windows-setup-rocm
88+
with:
89+
version: ${{ env.HIPSDK_INSTALLER_VERSION }}

.github/workflows/build-linux-cross.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,29 @@ jobs:
258258
runs-on: ubuntu-24.04
259259

260260
env:
261+
# Make sure this is in sync with build-cache.yml
261262
SPACEMIT_IME_TOOLCHAIN_VERSION: "1.1.2"
262-
SPACEMIT_IME_TOOLCHAIN_PATH: "spacemit-toolchain-linux-glibc-x86_64"
263263

264264
steps:
265265
- uses: actions/checkout@v4
266266

267-
- name: Cache Toolchain
267+
- name: Use SpacemiT Toolchain Cache
268268
uses: actions/cache@v4
269-
id: cache-spacemit-ime-cross-toolchain
269+
id: cache-toolchain
270270
with:
271-
path: ./${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}
272-
key: ${{ runner.os }}-spacemit-ime-toolchain-v${{ env.SPACEMIT_IME_TOOLCHAIN_VERSION }}
271+
path: ./spacemit_toolchain
272+
key: spacemit-ime-toolchain-v${{ env.SPACEMIT_IME_TOOLCHAIN_VERSION }}-${{ runner.os }}
273273

274-
- name: Setup Toolchain
275-
if: steps.cache-spacemit-ime-cross-toolchain.outputs.cache-hit != 'true'
276-
run: |
277-
wget --quiet --no-check-certificate https://archive.spacemit.com/toolchain/spacemit-toolchain-linux-glibc-x86_64-v${{ env.SPACEMIT_IME_TOOLCHAIN_VERSION }}.tar.xz -O ${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}.tar.xz
278-
rm -rf ${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}
279-
mkdir -p ${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}
280-
tar xf ${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}.tar.xz -C ${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }} --strip-components=1
281-
rm -rf ${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}.tar.xz
274+
- name: Setup SpacemiT Toolchain
275+
if: steps.cache-toolchain.outputs.cache-hit != 'true'
276+
uses: ./.github/actions/linux-setup-spacemit
277+
with:
278+
path: ./spacemit_toolchain
279+
version: ${{ env.SPACEMIT_IME_TOOLCHAIN_VERSION }}
282280

283281
- name: Build
284282
run: |
285-
export RISCV_ROOT_PATH=${PWD}/${{ env.SPACEMIT_IME_TOOLCHAIN_PATH }}
283+
export RISCV_ROOT_PATH=${PWD}/spacemit_toolchain
286284
cmake -B build -DLLAMA_CURL=OFF \
287285
-DCMAKE_BUILD_TYPE=Release \
288286
-DGGML_OPENMP=OFF \

.github/workflows/build.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,19 @@ jobs:
413413
run: |
414414
echo "VULKAN_SDK_VERSION=$(curl https://vulkan.lunarg.com/sdk/latest/linux.txt)" >> "$GITHUB_ENV"
415415
416-
- name: Cache Vulkan SDK
417-
id: cache_vulkan_sdk
416+
- name: Use Vulkan SDK Cache
418417
uses: actions/cache@v4
418+
id: cache-sdk
419419
with:
420420
path: ./vulkan_sdk
421421
key: vulkan-sdk-${{ env.VULKAN_SDK_VERSION }}-${{ runner.os }}
422422

423-
- name: Install Vulkan SDK
424-
if: steps.cache_vulkan_sdk.outputs.cache-hit != 'true'
425-
id: vulkan_sdk_install
426-
run: |
427-
mkdir -p vulkan_sdk
428-
cd vulkan_sdk
429-
curl --no-progress-meter https://sdk.lunarg.com/sdk/download/latest/linux/vulkan_sdk.tar.xz | tar -Jx --strip-components=1
423+
- name: Setup Vulkan SDK
424+
if: steps.cache-sdk.outputs.cache-hit != 'true'
425+
uses: ./.github/actions/linux-setup-vulkan
426+
with:
427+
path: ./vulkan_sdk
428+
version: ${{ env.VULKAN_SDK_VERSION }}
430429

431430
- name: Build
432431
id: cmake_build
@@ -1111,6 +1110,7 @@ jobs:
11111110
env:
11121111
# The ROCm version must correspond to the version used in the HIP SDK.
11131112
ROCM_VERSION: "6.4.2"
1113+
# Make sure this is in sync with build-cache.yml
11141114
HIPSDK_INSTALLER_VERSION: "25.Q3"
11151115

11161116
steps:
@@ -1125,33 +1125,18 @@ jobs:
11251125
7z x rocwmma.deb
11261126
7z x data.tar
11271127
1128-
- name: Cache ROCm Installation
1129-
id: cache-rocm
1128+
- name: Use ROCm Installation Cache
11301129
uses: actions/cache@v4
1130+
id: cache-rocm
11311131
with:
11321132
path: C:\Program Files\AMD\ROCm
11331133
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
11341134

1135-
- name: Install ROCm
1135+
- name: Setup ROCm
11361136
if: steps.cache-rocm.outputs.cache-hit != 'true'
1137-
id: depends
1138-
run: |
1139-
$ErrorActionPreference = "Stop"
1140-
write-host "Downloading AMD HIP SDK Installer"
1141-
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"
1142-
write-host "Installing AMD HIP SDK"
1143-
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
1144-
$completed = $proc.WaitForExit(600000)
1145-
if (-not $completed) {
1146-
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
1147-
$proc.Kill()
1148-
exit 1
1149-
}
1150-
if ($proc.ExitCode -ne 0) {
1151-
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
1152-
exit 1
1153-
}
1154-
write-host "Completed AMD HIP SDK installation"
1137+
uses: ./.github/actions/windows-setup-rocm
1138+
with:
1139+
version: ${{ env.HIPSDK_INSTALLER_VERSION }}
11551140

11561141
- name: Verify ROCm
11571142
id: verify

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# multiplie collaborators per item can be specified
33

44
/.devops/*.Dockerfile @ngxson
5-
/.github/actions/ @slaren
5+
/.github/actions/ @slaren @CISC
66
/.github/workflows/ @CISC
77
/.github/workflows/release.yml @slaren
88
/.github/workflows/winget.yml @slaren

0 commit comments

Comments
 (0)