Skip to content

Commit 5757856

Browse files
authored
Merge branch 'main' into mtmd
2 parents d8ee3ee + cb299e6 commit 5757856

19 files changed

Lines changed: 3589 additions & 394 deletions
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
name: Build Wheels (CU130) for Windows
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
build_wheels:
11+
name: Build Wheel ${{ matrix.os }} py${{ matrix.pyver }} cu130
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: ["windows-2022"]
18+
pyver: ["3.10", "3.11", "3.12", "3.13", "3.14"]
19+
cuda: ["13.0.2"]
20+
cudaarch: ["75-real;80-real;86-real;87-real;89-real;90-real;100-real;120-real"]
21+
22+
defaults:
23+
run:
24+
shell: pwsh
25+
26+
env:
27+
CUDAVER: ${{ matrix.cuda }}
28+
CUDAARCHVER: ${{ matrix.cudaarch }}
29+
MAX_JOBS: 12
30+
31+
steps:
32+
- name: Add MSBuild to PATH
33+
uses: microsoft/setup-msbuild@v3
34+
with:
35+
msbuild-architecture: x64
36+
37+
- name: Checkout
38+
uses: actions/checkout@v6
39+
with:
40+
submodules: recursive
41+
42+
- name: Inspect Visual Studio OpenMP runtime paths
43+
run: |
44+
Write-Output "ProgramFiles=$env:ProgramFiles"
45+
Write-Output "ProgramFiles(x86)=${env:ProgramFiles(x86)}"
46+
Write-Output ""
47+
48+
$vsRoots = @(
49+
"$env:ProgramFiles\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC",
50+
"$env:ProgramFiles\Microsoft Visual Studio\2022\BuildTools\VC\Redist\MSVC",
51+
"${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC",
52+
"${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Redist\MSVC"
53+
)
54+
55+
foreach ($root in $vsRoots) {
56+
Write-Output "Checking root: $root"
57+
58+
if (Test-Path $root) {
59+
Write-Output " Exists: yes"
60+
Write-Output " MSVC version directories:"
61+
62+
Get-ChildItem $root -Directory -ErrorAction SilentlyContinue |
63+
Sort-Object Name |
64+
ForEach-Object {
65+
Write-Output " $($_.FullName)"
66+
}
67+
68+
Write-Output " OpenMP runtime candidates:"
69+
70+
Get-ChildItem $root -Recurse -Filter "libomp140.x86_64.dll" -ErrorAction SilentlyContinue |
71+
Sort-Object FullName |
72+
ForEach-Object {
73+
$sizeKB = [Math]::Round($_.Length / 1KB, 2)
74+
$sizeMB = [Math]::Round($_.Length / 1MB, 4)
75+
76+
Write-Output " Path: $($_.FullName)"
77+
Write-Output " Size: $($_.Length) bytes / $sizeKB KB / $sizeMB MB"
78+
}
79+
} else {
80+
Write-Output " Exists: no"
81+
}
82+
83+
Write-Output ""
84+
}
85+
86+
Write-Output "Checking System32 fallback:"
87+
$system32OpenMP = "C:\Windows\System32\libomp140.x86_64.dll"
88+
89+
if (Test-Path $system32OpenMP) {
90+
$dll = Get-Item $system32OpenMP
91+
$sizeKB = [Math]::Round($dll.Length / 1KB, 2)
92+
$sizeMB = [Math]::Round($dll.Length / 1MB, 4)
93+
94+
Write-Output " Path: $($dll.FullName)"
95+
Write-Output " Size: $($dll.Length) bytes / $sizeKB KB / $sizeMB MB"
96+
} else {
97+
Write-Output " Not found: $system32OpenMP"
98+
}
99+
100+
- name: Install CUDA ${{ matrix.cuda }}
101+
uses: Jimver/cuda-toolkit@v0.2.35
102+
id: cuda-toolkit
103+
with:
104+
cuda: ${{ matrix.cuda }}
105+
use-github-cache: false
106+
107+
- name: Install uv and Python ${{ matrix.pyver }}
108+
uses: astral-sh/setup-uv@v7
109+
with:
110+
python-version: ${{ matrix.pyver }}
111+
activate-environment: true
112+
enable-cache: true
113+
114+
- name: Install dependencies
115+
run: |
116+
git config --system core.longpaths true
117+
uv pip install --upgrade build setuptools wheel packaging
118+
119+
- name: Setup MSVC environment for nvcc
120+
shell: cmd
121+
run: |
122+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
123+
echo PATH=%PATH%>>%GITHUB_ENV%
124+
echo INCLUDE=%INCLUDE%>>%GITHUB_ENV%
125+
echo LIB=%LIB%>>%GITHUB_ENV%
126+
echo LIBPATH=%LIBPATH%>>%GITHUB_ENV%
127+
128+
- name: Build wheel
129+
run: |
130+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.', '')
131+
132+
$env:CUDA_HOME = $env:CUDA_PATH
133+
$env:CUDA_TOOLKIT_ROOT_DIR = $env:CUDA_PATH
134+
$env:VERBOSE = '1'
135+
136+
# Force CMake to use Ninja + LLVM/Clang instead of the default
137+
# Visual Studio generator. MSVC skips several GGML CPU all-variant
138+
# backends, such as ivybridge, piledriver, cooperlake, zen4, and
139+
# sapphirerapids.
140+
$env:CMAKE_GENERATOR = 'Ninja Multi-Config'
141+
142+
$toolchainCandidates = @(
143+
(Join-Path $env:GITHUB_WORKSPACE "vendor\llama.cpp\cmake\x64-windows-llvm.cmake"),
144+
(Join-Path $env:GITHUB_WORKSPACE "cmake\x64-windows-llvm.cmake")
145+
)
146+
147+
$toolchainFile = $toolchainCandidates |
148+
Where-Object { Test-Path $_ } |
149+
Select-Object -First 1
150+
151+
if (!$toolchainFile) {
152+
Write-Error "Toolchain file not found. Checked: $($toolchainCandidates -join ', ')"
153+
exit 1
154+
}
155+
156+
$toolchainFile = $toolchainFile.Replace('\', '/')
157+
Write-Output "Using toolchain file: $toolchainFile"
158+
159+
# Build one CUDA wheel with dynamic GGML backends:
160+
# - GGML_BACKEND_DL enables runtime-loadable backend DLLs.
161+
# - GGML_CPU_ALL_VARIANTS builds CPU variant DLLs such as ggml-cpu-x64,
162+
# ggml-cpu-haswell, ggml-cpu-alderlake, etc.
163+
# - GGML_NATIVE=OFF avoids binding the wheel to the runner CPU.
164+
165+
# Suppress CUDA compiler warnings
166+
$cudaDiagSuppress = '--diag-suppress=177,221,550'
167+
168+
$cmakeArgs = @(
169+
# Windows toolchain / common runtime
170+
'-DCMAKE_TOOLCHAIN_FILE=vendor/llama.cpp/cmake/x64-windows-llvm.cmake'
171+
'-DLLAMA_BUILD_BORINGSSL=ON'
172+
173+
# Disable non-wheel targets
174+
'-DLLAMA_BUILD_EXAMPLES=OFF'
175+
'-DLLAMA_BUILD_TESTS=OFF'
176+
'-DLLAMA_BUILD_TOOLS=OFF'
177+
'-DLLAMA_BUILD_SERVER=OFF'
178+
'-DLLAMA_BUILD_UI=OFF'
179+
'-DLLAMA_USE_PREBUILT_UI=OFF'
180+
'-DLLAMA_CURL=OFF'
181+
182+
# GGML dynamic backend layout
183+
'-DGGML_CPU=ON'
184+
'-DGGML_CUDA=ON'
185+
'-DGGML_NATIVE=OFF'
186+
'-DGGML_BACKEND_DL=ON'
187+
'-DGGML_CPU_ALL_VARIANTS=ON'
188+
'-DGGML_OPENMP=ON'
189+
190+
# CUDA backend
191+
"-DCMAKE_CUDA_ARCHITECTURES=$env:CUDAARCHVER"
192+
'-DGGML_CUDA_FORCE_MMQ=ON'
193+
'-DCUDA_SEPARABLE_COMPILATION=ON'
194+
"-DCMAKE_CUDA_FLAGS=$cudaDiagSuppress"
195+
196+
# Build behavior
197+
"-DCMAKE_BUILD_PARALLEL_LEVEL=$env:MAX_JOBS"
198+
'-DENABLE_CCACHE=ON'
199+
)
200+
201+
$env:CMAKE_ARGS = $cmakeArgs -join ' '
202+
Write-Output "CMAKE_ARGS=$env:CMAKE_ARGS"
203+
204+
python -m build --wheel
205+
206+
# Check if wheel was built
207+
if (!(Test-Path '.\dist\*.whl')) {
208+
Write-Error "No wheel built in dist/ directory"
209+
exit 1
210+
}
211+
212+
$wheelFile = Get-Item '.\dist\*.whl' | Select-Object -First 1
213+
214+
# Wheel filename format:
215+
# name-version-python_tag-abi_tag-platform_tag.whl
216+
$parts = $wheelFile.Name.Split('-')
217+
$distName = $parts[0]
218+
$version = $parts[1]
219+
$pyTag = $parts[2]
220+
$abiTag = $parts[3]
221+
$platTag = $parts[4]
222+
223+
# CPU all-variants is now an internal runtime layout detail.
224+
$newVersion = "$version+cu$cudaVersion"
225+
$newName = "$distName-$newVersion-$pyTag-$abiTag-$platTag"
226+
227+
# Rename wheel file
228+
Rename-Item -Path $wheelFile.FullName -NewName $newName
229+
Write-Output "Renamed wheel to: $newName"
230+
231+
# Write the build tag to the output
232+
Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV
233+
Write-Output "TAG_VERSION=$version" >> $env:GITHUB_ENV
234+
235+
- name: Get current date
236+
id: get-date
237+
run: |
238+
$currentDate = Get-Date -UFormat "%Y%m%d"
239+
Write-Output "BUILD_DATE=$currentDate" >> $env:GITHUB_ENV
240+
241+
- name: Create release
242+
if: always() && env.TAG_VERSION != ''
243+
uses: softprops/action-gh-release@v3
244+
with:
245+
files: dist/*
246+
# Set tag_name to v<tag>-cu<cuda_version>-win-<date>
247+
tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-win-${{ env.BUILD_DATE }}
248+
env:
249+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-wheels-metal.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ permissions:
88

99
jobs:
1010
build_wheels:
11-
name: Build wheels (Metal macos)
12-
runs-on: macos-latest
11+
name: Build wheels (Metal macos-26)
12+
runs-on: macos-26
1313

1414
outputs:
1515
version: ${{steps.get_version.outputs.version}}
@@ -53,8 +53,7 @@ jobs:
5353
-DCMAKE_CROSSCOMPILING=on
5454
-DGGML_METAL=on
5555
-DGGML_METAL_USE_BF16=on
56-
-DGGML_METAL_EMBED_LIBRARY=off
57-
-DGGML_METAL_SHADER_DEBUG=on"
56+
-DGGML_METAL_EMBED_LIBRARY=on"
5857
with:
5958
package-dir: .
6059
output-dir: wheelhouse2

.github/workflows/test.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ jobs:
2828
python-version: ["3.9", "3.14"]
2929
include:
3030
# macOS Non-Metal
31-
- os: macos-14
31+
- os: macos-15-intel
3232
python-version: "3.9"
33-
cmake_args: "-DLLAMA_METAL=off"
33+
cmake_args: "-DLLAMA_METAL=off -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3"
3434
metal_status: "(No Metal)"
35-
- os: macos-14
35+
- os: macos-15-intel
3636
python-version: "3.14"
37-
cmake_args: "-DLLAMA_METAL=off"
37+
cmake_args: "-DLLAMA_METAL=off -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3"
3838
metal_status: "(No Metal)"
3939

4040
# macOS Metal
41-
- os: macos-14
41+
- os: macos-26
4242
python-version: "3.9"
4343
cmake_args: "-DLLAMA_METAL=on -DGGML_METAL_USE_BF16=on -DGGML_METAL_EMBED_LIBRARY=on"
4444
metal_status: "(Metal)"
45-
- os: macos-14
45+
- os: macos-26
4646
python-version: "3.14"
4747
cmake_args: "-DLLAMA_METAL=on -DGGML_METAL_USE_BF16=on -DGGML_METAL_EMBED_LIBRARY=on"
4848
metal_status: "(Metal)"

0 commit comments

Comments
 (0)