Skip to content

Commit 8bfb842

Browse files
committed
Update test workflow
1 parent eb5021f commit 8bfb842

File tree

1 file changed

+15
-90
lines changed

1 file changed

+15
-90
lines changed

.github/workflows/build-wheels-test.yml

Lines changed: 15 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4,128 +4,53 @@ 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.6'
8+
default: 'v0.2.6'
99
required: false
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.6'
15+
default: 'v0.2.6'
1616
required: false
1717
type: string
1818

1919
jobs:
20-
build_wheels:
21-
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
20+
build_wheels_main:
21+
name: ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.avx }}
2222
runs-on: ${{ matrix.os }}
2323
strategy:
2424
matrix:
25-
os: [ubuntu-20.04, windows-latest]
25+
os: [macos-13, macos-12, macos-11]
26+
arch: ["x86_64","arm64"]
2627
pyver: ["3.10"]
27-
cuda: ["11.7.1"]
28-
releasetag: ["wheels"]
29-
defaults:
30-
run:
31-
shell: pwsh
3228
env:
33-
CUDAVER: ${{ matrix.cuda }}
34-
AVXVER: ${{ matrix.releasetag }}
29+
CMAKE_OSX_ARCHITECTURES: ${{ matrix.arch }}
3530
PCKGVER: ${{ inputs.version }}
3631

3732
steps:
38-
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v3
3934
with:
4035
repository: 'abetlen/llama-cpp-python'
4136
ref: ${{ inputs.version }}
4237
submodules: 'recursive'
4338

44-
- uses: actions/setup-python@v4
39+
- uses: actions/setup-python@v3
4540
with:
4641
python-version: ${{ matrix.pyver }}
47-
48-
- name: Setup Mamba
49-
uses: conda-incubator/setup-miniconda@v2.2.0
50-
with:
51-
activate-environment: "build"
52-
python-version: ${{ matrix.pyver }}
53-
miniforge-variant: Mambaforge
54-
miniforge-version: latest
55-
use-mamba: true
56-
add-pip-as-python-dependency: true
57-
auto-activate-base: false
58-
59-
- name: VS Integration Cache
60-
id: vs-integration-cache
61-
if: runner.os == 'Windows'
62-
uses: actions/cache@v3.3.2
63-
with:
64-
path: ./MSBuildExtensions
65-
key: cuda-${{ matrix.cuda }}-vs-integration
66-
67-
- name: Get Visual Studio Integration
68-
if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true'
69-
run: |
70-
if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER}
71-
$links = (Invoke-RestMethod 'https://github.com/Jimver/cuda-toolkit/raw/257a101bc5c656053b5dc220126744980ef7f5b8/src/links/windows-links.ts').Trim().split().where({$_ -ne ''})
72-
for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}}
73-
Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip'
74-
& 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null
75-
Remove-Item 'cudainstaller.zip'
76-
77-
- name: Install Visual Studio Integration
78-
if: runner.os == 'Windows'
79-
run: |
80-
$y = (gi '.\MSBuildExtensions').fullname + '\*'
81-
(gi 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_})
82-
$cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_')
83-
echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV
8442

8543
- name: Install Dependencies
8644
run: |
87-
$cudaVersion = $env:CUDAVER
88-
$cudaChannels = ''
89-
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
90-
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
91-
mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()
92-
if (!(mamba list cuda)[-1].contains('cuda')) {sleep -s 10; mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()}
93-
if (!(mamba list cuda)[-1].contains('cuda')) {throw 'CUDA Toolkit failed to install!'}
94-
python -m pip install build wheel
45+
python -m pip install build wheel cmake
9546
9647
- name: Build Wheel
9748
run: |
98-
$packageVersion = [version]$env:PCKGVER.TrimStart('v')
99-
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
100-
$env:CUDA_PATH = $env:CONDA_PREFIX
101-
$env:CUDA_HOME = $env:CONDA_PREFIX
102-
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH}
103-
$env:VERBOSE = '1'
104-
$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=all'
105-
if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.71') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=35-real;37-real;52;61-real;70-real;72-real;75-real;80-real;86-real;89-real;90'}
106-
if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.71' -and [version]$env:CUDAVER -ge [version]'12.0') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=52;61-real;70-real;72-real;75-real;80-real;86-real;89-real;90'}
107-
if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.71' -and [version]$env:CUDAVER -lt [version]'11.8') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=35-real;37-real;52;61-real;70-real;72-real;75-real;80-real;86'}
108-
if ($packageVersion -lt [version]'0.1.66') {$env:CUDAFLAGS = '-arch=all'}
109-
if ($env:AVXVER -eq 'AVX') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off'}
110-
if ($env:AVXVER -eq 'AVX512') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX512=on'}
111-
if ($env:AVXVER -eq 'basic') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off'}
112-
$buildtag = "+cu$cudaVersion"
113-
if ($packageVersion -lt [version]'0.2.0') {
114-
$env:FORCE_CMAKE = '1'
115-
python -m build --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$buildtag"
116-
} else {
117-
$initpath = Join-Path '.' 'llama_cpp' '__init__.py' -resolve
118-
$initcontent = Get-Content $initpath -raw
119-
$regexstr = '(?s)(?<=__version__ \= ")\d+(?:\.\d+)*(?=")'
120-
$regexmatch = [Regex]::Matches($initcontent,$regexstr)
121-
if (!($regexmatch[0].Success)) {throw '__init__.py parsing failed'}
122-
$newinit = $regexmatch[0].Result(('$`' + '$&' + $buildtag + '$'''))
123-
New-Item $initpath -itemType File -value $newinit -force
124-
python -m build --wheel
125-
}
49+
export CMAKE_ARGS="-DLLAMA_METAL=on"
50+
CMAKE_ARGS="-DLLAMA_METAL=on" VERBOSE=1 python -m build --wheel
12651
12752
- uses: actions/upload-artifact@v3
12853
if: steps.upload-release.outcome == 'failure'
12954
with:
130-
name: ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
55+
name: ${{ format('wheel-{0}-{1}', matrix.os, matrix.arch) }}
13156
path: ./dist/*.whl

0 commit comments

Comments
 (0)