Skip to content

Commit 201f819

Browse files
committed
Add configurable matrix inputs to workflows
1 parent 3c54b2f commit 201f819

14 files changed

+560
-2423
lines changed

.github/workflows/build-wheel-rocm.yml

Lines changed: 10 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -4,144 +4,25 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version tag of llama-cpp-python to build: v0.2.2'
8-
default: 'v0.2.2'
7+
description: 'Version tag of llama-cpp-python to build: v0.2.9'
8+
default: 'v0.2.9'
99
required: true
1010
type: string
1111
workflow_call:
1212
inputs:
1313
version:
14-
description: 'Version tag of llama-cpp-python to build: v0.2.2'
15-
default: 'v0.2.2'
14+
description: 'Version tag of llama-cpp-python to build: v0.2.9'
15+
default: 'v0.2.9'
1616
required: true
1717
type: string
1818

1919
permissions:
2020
contents: write
2121

2222
jobs:
23-
build_wheels:
24-
name: Build ${{ matrix.os }} ROCm ${{ matrix.rocm }} Wheel ${{ matrix.pyver }}
25-
runs-on: ${{ matrix.os }}
26-
strategy:
27-
matrix:
28-
os: [ubuntu-20.04, windows-latest]
29-
pyver: ["3.8", "3.9", "3.10", "3.11"]
30-
rocm: ['5.4.2','5.5','5.5.1','5.6.1']
31-
exclude:
32-
- os: windows-latest
33-
rocm: '5.4.2'
34-
- os: windows-latest
35-
rocm: '5.5'
36-
- os: windows-latest
37-
rocm: '5.6.1'
38-
- os: ubuntu-20.04
39-
rocm: '5.5.1'
40-
defaults:
41-
run:
42-
shell: pwsh
43-
env:
44-
PCKGVER: ${{ inputs.version }}
45-
ROCM_VERSION: ${{ matrix.rocm }}
46-
47-
steps:
48-
- name: Free Disk Space
49-
if: runner.os == 'Linux'
50-
uses: jlumbroso/free-disk-space@v1.2.0
51-
with:
52-
tool-cache: false
53-
android: true
54-
dotnet: true
55-
haskell: true
56-
large-packages: false
57-
swap-storage: false
58-
59-
- uses: actions/checkout@v4
60-
with:
61-
repository: 'abetlen/llama-cpp-python'
62-
ref: ${{ inputs.version }}
63-
submodules: 'recursive'
64-
65-
- name: Install Linux ROCm SDK
66-
if: runner.os == 'Linux'
67-
shell: bash
68-
run: |
69-
[ ! -d /etc/apt/keyrings ] && sudo mkdir --parents --mode=0755 /etc/apt/keyrings
70-
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
71-
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/$ROCM_VERSION focal main" | sudo tee --append /etc/apt/sources.list.d/rocm.list
72-
echo -e 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600
73-
sudo apt update
74-
sudo apt install rocm-dev rocblas-dev hipblas-dev -y
75-
76-
- name: Install Windows ROCm SDK
77-
if: runner.os == 'Windows'
78-
run: |
79-
curl -LO https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-23.Q3-Win10-Win11-For-HIP.exe
80-
Start-Process 'AMD-Software-PRO-Edition-23.Q3-Win10-Win11-For-HIP.exe' -ArgumentList '-install' -NoNewWindow -Wait
81-
echo "C:\Program Files\AMD\ROCm\5.5\bin" >> $env:GITHUB_PATH
82-
echo 'ROCM_PATH=C:\Program Files\AMD\ROCm\5.5' >> $env:GITHUB_ENV
83-
echo 'HIP_PATH=C:\Program Files\AMD\ROCm\5.5' >> $env:GITHUB_ENV
84-
85-
- uses: actions/setup-python@v4
86-
with:
87-
python-version: ${{ matrix.pyver }}
88-
89-
- name: Install Dependencies
90-
run: |
91-
python -m pip install build wheel cmake scikit-build ninja
92-
93-
- name: Build Wheel
94-
run: |
95-
if ($IsLinux) {
96-
$env:CC = '/opt/rocm/llvm/bin/clang'
97-
$env:CXX = '/opt/rocm/llvm/bin/clang++'
98-
$env:CFLAGS = '-fPIC'
99-
$env:CXXFLAGS = '-fPIC'
100-
$env:CMAKE_PREFIX_PATH = '/opt/rocm'
101-
$env:GITHUB_PATH = "/opt/rocm/bin:$env:GITHUB_PATH"
102-
$env:ROCM_PATH = "/opt/rocm"
103-
$env:HIP_PATH = "/opt/rocm"
104-
} else {
105-
$env:CC = 'C:\Program Files\AMD\ROCm\5.5\bin\clang.exe'
106-
$env:CXX = 'C:\Program Files\AMD\ROCm\5.5\bin\clang++.exe'
107-
$env:CMAKE_PREFIX_PATH = 'C:\Program Files\AMD\ROCm\5.5'
108-
$cmakelists = Get-Content 'CMakeLists.txt' -raw
109-
$regexstr = '(?s)(?<=\n)\s+?install\(\s+FILES \$\<TARGET_RUNTIME_DLLS.+/llama_cpp(?:_cuda)?\s+\)\s+?(?=endif\(\))'
110-
$regexmatch = [Regex]::Matches($cmakelists,$regexstr)
111-
if ($regexmatch[0].Success) {New-Item 'CMakeLists.txt' -itemType File -value $regexmatch[0].Result('$`$''') -force}
112-
}
113-
$env:VERBOSE = '1'
114-
$packageVersion = [version]$env:PCKGVER.TrimStart('v')
115-
$gputargets = 'gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102'
116-
if ([version]$env:ROCM_VERSION -lt [version]'5.5') {$gputargets = 'gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx1010;gfx1012;gfx1030'}
117-
$env:CMAKE_ARGS = "-GNinja -DLLAMA_HIPBLAS=ON -DGPU_TARGETS=$gputargets"
118-
$buildtag = "+rocm$env:ROCM_VERSION"
119-
if ($packageVersion -lt [version]'0.2.0') {
120-
python -m build --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$buildtag"
121-
} else {
122-
$initpath = Join-Path '.' 'llama_cpp' '__init__.py' -resolve
123-
$initcontent = Get-Content $initpath -raw
124-
$regexstr = '(?s)(?<=__version__ \= ")\d+(?:\.\d+)*(?=")'
125-
$regexmatch = [Regex]::Matches($initcontent,$regexstr)
126-
if (!($regexmatch[0].Success)) {throw '__init__.py parsing failed'}
127-
$newinit = $regexmatch[0].Result(('$`' + '$&' + $buildtag + '$'''))
128-
New-Item $initpath -itemType File -value $newinit -force
129-
python -m build --wheel
130-
}
131-
132-
- name: Upload files to a GitHub release
133-
id: upload-release
134-
uses: svenstaro/upload-release-action@2.7.0
135-
continue-on-error: true
136-
with:
137-
file: ./dist/*.whl
138-
tag: rocm
139-
file_glob: true
140-
make_latest: false
141-
overwrite: true
142-
143-
- uses: actions/upload-artifact@v3
144-
if: steps.upload-release.outcome == 'failure'
145-
with:
146-
name: 'rocm-wheels'
147-
path: ./dist/*.whl
23+
build_wheels_rocm:
24+
name: ROCm Wheels
25+
uses: ./.github/workflows/build-wheels-rocm-full.yml
26+
with:
27+
version: ${{ inputs.version }}
28+
config: 'rename:0'

0 commit comments

Comments
 (0)