11name : Build Wheels (ROCm)
22
3- on : workflow_dispatch
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ release_tag :
7+ description : Release tag to upload wheel assets to
8+ required : false
9+ type : string
10+ amdgpu_targets :
11+ description : AMDGPU targets to compile into the Linux ROCm wheel
12+ required : false
13+ default : gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1200;gfx1201
14+ windows_amdgpu_targets :
15+ description : AMDGPU targets to compile into the Windows HIP Radeon wheel
16+ required : false
17+ default : gfx1150;gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032
418
519permissions :
620 contents : write
2438 - name : Install system dependencies
2539 run : |
2640 apt-get update
27- apt-get install -y --no-install-recommends git cmake lsb-release ninja-build
41+ apt-get install -y --no-install-recommends git cmake lsb-release ninja-build patchelf
2842
2943 - uses : actions/checkout@v6
3044 with :
3751 - name : Install build dependencies
3852 run : |
3953 python -m pip install --upgrade pip
40- python -m pip install build wheel
54+ python -m pip install auditwheel build wheel
4155
4256 - name : Build ROCm wheel
57+ env :
58+ MATRIX_AMDGPU_TARGETS : ${{ matrix.amdgpu_targets }}
59+ INPUT_AMDGPU_TARGETS : ${{ inputs.amdgpu_targets }}
4360 run : |
4461 export ROCM_PATH="${ROCM_PATH:-/opt/rocm}"
4562 export HIP_PATH="${HIP_PATH:-$ROCM_PATH}"
@@ -56,11 +73,38 @@ jobs:
5673 rocm_tag="$(hipconfig --version | sed -E 's/^([0-9]+)\.([0-9]+).*/\1\2/')"
5774 echo "ROCM_VERSION=$rocm_tag" >> "$GITHUB_ENV"
5875
59- amdgpu_targets="${{ matrix.amdgpu_targets } }"
60- export CMAKE_ARGS="-DGGML_HIP=on -DGGML_NATIVE=off -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off -DAMDGPU_TARGETS=$amdgpu_targets -DCMAKE_HIP_ARCHITECTURES=$amdgpu_targets"
76+ amdgpu_targets="${INPUT_AMDGPU_TARGETS:-$MATRIX_AMDGPU_TARGETS }"
77+ export CMAKE_ARGS="-DGGML_HIP=on -DGGML_NATIVE=off -DGGML_OPENMP=OFF - DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off -DAMDGPU_TARGETS=$amdgpu_targets -DCMAKE_HIP_ARCHITECTURES=$amdgpu_targets"
6178 python -m build --wheel
79+
80+ - name : Repair Linux wheel
81+ run : |
82+ export ROCM_PATH="${ROCM_PATH:-/opt/rocm}"
83+ export LD_LIBRARY_PATH="$ROCM_PATH/lib:$ROCM_PATH/lib64:${LD_LIBRARY_PATH:-}"
6284 mkdir -p wheelhouse
63- cp dist/*.whl wheelhouse/
85+ python -m auditwheel repair \
86+ --exclude libamdhip64.so \
87+ --exclude libamdhip64.so.6 \
88+ --exclude libamdhip64.so.7 \
89+ --exclude libhiprtc.so \
90+ --exclude libhiprtc.so.6 \
91+ --exclude libhiprtc.so.7 \
92+ --exclude libhipblas.so \
93+ --exclude libhipblas.so.2 \
94+ --exclude libhipblas.so.3 \
95+ --exclude libhipblaslt.so \
96+ --exclude libhipblaslt.so.0 \
97+ --exclude libhipblaslt.so.1 \
98+ --exclude librocblas.so \
99+ --exclude librocblas.so.4 \
100+ --exclude librocblas.so.5 \
101+ --exclude libhsa-runtime64.so.1 \
102+ --exclude libhsakmt.so.1 \
103+ -w wheelhouse \
104+ dist/*.whl
105+ rm dist/*.whl
106+ cp wheelhouse/*.whl dist/
107+ python -m auditwheel show dist/*.whl
64108
65109 - uses : actions/upload-artifact@v7
66110 with :
@@ -139,11 +183,14 @@ jobs:
139183 & $clangPath.FullName --version
140184
141185 - name : Build HIP wheel
186+ env :
187+ MATRIX_AMDGPU_TARGETS : ${{ matrix.amdgpu_targets }}
188+ INPUT_AMDGPU_TARGETS : ${{ inputs.windows_amdgpu_targets }}
142189 run : |
143190 $ErrorActionPreference = "Stop"
144191 $hipPath = Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Split-Path | Split-Path
145192 $rocwmmaInclude = (Join-Path $PWD 'opt\rocm-7.2.1\include').Replace('\', '/')
146- $amdgpuTargets = "${{ matrix.amdgpu_targets }}"
193+ $amdgpuTargets = if ($env:INPUT_AMDGPU_TARGETS) { $env:INPUT_AMDGPU_TARGETS } else { $env:MATRIX_AMDGPU_TARGETS }
147194
148195 $env:HIP_PATH = $hipPath
149196 $env:ROCM_PATH = $hipPath
@@ -198,7 +245,7 @@ jobs:
198245 release_rocm :
199246 name : Release ROCm
200247 needs : [build_wheels]
201- if : startsWith(github.ref, 'refs/tags/')
248+ if : startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
202249 runs-on : ubuntu-latest
203250
204251 steps :
@@ -211,14 +258,14 @@ jobs:
211258 with :
212259 files : dist/*
213260 # Set release name to <tag>-rocm<rocm_version>.
214- tag_name : ${{ github.ref_name }}-rocm72
261+ tag_name : ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github. ref_name }}-rocm72
215262 env :
216263 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
217264
218265 release_hip :
219266 name : Release HIP
220267 needs : [build_wheels_windows_hip]
221- if : startsWith(github.ref, 'refs/tags/')
268+ if : startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
222269 runs-on : ubuntu-latest
223270
224271 steps :
@@ -231,6 +278,6 @@ jobs:
231278 with :
232279 files : dist/*
233280 # Set release name to <tag>-hip-radeon.
234- tag_name : ${{ github.ref_name }}-hip-radeon
281+ tag_name : ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github. ref_name }}-hip-radeon
235282 env :
236283 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments