Files

1841 lines
76 KiB
YAML

name: CI
on:
schedule:
- cron: '0 12 * * *' # nightly at 4 AM PST
workflow_dispatch: # allows manual triggering
inputs:
create_release:
description: "Create new release"
required: true
type: boolean
pull_request: # validate the release build on PRs; the release job is skipped so nothing is published
paths:
# The build jobs clone stable-diffusion.cpp source from upstream
# (leejet/stable-diffusion.cpp), so only this workflow and the ROCm
# qualification suite can affect the outcome of a PR run.
- '.github/workflows/build.yml'
- '.github/qualify-rocm/**'
env:
BRANCH_NAME: master
# The ROCm archives every run should produce. Keep in step with the ROCm build and qualify matrices.
ROCM_VERSIONS: "10.0,10.1,10.2"
ROCM_OPERATING_SYSTEMS: "ubuntu,win"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
# Pins one upstream commit for the whole run, so a push upstream mid-run cannot put two revisions under one tag.
resolve-upstream:
runs-on: ubuntu-24.04
outputs:
sha: ${{ steps.resolve.outputs.sha }}
tag: ${{ steps.resolve.outputs.tag }}
short: ${{ steps.resolve.outputs.short }}
skip: ${{ steps.published.outputs.complete == 'true' }}
steps:
- name: Clone
uses: actions/checkout@v6
with:
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
path: upstream
- name: Checkout qualification suite
uses: actions/checkout@v6
with:
path: lemonade-ci
- name: Resolve commit and tag
id: resolve
run: |
sha=$(git -C upstream rev-parse HEAD)
short=${GITHUB_SHA::7}
tag="${BRANCH_NAME}-$(git -C upstream rev-list --count HEAD)-${short}"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
echo "short=$short" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "Pinning this run to upstream $sha ($tag)"
# The tag only changes when upstream or this fork changes, so a nightly on unchanged
# sources would rebuild a release that already exists. Skip it when that release
# already holds every family; rebuild to fill the gaps when it does not.
- name: Check whether this tag is already fully published
id: published
if: github.event_name == 'schedule'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.resolve.outputs.tag }}
SHORT: ${{ steps.resolve.outputs.short }}
run: |
if gh release view "$TAG" -R "${{ github.repository }}" --json assets \
--jq '.assets[] | select(.state == "uploaded") | .name' > assets.txt; then
python3 lemonade-ci/.github/qualify-rocm/release_assets.py check-release \
--branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$ROCM_VERSIONS" --names-file assets.txt
else
echo "No complete release $TAG yet; building it."
echo "complete=false" >> "$GITHUB_OUTPUT"
fi
ubuntu-latest-cmake:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
# Pinned: Lemonade expects Ubuntu-24.04 asset names, and binaries built on
# newer Ubuntu need a newer glibc than 24.04 and Debian 13 provide.
runs-on: ubuntu-24.04
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.1
- name: Dependencies
id: depends
run: |
sudo apt-get update
sudo apt-get install build-essential
- name: Build
id: cmake_build
run: |
mkdir build
cd build
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH='$ORIGIN'
cmake --build . --config Release
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Fetch system info
id: system-info
run: |
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/*
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
path: |
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
ubuntu-latest-cmake-vulkan:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
# Pinned for the same reason as ubuntu-latest-cmake.
runs-on: ubuntu-24.04
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.1
- name: Dependencies
id: depends
run: |
sudo apt-get update
sudo apt-get install build-essential libvulkan-dev glslc spirv-headers
- name: Build
id: cmake_build
run: |
mkdir build
cd build
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DSD_VULKAN=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH='$ORIGIN'
cmake --build . --config Release
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Fetch system info
id: system-info
run: |
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip ./build/bin/*
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
path: |
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
ubuntu-latest-cuda:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# On PRs only build one representative arch (packaging logic is identical
# across all sm_*); build the full matrix on schedule/dispatch.
sm: ${{ github.event_name == 'pull_request' && fromJSON('["sm_89"]') || fromJSON('["sm_75", "sm_80", "sm_86", "sm_89", "sm_90", "sm_100", "sm_120", "sm_121"]') }}
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: ccache
uses: ggml-org/[email protected]
with:
key: ubuntu-cuda-${{ matrix.sm }}
evict-old-files: 1d
- name: Free disk space
run: |
sudo apt-get remove -y '^aspnetcore-.*' '^dotnet-.*' '^llvm-.*' 'php.*' 'ruby.*' \
google-cloud-cli azure-cli google-chrome-stable firefox powershell 2>/dev/null || true
sudo apt-get autoremove -y
df -h
- name: Install CUDA Toolkit
run: |
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
# The cuda-toolkit-12-9 metapackage is ~3.9 GB of archives and drags
# in Nsight, cuFFT, cuSPARSE, cuSOLVER and NPP, none of which
# ggml-cuda links or this workflow ships. Install just what the Build
# and Bundle steps consume (~1.2 GB): nvcc, cudart-dev (also supplies
# the libcuda stub behind CUDA::cuda_driver), cccl for thrust/cub,
# cublas, and the curand/nvjitlink libs the bundle step copies.
sudo apt-get install -y \
cuda-nvcc-12-9 \
cuda-cudart-dev-12-9 \
cuda-cccl-12-9 \
libcublas-dev-12-9 \
libcurand-dev-12-9 \
libnvjitlink-dev-12-9 \
cmake ninja-build patchelf
# Fail here, naming the missing file, rather than partway through the
# compile if NVIDIA repackages any of the above.
for f in /usr/local/cuda/bin/nvcc \
/usr/local/cuda/include/cublas_v2.h \
/usr/local/cuda/include/cub/cub.cuh \
/usr/local/cuda/lib64/libcudart.so \
/usr/local/cuda/lib64/libcublas.so \
/usr/local/cuda/lib64/libcublasLt.so \
/usr/local/cuda/lib64/libcurand.so \
/usr/local/cuda/lib64/libnvJitLink.so; do
[ -e "$f" ] || { echo "::error::CUDA install is missing $f"; exit 1; }
done
- name: Set CUDA environment
run: |
echo "CUDA_PATH=/usr/local/cuda" >> "$GITHUB_ENV"
echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
- name: Build
id: cmake_build
run: |
cmake_arch="${{ matrix.sm }}"
cmake_arch="${cmake_arch#sm_}"
cmake -B build -S . \
-DSD_CUBLAS=ON \
-DGGML_CUDA=ON \
-DCMAKE_CUDA_ARCHITECTURES="${cmake_arch}" \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
-DGGML_NATIVE=OFF \
-DSD_BUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j $(nproc)
- name: Bundle CUDA runtime libraries
run: |
cuda_lib=/usr/local/cuda/lib64
cp -av ${cuda_lib}/libcudart.so* build/bin/
cp -av ${cuda_lib}/libcublas.so* build/bin/
cp -av ${cuda_lib}/libcublasLt.so* build/bin/
cp -av ${cuda_lib}/libcurand.so* build/bin/
cp -av ${cuda_lib}/libnvJitLink.so* build/bin/
# Copy all ggml shared libs (libggml.so, libggml-base.so, libggml-cuda.so, etc.)
# from wherever cmake placed them outside build/bin/ into the distribution dir.
find build -name 'libggml*.so*' ! -path 'build/bin/*' -exec cp -av {} build/bin/ \;
- name: Set RPATH for portable distribution
run: |
for f in build/bin/*; do
[ -f "$f" ] && ! [ -L "$f" ] || continue
if file "$f" | grep -q 'ELF'; then
patchelf --set-rpath '$ORIGIN' "$f"
fi
done
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
tar -I 'xz -T0' -cf sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-ubuntu-cuda-${{ matrix.sm }}-x64.tar.xz -C ./build/bin .
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-ubuntu-cuda-${{ matrix.sm }}-x64.tar.xz
path: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-ubuntu-cuda-${{ matrix.sm }}-x64.tar.xz
windows-latest-cuda:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
# On PRs only build one representative arch (packaging logic is identical
# across all sm_*); build the full matrix on schedule/dispatch.
sm: ${{ github.event_name == 'pull_request' && fromJSON('["sm_89"]') || fromJSON('["sm_75", "sm_80", "sm_86", "sm_89", "sm_90", "sm_100", "sm_120", "sm_121"]') }}
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: Install CUDA Toolkit
id: cuda-toolkit
uses: Jimver/[email protected]
with:
cuda: '12.9.1'
method: 'network'
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "curand", "nvjitlink", "thrust", "visual_studio_integration"]'
- name: ccache
uses: ggml-org/[email protected]
with:
key: windows-cuda-${{ matrix.sm }}
variant: ccache
evict-old-files: 1d
- name: Install Ninja
run: choco install ninja
- name: Build
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
set sm=${{ matrix.sm }}
set cmake_arch=%sm:sm_=%
cmake -S . -B build -G "Ninja Multi-Config" ^
-DSD_CUBLAS=ON ^
-DGGML_CUDA=ON ^
-DCMAKE_CUDA_ARCHITECTURES=%cmake_arch% ^
-DGGML_NATIVE=OFF ^
-DSD_BUILD_SHARED_LIBS=ON ^
-DCMAKE_CXX_FLAGS=/bigobj
cmake --build build --config Release
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
Copy-Item ggml/LICENSE .\build\bin\Release\ggml.txt
Copy-Item LICENSE .\build\bin\Release\stable-diffusion.cpp.txt
$cudaBin = Join-Path $env:CUDA_PATH 'bin'
$runtimeDllPatterns = @(
'cudart64_*.dll',
'cublas64_*.dll',
'cublasLt64_*.dll',
'curand64_*.dll',
'nvJitLink_*.dll'
)
foreach ($pattern in $runtimeDllPatterns) {
$dll = Get-ChildItem -Path $cudaBin -Filter $pattern -ErrorAction Stop | Sort-Object Name -Descending | Select-Object -First 1
if (-not $dll) { throw "Required CUDA runtime DLL matching '$pattern' was not found in $cudaBin" }
Copy-Item $dll.FullName .\build\bin\Release
}
# Copy all ggml DLLs (ggml.dll, ggml-base.dll, ggml-cuda.dll, etc.)
# from wherever cmake placed them outside build\bin\Release\ into the distribution dir.
Get-ChildItem -Path build -Filter 'ggml*.dll' -Recurse |
Where-Object { $_.FullName -notlike '*\bin\Release\*' } |
ForEach-Object { Copy-Item $_.FullName .\build\bin\Release\ -Force }
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-windows-cuda-${{ matrix.sm }}-x64.zip .\build\bin\Release\*
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-windows-cuda-${{ matrix.sm }}-x64.zip
path: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-windows-cuda-${{ matrix.sm }}-x64.zip
ubuntu-arm64-cuda:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
# GB10 (sm_121) ARM64 Linux build
runs-on: ubuntu-24.04-arm
strategy:
fail-fast: false
matrix:
# sm_121 targets the GB10 (Blackwell) ARM64 device
sm: ["sm_121"]
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: ccache
uses: ggml-org/[email protected]
with:
key: ubuntu-arm64-cuda-${{ matrix.sm }}
evict-old-files: 1d
- name: Install CUDA Toolkit
run: |
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/sbsa/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
# See the x64 job above for why this is a hand-picked subset rather
# than the cuda-toolkit-12-9 metapackage.
sudo apt-get install -y \
cuda-nvcc-12-9 \
cuda-cudart-dev-12-9 \
cuda-cccl-12-9 \
libcublas-dev-12-9 \
libcurand-dev-12-9 \
libnvjitlink-dev-12-9 \
cmake ninja-build patchelf
for f in /usr/local/cuda/bin/nvcc \
/usr/local/cuda/include/cublas_v2.h \
/usr/local/cuda/include/cub/cub.cuh \
/usr/local/cuda/lib64/libcudart.so \
/usr/local/cuda/lib64/libcublas.so \
/usr/local/cuda/lib64/libcublasLt.so \
/usr/local/cuda/lib64/libcurand.so \
/usr/local/cuda/lib64/libnvJitLink.so; do
[ -e "$f" ] || { echo "::error::CUDA install is missing $f"; exit 1; }
done
- name: Set CUDA environment
run: |
echo "CUDA_PATH=/usr/local/cuda" >> "$GITHUB_ENV"
echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
- name: Build
id: cmake_build
run: |
cmake_arch="${{ matrix.sm }}"
cmake_arch="${cmake_arch#sm_}"
cmake -B build -S . \
-DSD_CUBLAS=ON \
-DGGML_CUDA=ON \
-DCMAKE_CUDA_ARCHITECTURES="${cmake_arch}" \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
-DGGML_NATIVE=OFF \
-DSD_BUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j $(nproc)
- name: Bundle CUDA runtime libraries
run: |
cuda_lib=/usr/local/cuda/lib64
cp -av ${cuda_lib}/libcudart.so* build/bin/
cp -av ${cuda_lib}/libcublas.so* build/bin/
cp -av ${cuda_lib}/libcublasLt.so* build/bin/
cp -av ${cuda_lib}/libcurand.so* build/bin/
cp -av ${cuda_lib}/libnvJitLink.so* build/bin/
find build -name 'libggml*.so*' ! -path 'build/bin/*' -exec cp -av {} build/bin/ \;
- name: Set RPATH for portable distribution
run: |
for f in build/bin/*; do
[ -f "$f" ] && ! [ -L "$f" ] || continue
if file "$f" | grep -q 'ELF'; then
patchelf --set-rpath '$ORIGIN' "$f"
fi
done
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
tar -I 'xz -T0' -cf sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-ubuntu-cuda-${{ matrix.sm }}-arm64.tar.xz -C ./build/bin .
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-ubuntu-cuda-${{ matrix.sm }}-arm64.tar.xz
path: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-ubuntu-cuda-${{ matrix.sm }}-arm64.tar.xz
windows-latest-cmake:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
runs-on: windows-2022
env:
VULKAN_VERSION: 1.4.328.1
strategy:
# Each build is published as its own family, so one failing must not cancel the others.
fail-fast: false
matrix:
include:
- build: "cpu"
defines: "-DGGML_NATIVE=OFF -DSD_BUILD_SHARED_LIBS=ON -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
- build: "cuda12"
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"' -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
- build: "vulkan"
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.1
- name: Install cuda-toolkit
id: cuda-toolkit
if: ${{ matrix.build == 'cuda12' }}
uses: Jimver/[email protected]
with:
cuda: "12.8.1"
method: "network"
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
- name: Install Vulkan SDK
id: get_vulkan
if: ${{ matrix.build == 'vulkan' }}
run: |
curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe"
& "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
- name: ccache
uses: ggml-org/[email protected]
with:
key: windows-cmake-${{ matrix.build }}
variant: ccache
evict-old-files: 1d
max-size: ${{ matrix.build == 'cuda12' && '2G' || '500M' }}
- name: Activate MSVC environment
id: msvc_dev_cmd
uses: ilammy/msvc-dev-cmd@v1
- name: Build
id: cmake_build
run: |
mkdir build
cd build
cmake .. -DCMAKE_CXX_FLAGS='/bigobj' -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Release ${{ matrix.defines }}
cmake --build .
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
$filePath = ".\build\bin\Release\*"
if (Test-Path $filePath) {
echo "Exists at path $filePath"
Copy-Item ggml/LICENSE .\build\bin\Release\ggml.txt
Copy-Item LICENSE .\build\bin\Release\stable-diffusion.cpp.txt
} elseif (Test-Path ".\build\bin\stable-diffusion.dll") {
$filePath = ".\build\bin\*"
echo "Exists at path $filePath"
Copy-Item ggml/LICENSE .\build\bin\ggml.txt
Copy-Item LICENSE .\build\bin\stable-diffusion.cpp.txt
} else {
ls .\build\bin
throw "Can't find stable-diffusion.dll"
}
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip $filePath
- name: Copy and pack Cuda runtime
id: pack_cuda_runtime
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'schedule' || github.event.inputs.create_release == 'true') }}
run: |
echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
$dst='.\build\bin\cudart\'
robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
7z a cudart-sd-bin-win-cu12-x64.zip $dst\*
- name: Upload Cuda runtime
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'schedule' || github.event.inputs.create_release == 'true') }}
uses: actions/upload-artifact@v4
with:
name: sd-cudart-sd-bin-win-cu12-x64.zip
path: |
cudart-sd-bin-win-cu12-x64.zip
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
path: |
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
windows-latest-rocm:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
runs-on: windows-2022
strategy:
# Each ROCm version is an independent product, so one version failing must not cancel the others.
fail-fast: false
matrix:
include:
- ROCM_VERSION: "10.0.0"
gpu_targets: "gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
- ROCM_VERSION: "10.1.0"
gpu_targets: "gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
- ROCM_VERSION: "10.2.0"
gpu_targets: "gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
steps:
- name: Clone
id: checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.1
- name: Cache ROCm Installation
id: cache-rocm
uses: actions/cache@v4
with:
path: C:\TheRock\build
key: rocm-wheels-${{ matrix.ROCM_VERSION }}-${{ runner.os }}
- name: ccache
uses: ggml-org/[email protected]
with:
key: windows-rocm-${{ matrix.ROCM_VERSION }}-x64
evict-old-files: 1d
- name: Install ROCm with Wheels
if: steps.cache-rocm.outputs.cache-hit != 'true'
run: |
$ErrorActionPreference = "Stop"
write-host "Setting up Python virtual environment"
# Create the venv directly at the cache location to avoid relocation issues
New-Item -Path "C:\TheRock\build" -ItemType Directory -Force | Out-Null
python -m venv C:\TheRock\build\.venv
& C:\TheRock\build\.venv\Scripts\Activate.ps1
write-host "Upgrading pip"
python -m pip install --upgrade pip
write-host "Installing ROCm wheels for multi-arch support"
# Install ROCm wheels for multi-arch support (this may take several minutes)
python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ "rocm[libraries,devel]==${{ matrix.ROCM_VERSION }}"
# Pre-expand the devel tree so it is included in the cache
write-host "Initializing ROCm devel tree"
rocm-sdk init
if ($LASTEXITCODE -ne 0) { throw "rocm-sdk init failed with exit code $LASTEXITCODE" }
write-host "Completed ROCm wheel installation to C:\TheRock\build"
- name: Setup ROCm Environment
run: |
$ErrorActionPreference = "Stop"
# Activate venv from cache or fresh install
& C:\TheRock\build\.venv\Scripts\Activate.ps1
# Expand the devel tree (idempotent; no-op if already done during install)
rocm-sdk init
if ($LASTEXITCODE -ne 0) { throw "rocm-sdk init failed with exit code $LASTEXITCODE" }
# Get ROCm installation paths using the rocm-sdk CLI tool
$rocmPath = (rocm-sdk path --root)
if (-not $rocmPath) { throw "rocm-sdk path --root returned empty - devel package may not be installed" }
$rocmPath = $rocmPath.Trim()
$cmakePath = (rocm-sdk path --cmake).Trim()
$binPath = (rocm-sdk path --bin).Trim()
write-host "ROCm root: $rocmPath"
write-host "CMake path: $cmakePath"
write-host "Bin path: $binPath"
echo "HIP_PATH=$rocmPath" >> $env:GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$cmakePath" >> $env:GITHUB_ENV
echo "HIP_DEVICE_LIB_PATH=$rocmPath\lib\llvm\amdgcn\bitcode" >> $env:GITHUB_ENV
echo "HIP_PLATFORM=amd" >> $env:GITHUB_ENV
echo "LLVM_PATH=$rocmPath\lib\llvm" >> $env:GITHUB_ENV
echo "$binPath" >> $env:GITHUB_PATH
# Keep venv in PATH for subsequent steps
echo "C:\TheRock\build\.venv\Scripts" >> $env:GITHUB_PATH
- name: Build
run: |
mkdir build
cd build
cmake .. `
-G "Unix Makefiles" `
-DCMAKE_PREFIX_PATH="${env:HIP_PATH}" `
-DSD_HIPBLAS=ON `
-DSD_BUILD_SHARED_LIBS=ON `
-DGGML_NATIVE=OFF `
-DCMAKE_C_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang.exe" `
-DCMAKE_CXX_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang++.exe" `
-DCMAKE_HIP_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang.exe" `
-DHIP_PATH="${env:HIP_PATH}" `
-DCMAKE_BUILD_TYPE=Release `
-DGPU_TARGETS="${{ matrix.gpu_targets }}"
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
# Packed on every event, pull requests included, so the qualify jobs can test the archive.
- name: Bundle HIP runtime libraries
run: |
$ErrorActionPreference = "Stop"
$binPath = (rocm-sdk path --bin).Trim()
if (-not $binPath) { throw "rocm-sdk path --bin returned empty" }
foreach ($dll in @("amdhip64_7.dll", "rocm_kpack.dll", "amd_comgr.dll")) {
$f = Get-ChildItem -Path $binPath -Filter $dll -ErrorAction SilentlyContinue
if (-not $f) { throw "no match for $dll in $binPath" }
Copy-Item $f.FullName -Destination .\build\bin\ -Force
}
- name: Pack artifacts
run: |
Copy-Item ggml/LICENSE .\build\bin\ggml.txt
Copy-Item LICENSE .\build\bin\stable-diffusion.cpp.txt
7z a sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-win-rocm-${{ matrix.ROCM_VERSION }}-x64.zip .\build\bin\*
# The qualify jobs audit the archive against this job's own gpu_targets, and the
# release job proves with the SHA-256 that it uploads the archive they tested (T0.12).
- name: Record qualification metadata
run: |
$archive = 'sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-win-rocm-${{ matrix.ROCM_VERSION }}-x64.zip'
$short = ('${{ matrix.ROCM_VERSION }}'.Split('.')[0..1] -join '.')
$meta = [ordered]@{
os = 'win'
rocm_version = $short
rocm_version_full = '${{ matrix.ROCM_VERSION }}'
gpu_targets = '${{ matrix.gpu_targets }}'
tag = '${{ needs.resolve-upstream.outputs.tag }}'
upstream_sha = '${{ needs.resolve-upstream.outputs.sha }}'
artifact = $archive
sha256 = (Get-FileHash -Algorithm SHA256 -Path $archive).Hash.ToLowerInvariant()
}
$path = "qualify-meta-win-rocm-$short.json"
$meta | ConvertTo-Json | Set-Content -Path $path -Encoding utf8
Get-Content $path
echo "ROCM_VERSION_SHORT=$short" >> $env:GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-win-rocm-${{ matrix.ROCM_VERSION }}-x64.zip
path: |
sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-win-rocm-${{ matrix.ROCM_VERSION }}-x64.zip
retention-days: ${{ github.event_name == 'pull_request' && '7' || '' }}
- name: Upload qualification metadata
uses: actions/upload-artifact@v4
with:
name: qualify-meta-win-rocm-${{ env.ROCM_VERSION_SHORT }}
path: qualify-meta-win-rocm-${{ env.ROCM_VERSION_SHORT }}.json
retention-days: ${{ github.event_name == 'pull_request' && '7' || '' }}
ubuntu-latest-rocm:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
runs-on: ubuntu-24.04
env:
UBUNTU_VERSION: "24.04"
strategy:
# Same as windows-latest-rocm: one ROCm version failing must not cancel the others.
fail-fast: false
matrix:
include:
- ROCM_VERSION: "10.0.0"
gpu_targets: "gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
build: 'x64'
- ROCM_VERSION: "10.1.0"
gpu_targets: "gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
build: 'x64'
- ROCM_VERSION: "10.2.0"
gpu_targets: "gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
build: 'x64'
steps:
- name: Clone
id: checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: ccache
uses: ggml-org/[email protected]
with:
key: ubuntu-rocm-cmake-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
evict-old-files: 1d
max-size: "2G"
- name: Tune ccache for reinstalled ROCm toolchain
run: |
# ROCm is pip-installed fresh each run, so the clang binary's mtime
# changes every time. With the default compiler_check=mtime that
# invalidates the cache; hash compiler contents instead so warm
# builds hit.
ccache --set-config=compiler_check=content
ccache --set-config=sloppiness=time_macros,include_file_mtime,include_file_ctime
- name: Dependencies
id: depends
run: |
sudo apt install -y build-essential git cmake wget patchelf
- name: Free disk space
run: |
df -h
# Remove preinstalled SDKs and caches not needed for this job before
# installing ROCm. The legacy ROCm apt packages are large enough to
# exhaust ubuntu-latest if cleanup runs after installation.
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /usr/local/lib/android || true
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
sudo rm -rf /opt/hostedtoolcache || true
sudo rm -rf /usr/share/swift || true
sudo rm -rf /usr/local/share/boost || true
docker system prune -af || true
sudo apt clean
df -h
- name: Setup TheRock with Wheels
id: therock_env
run: |
# Create Python virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install ROCm wheels for build
# libraries = HIP runtime and CMake configs needed for linking
# devel = compilers, headers, static libs
python -m pip install --upgrade pip
python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ "rocm[libraries,devel]==${{ matrix.ROCM_VERSION }}"
# Get ROCm installation paths using the rocm-sdk CLI tool
ROCM_PATH=$(rocm-sdk path --root)
CMAKE_PATH=$(rocm-sdk path --cmake)
BIN_PATH=$(rocm-sdk path --bin)
echo "ROCM_PATH=$ROCM_PATH"
echo "CMAKE_PATH=$CMAKE_PATH"
echo "BIN_PATH=$BIN_PATH"
# Set environment variables
echo "ROCM_PATH=$ROCM_PATH" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$CMAKE_PATH" >> $GITHUB_ENV
echo "HIP_PATH=$ROCM_PATH" >> $GITHUB_ENV
echo "PATH=$BIN_PATH:${PATH}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$ROCM_PATH/lib:${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
# Keep venv activated for subsequent steps
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
# setup-node installs into /opt/hostedtoolcache, which is removed above.
# Keep Node/pnpm setup after disk cleanup so the server frontend can be embedded.
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.1
- name: Build
id: cmake_build
run: |
mkdir build
cd build
cmake .. -G Ninja \
-DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
-DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600" \
-DCMAKE_BUILD_TYPE=Release \
-DSD_HIPBLAS=ON \
-DHIP_PLATFORM=amd \
-DGPU_TARGETS="${{ matrix.gpu_targets }}" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_INSTALL_RPATH='$ORIGIN' \
-DGGML_NATIVE=OFF \
-DSD_BUILD_SHARED_GGML_LIB=ON \
-DGGML_BACKEND_DL=ON \
-DGGML_CPU_ALL_VARIANTS=ON \
-DSD_BUILD_SHARED_LIBS=ON
cmake --build . --config Release
# The HIP link adds the pip-installed ROCm devel tree to RUNPATH
# (.../_rocm_sdk_devel/lib), a build-machine path that means nothing on a user's machine.
- name: Normalize RPATH for portable distribution
run: |
for f in build/bin/*; do
[ -f "$f" ] && ! [ -L "$f" ] || continue
if file "$f" | grep -q 'ELF'; then
patchelf --set-rpath '$ORIGIN' "$f"
fi
done
- name: Fetch system info
id: system-info
run: |
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
# Packed on every event, pull requests included, so the qualify jobs can test the archive.
- name: Pack artifacts
id: pack_artifacts
run: |
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
archive=sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip
zip -y -r "$archive" ./build/bin
echo "archive=$archive" >> "$GITHUB_OUTPUT"
echo "ROCM_VERSION_SHORT=$(echo '${{ matrix.ROCM_VERSION }}' | cut -d '.' -f 1,2)" >> "$GITHUB_ENV"
# Same as windows-latest-rocm, SHA-256 included.
- name: Record qualification metadata
env:
ARCHIVE: ${{ steps.pack_artifacts.outputs.archive }}
run: |
cat > "qualify-meta-ubuntu-rocm-${ROCM_VERSION_SHORT}.json" <<EOF
{
"os": "ubuntu",
"rocm_version": "${ROCM_VERSION_SHORT}",
"rocm_version_full": "${{ matrix.ROCM_VERSION }}",
"gpu_targets": "${{ matrix.gpu_targets }}",
"tag": "${{ needs.resolve-upstream.outputs.tag }}",
"upstream_sha": "${{ needs.resolve-upstream.outputs.sha }}",
"artifact": "${ARCHIVE}",
"sha256": "$(sha256sum "$ARCHIVE" | cut -d ' ' -f 1)"
}
EOF
cat "qualify-meta-ubuntu-rocm-${ROCM_VERSION_SHORT}.json"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.pack_artifacts.outputs.archive }}
path: ${{ steps.pack_artifacts.outputs.archive }}
retention-days: ${{ github.event_name == 'pull_request' && '7' || '' }}
- name: Upload qualification metadata
uses: actions/upload-artifact@v4
with:
name: qualify-meta-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}
path: qualify-meta-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}.json
retention-days: ${{ github.event_name == 'pull_request' && '7' || '' }}
macos-arm64-cmake:
needs: resolve-upstream
if: needs.resolve-upstream.outputs.skip != 'true'
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
label: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Clone
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: ccache
uses: ggml-org/[email protected]
with:
key: macos-arm64-${{ matrix.label }}
evict-old-files: 1d
- name: Build
id: cmake_build
run: |
sysctl -a
mkdir build
cd build
cmake .. \
-DGGML_METAL=ON \
-DGGML_METAL_USE_BF16=ON \
-DGGML_METAL_EMBED_LIBRARY=ON \
-DSD_BUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_RPATH='@loader_path' \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
- name: Get commit hash
id: commit
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: prompt/actions-commit-hash@v2
- name: Fetch system info
id: system-info
run: |
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
echo "OS_NAME=`sw_vers -productName`" >> "$GITHUB_OUTPUT"
echo "OS_VERSION=`sw_vers -productVersion`" >> "$GITHUB_OUTPUT"
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
- name: Pack artifacts
id: pack_artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
run: |
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/*
- name: Upload artifacts
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
path: |
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
# ---------------------------------------------------------------------------
# ROCm qualification. Each ROCm archive is checked as built.
# Tier 0 statically, Tier 1 by generating an image on a Strix Halo (gfx1151) GPU.
# The release job withholds a ROCm version unless both of its archives pass both tiers.
# See .github/qualify-rocm/README.md.
# ---------------------------------------------------------------------------
qualify-tier0:
# !cancelled(): a failed build leaves nothing to audit, and the release job reports that gap.
if: ${{ !cancelled() && needs.resolve-upstream.result == 'success' && needs.resolve-upstream.outputs.skip != 'true' }}
needs:
- resolve-upstream
- ubuntu-latest-rocm
- windows-latest-rocm
strategy:
fail-fast: false
matrix:
# Each leg runs on the archive's own OS: T0.8-T0.11 run sd-server and install a user's ROCm.
os: [ubuntu, win]
rocm: ["10.0", "10.1", "10.2"]
include:
- os: ubuntu
runner: ubuntu-24.04
- os: win
runner: windows-2025
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout qualification suite
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Download qualification metadata
uses: actions/download-artifact@v4
with:
name: qualify-meta-${{ matrix.os }}-rocm-${{ matrix.rocm }}
path: ./meta
- name: Name the archive
id: archive
shell: python
run: |
import json, os
with open("meta/qualify-meta-${{ matrix.os }}-rocm-${{ matrix.rocm }}.json", encoding="utf-8-sig") as handle:
name = json.load(handle)["artifact"]
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as out:
out.write(f"name={name}\n")
- name: Download ROCm archive
uses: actions/download-artifact@v4
with:
name: ${{ steps.archive.outputs.name }}
path: ./artifact
# T0.8-T0.11 need the ROCm a user installs; this must not fail quietly or they would only skip.
- name: Install a user-style ROCm runtime
run: >-
python .github/qualify-rocm/install_rocm.py
--version ${{ matrix.rocm }}.0
--arch gfx1151
- name: Run Tier 0 static verification
run: >-
python .github/qualify-rocm/tier0_static.py
--meta meta/qualify-meta-${{ matrix.os }}-rocm-${{ matrix.rocm }}.json
--archive-dir ./artifact
--run-binaries
--fail-on-error
--output fragments/tier0-${{ matrix.os }}-rocm-${{ matrix.rocm }}.json
- name: Upload Tier 0 report
if: always()
uses: actions/upload-artifact@v4
with:
name: qualify-fragments-tier0-${{ matrix.os }}-${{ matrix.rocm }}
path: fragments/*.json
if-no-files-found: warn
qualify-tier1:
# Runs on every event except a pull request from a fork, which must not reach the self-hosted GPU runners.
if: >-
${{ !cancelled() && needs.resolve-upstream.result == 'success' && needs.resolve-upstream.outputs.skip != 'true' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository) }}
needs:
- resolve-upstream
- ubuntu-latest-rocm
- windows-latest-rocm
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
rocm: "10.0"
runner: [self-hosted, strix-halo, xsj-dispatch, Linux]
- os: ubuntu
rocm: "10.1"
runner: [self-hosted, strix-halo, xsj-dispatch, Linux]
- os: ubuntu
rocm: "10.2"
runner: [self-hosted, strix-halo, xsj-dispatch, Linux]
- os: win
rocm: "10.0"
runner: [self-hosted, strix-halo, xsj-dispatch, Windows]
- os: win
rocm: "10.1"
runner: [self-hosted, strix-halo, xsj-dispatch, Windows]
- os: win
rocm: "10.2"
runner: [self-hosted, strix-halo, xsj-dispatch, Windows]
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout qualification suite
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
# Self-hosted runners may carry another Python earlier on PATH.
- name: Pin the interpreter
shell: python
run: |
import os
location = os.environ["pythonLocation"]
interpreter = (os.path.join(location, "python.exe") if os.name == "nt"
else os.path.join(location, "bin", "python"))
if not os.path.exists(interpreter):
raise SystemExit(f"::error::no interpreter at {interpreter}")
with open(os.environ["GITHUB_ENV"], "a", encoding="utf-8") as handle:
handle.write(f"QUALIFY_PYTHON={interpreter}\n")
- name: Download qualification metadata
uses: actions/download-artifact@v4
with:
name: qualify-meta-${{ matrix.os }}-rocm-${{ matrix.rocm }}
path: ./meta
- name: Name the archive
id: archive
shell: python
run: |
import json, os
with open("meta/qualify-meta-${{ matrix.os }}-rocm-${{ matrix.rocm }}.json", encoding="utf-8-sig") as handle:
name = json.load(handle)["artifact"]
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as out:
out.write(f"name={name}\n")
- name: Download ROCm archive
uses: actions/download-artifact@v4
with:
name: ${{ steps.archive.outputs.name }}
path: ./artifact
- name: Install a user-style ROCm runtime
run: >-
${{ env.QUALIFY_PYTHON }} .github/qualify-rocm/install_rocm.py
--version ${{ matrix.rocm }}.0
--arch gfx1151
--output-json rocm-install.json
- name: Run Tier 1 GPU inference
run: >-
${{ env.QUALIFY_PYTHON }} .github/qualify-rocm/tier1_gpu.py
--meta meta/qualify-meta-${{ matrix.os }}-rocm-${{ matrix.rocm }}.json
--archive-dir ./artifact
--gfx-target gfx1151
--logs-dir fragments
--fail-on-error
--output fragments/tier1-${{ matrix.os }}-rocm-${{ matrix.rocm }}.json
- name: Upload Tier 1 report
if: always()
uses: actions/upload-artifact@v4
with:
name: qualify-fragments-tier1-${{ matrix.os }}-${{ matrix.rocm }}
path: |
fragments/*.json
fragments/*.log
if-no-files-found: warn
# Backstop for a cancelled run. Only sd-server processes started from this job's
# temp folder are stopped, never another one on a shared machine.
- name: Tear down (Windows)
if: always() && runner.os == 'Windows'
continue-on-error: true
shell: powershell
run: |
Get-Process sd-server -ErrorAction SilentlyContinue |
Where-Object { $_.Path -and $_.Path.StartsWith($env:RUNNER_TEMP, [StringComparison]::OrdinalIgnoreCase) } |
Stop-Process -Force
- name: Tear down (Linux)
if: always() && runner.os == 'Linux'
continue-on-error: true
run: pkill -f "${RUNNER_TEMP}/tier1-[^ ]*/sd-server" || true
release:
# !cancelled() so a failed build leg does not skip the release -- the per-family
# checks below decide what is complete and safe to publish -- while a run
# cancelled before this job starts publishes nothing. A cancel during the upload
# leaves what was already uploaded; the next nightly sees the gap and refills it.
if: >-
${{ !cancelled() && needs.resolve-upstream.result == 'success' &&
needs.resolve-upstream.outputs.skip != 'true' &&
(github.event_name == 'schedule' || github.event.inputs.create_release == 'true') }}
permissions:
contents: write
# Two runs on the same tag (a manual release overlapping the nightly) would
# otherwise upload into one release at once and could pair one run's
# qualification record with the other run's archive. The second one waits.
concurrency:
group: release-${{ needs.resolve-upstream.outputs.tag }}
cancel-in-progress: false
runs-on: ubuntu-24.04
needs:
- resolve-upstream
- ubuntu-latest-cmake
- ubuntu-latest-cmake-vulkan
- ubuntu-latest-cuda
- ubuntu-arm64-cuda
- windows-latest-cuda
- ubuntu-latest-rocm
- macos-arm64-cmake
- windows-latest-cmake
- windows-latest-rocm
- qualify-tier0
- qualify-tier1
# For publish-qualification: the ROCm archives T0.12 ran on, and the ones this run uploaded.
outputs:
final_checked: ${{ steps.final.outputs.archives }}
published_rocm: ${{ steps.upload_release.outputs.rocm }}
env:
TAG: ${{ needs.resolve-upstream.outputs.tag }}
SHORT: ${{ needs.resolve-upstream.outputs.short }}
steps:
- name: Clone
id: checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
repository: 'leejet/stable-diffusion.cpp'
ref: ${{ needs.resolve-upstream.outputs.sha }}
- name: Checkout qualification suite
uses: actions/checkout@v6
with:
path: lemonade-ci
- name: Download artifacts
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ./artifact
pattern: sd-*
merge-multiple: true
# Each backend family ships as a complete set or not at all; each ROCm version is
# its own family, so a gap in one version never withholds another.
- name: Check release artifacts
id: check_artifacts
run: >-
python3 lemonade-ci/.github/qualify-rocm/release_assets.py check-dir
--dir artifact --branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$ROCM_VERSIONS"
- name: Download qualification fragments
uses: actions/download-artifact@v4
with:
pattern: qualify-fragments-*
path: ./fragments
merge-multiple: true
- name: Download qualification metadata
uses: actions/download-artifact@v4
with:
pattern: qualify-meta-*
path: ./meta
merge-multiple: true
# T0.12: the exact files about to be uploaded are the ones Tier 0 and Tier 1 tested.
- name: Final-archive checks
id: final
run: |
shopt -s nullglob
mkdir -p fragments
# Only this attempt's final checks count, never ones downloaded from an earlier attempt.
rm -f fragments/tier0-final-*.json
checked=""
for archive in artifact/sd-"${BRANCH_NAME}-${SHORT}"-bin-*-rocm-*.zip; do
base=$(basename "$archive")
if [[ "$base" == *-win-rocm-* ]]; then os=win; else os=ubuntu; fi
ver=$(sed -E 's/.*-rocm-([0-9]+\.[0-9]+)\.[0-9]+(-x64)?\.zip$/\1/' <<<"$base")
checked="${checked:+$checked }$base"
python3 lemonade-ci/.github/qualify-rocm/check_final.py \
--archive "$archive" --meta "meta/qualify-meta-$os-rocm-$ver.json" \
--output "fragments/tier0-final-$os-rocm-$ver.json" \
|| echo "::error::check_final.py crashed on $base, so T0.12 will show as missing"
done
echo "archives=$checked" >> "$GITHUB_OUTPUT"
# So publish-qualification can still see T0.12 if this job stops before writing records.
- name: Upload final-archive reports
if: ${{ !cancelled() }}
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: qualify-fragments-final
path: fragments/tier0-final-*.json
if-no-files-found: ignore
- name: Qualify ROCm release artifacts
id: qualify
continue-on-error: true
run: |
mkdir -p qualification
python3 lemonade-ci/.github/qualify-rocm/aggregate.py \
--fragments-dir ./fragments \
--tag "$TAG" \
--records-dir ./qualification \
--output-summary ./qualification/qualification-summary.json \
--operating-systems "$ROCM_OPERATING_SYSTEMS" \
--rocm-versions "$ROCM_VERSIONS" \
--require-final \
--fail-on-no-promote
# Uploaded straight away so a later failure in this job cannot keep them out of the feed.
- name: Upload qualification records
if: always()
uses: actions/upload-artifact@v4
with:
name: qualification-records
path: qualification/*.json
if-no-files-found: warn
- name: Drop unqualified ROCm versions
id: rocm_gate
env:
PROMOTE: ${{ steps.qualify.outputs.promote_rocm }}
BLOCKED: ${{ steps.qualify.outputs.blocked_rocm_versions }}
run: |
if [ "$PROMOTE" = "true" ]; then
echo "Every ROCm version qualified."
echo "dropped=0" >> "$GITHUB_OUTPUT"
exit 0
fi
# No verdict at all means no evidence for any version, so withhold them all.
blocked="$BLOCKED"
if [ -z "$blocked" ]; then
blocked="${ROCM_VERSIONS//,/ }"
echo "::warning::Qualification produced no verdict; withholding every ROCm version."
fi
dropped=0
for version in $blocked; do
for archive in "artifact/sd-${BRANCH_NAME}-${SHORT}-bin-win-rocm-${version}.0-x64.zip" \
"artifact/sd-${BRANCH_NAME}-${SHORT}-bin-Linux-"*"-rocm-${version}.0.zip"; do
[ -f "$archive" ] || continue
echo "::warning::ROCm ${version} did not qualify; withholding $(basename "$archive")."
rm -fv "$archive"
dropped=$((dropped + 1))
done
done
echo "dropped=$dropped" >> "$GITHUB_OUTPUT"
echo "blocked=$blocked" >> "$GITHUB_OUTPUT"
- name: Stage qualification records as release assets
run: |
shopt -s nullglob
for record in qualification/qualification-sd-*.json; do
cp -v "$record" artifact/
done
- name: Determine release summary
id: release_summary
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "value=Nightly release for ${{ github.sha }}" >> "$GITHUB_OUTPUT"
else
echo "value=$(git log -1 --pretty=%s)" >> "$GITHUB_OUTPUT"
fi
# Reuses the release when the tag already exists (an earlier run left gaps to fill).
- name: Create or get release
id: release
uses: actions/github-script@v8
env:
RELEASE_SUMMARY: ${{ steps.release_summary.outputs.value }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = process.env.TAG;
const { owner, repo } = context.repo;
let release;
try {
release = (await github.rest.repos.getReleaseByTag({ owner, repo, tag })).data;
core.info(`Reusing existing release ${tag} (id ${release.id})`);
} catch (e) {
if (e.status !== 404) throw e;
try {
release = (await github.rest.repos.createRelease({ owner, repo, tag_name: tag, name: tag, body: process.env.RELEASE_SUMMARY })).data;
core.info(`Created release ${tag} (id ${release.id})`);
} catch (createError) {
if (createError.status !== 422) throw createError;
release = (await github.rest.repos.getReleaseByTag({ owner, repo, tag })).data;
core.info(`Reusing concurrently created release ${tag} (id ${release.id})`);
}
}
core.setOutput('id', release.id);
# Assets already in the release are never replaced: Lemonade may already pin them, and
# they were qualified when they were uploaded. A record is uploaded with its archive.
# checksums.txt is rebuilt from GitHub's digests, so it always matches what is published.
- name: Upload release
id: upload_release
uses: actions/github-script@v8
env:
RELEASE_ID: ${{ steps.release.outputs.id }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
const release_id = Number(process.env.RELEASE_ID);
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function withRetry(label, fn, attempts = 5) {
for (let i = 1; ; i++) {
try {
return await fn();
} catch (e) {
const transient = !e.status || e.status >= 500 || e.status === 429;
if (i >= attempts || !transient) throw e;
const delay = Math.min(30000, 1000 * 2 ** (i - 1));
core.warning(`${label} failed (attempt ${i}/${attempts}): ${e.message}. Retrying in ${delay}ms`);
await sleep(delay);
}
}
}
const listAssets = () => github.paginate(github.rest.repos.listReleaseAssets, { owner, repo, release_id });
async function upload(name, data) {
await withRetry(`upload ${name}`, () =>
github.rest.repos.uploadReleaseAsset({ owner, repo, release_id, name, data })
.catch(async (e) => {
if (e.status !== 422) throw e;
const asset = (await listAssets()).find((a) => a.name === name);
if (asset?.state === 'uploaded') return;
if (asset) await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
throw new Error(`retrying upload for ${name} after deleting conflicting asset`);
}));
core.info(`uploaded ${name}`);
}
async function remove(asset, reason) {
core.warning(`deleting ${reason} asset ${asset.name}`);
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
}
const published = new Map();
for (const a of await listAssets()) {
if (a.state === 'uploaded') published.set(a.name, a);
else await remove(a, `incomplete (${a.state})`);
}
const files = fs.readdirSync('./artifact');
const archives = files.filter((f) => f.endsWith('.zip') || f.endsWith('.tar.xz'));
// A record goes up before its archive, so an archive is never published without one.
const records = files.filter((f) => f.startsWith('qualification-') && f.endsWith('.json'));
const recordFor = (archive) => `qualification-${archive.replace(/\.(zip|tar\.xz)$/, '')}.json`;
async function uploadRecord(record) {
if (published.has(record)) await remove(published.get(record), 'superseded');
await upload(record, fs.readFileSync(`./artifact/${record}`));
}
const uploaded = [];
for (const file of archives) {
if (published.has(file)) {
core.info(`keeping ${file} (already published)`);
continue;
}
if (records.includes(recordFor(file))) await uploadRecord(recordFor(file));
await upload(file, fs.readFileSync(`./artifact/${file}`));
uploaded.push(file);
// Written after every upload, so a later failure still reports what did ship.
core.setOutput('rocm', uploaded.filter((f) => /-rocm-/.test(f)).join(' '));
}
// Records of withheld archives say why they were withheld.
for (const record of records) {
const archive = record.replace(/^qualification-/, '').replace(/\.json$/, '.zip');
if (!published.has(archive) && !uploaded.includes(archive)) await uploadRecord(record);
}
const assets = (await listAssets()).filter((a) => a.state === 'uploaded');
const sums = assets.filter((a) => a.name.endsWith('.zip') || a.name.endsWith('.tar.xz'))
.sort((a, b) => a.name.localeCompare(b.name))
.map((a) => {
if (!a.digest?.startsWith('sha256:')) throw new Error(`no SHA-256 digest for ${a.name}`);
return `${a.digest.slice('sha256:'.length)} ${a.name}`;
});
const old = assets.find((a) => a.name === 'checksums.txt');
if (old) await remove(old, 'superseded');
await upload('checksums.txt', Buffer.from(sums.join('\n') + '\n'));
const names = assets.map((a) => a.name).filter((n) => n !== 'checksums.txt');
fs.writeFileSync('release-assets.txt', [...names, 'checksums.txt'].join('\n') + '\n');
core.setOutput('rocm', uploaded.filter((f) => /-rocm-/.test(f)).join(' '));
core.info(`Done: ${uploaded.length} archive(s) uploaded, ${archives.length - uploaded.length} already published.`);
- name: Write release notes
env:
RELEASE_SUMMARY: ${{ steps.release_summary.outputs.value }}
run: >-
python3 lemonade-ci/.github/qualify-rocm/release_notes.py
--tag "$TAG" --repo "${{ github.repository }}"
--assets-file release-assets.txt --rocm-versions "$ROCM_VERSIONS"
--summary "$RELEASE_SUMMARY" --output release-notes.md
- name: Update release notes
uses: actions/github-script@v8
env:
RELEASE_ID: ${{ steps.release.outputs.id }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
await github.rest.repos.updateRelease({
owner, repo, release_id: Number(process.env.RELEASE_ID),
name: process.env.TAG, body: fs.readFileSync('release-notes.md', 'utf8'),
});
- name: Fail if any artifacts were missing
if: steps.check_artifacts.outputs.missing != '0'
run: |
echo "::error::${{ steps.check_artifacts.outputs.missing }} artifact(s) were missing (${{ steps.check_artifacts.outputs.summary }}) — the incomplete families were dropped from this release; other families were still published. See the 'Check release artifacts' step for the full per-file list."
exit 1
- name: Fail if ROCm qualification did not pass
if: steps.rocm_gate.outputs.dropped != '0'
run: |
echo "::error::ROCm ${{ steps.rocm_gate.outputs.blocked }} did not qualify — ${{ steps.rocm_gate.outputs.dropped }} archive(s) were withheld. Every other ROCm version and backend was published normally. The attached qualification-*.json records list each failing check."
exit 1
# Publishes every run's ROCm qualification records, passing or failing, to the
# qualification-data branch the ROCm readiness dashboard reads (format: .github/qualify-rocm/FEED.md).
# A nightly skipped because its release was already complete records only that it
# checked and found nothing new (index.json "last_check"). The branch is created on the first publish.
publish-qualification:
if: >-
${{ !cancelled() && needs.resolve-upstream.result == 'success' &&
(needs.resolve-upstream.outputs.skip == 'true' ||
needs.release.result == 'success' || needs.release.result == 'failure') }}
needs:
- resolve-upstream
- release
runs-on: ubuntu-24.04
permissions:
contents: write # to push to the qualification-data branch
actions: read # to read each ROCm build job's result
steps:
- name: Checkout qualification suite
uses: actions/checkout@v6
with:
path: lemonade-ci
- name: Download qualification records
if: needs.resolve-upstream.outputs.skip != 'true'
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: qualification-records
path: ./records
- name: Download qualification fragments
if: needs.resolve-upstream.outputs.skip != 'true'
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: qualify-fragments-*
path: ./fragments
merge-multiple: true
# If the release job stopped before writing records, build them from the tier reports.
- name: Collect qualification records
if: needs.resolve-upstream.outputs.skip != 'true'
env:
TAG: ${{ needs.resolve-upstream.outputs.tag }}
run: |
set -euo pipefail
shopt -s nullglob
records=(records/qualification-sd-*.json)
if [ ${#records[@]} -gt 0 ]; then
echo "Using the ${#records[@]} record(s) the release job wrote."
exit 0
fi
echo "The release job wrote no records; building them from the Tier 0 and Tier 1 reports."
mkdir -p records fragments
python3 lemonade-ci/.github/qualify-rocm/aggregate.py \
--fragments-dir ./fragments \
--tag "$TAG" \
--records-dir ./records \
--output-summary ./records/qualification-summary.json \
--operating-systems "$ROCM_OPERATING_SYSTEMS" \
--rocm-versions "$ROCM_VERSIONS" \
--require-final
- name: Read build job results
if: needs.resolve-upstream.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -uo pipefail
for attempt in 1 2 3; do
if gh api --paginate \
"repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs?filter=latest&per_page=100" \
--jq '.jobs[] | {name, conclusion}' > jobs.jsonl; then
grep -E '"name":"(ubuntu-latest-rocm|windows-latest-rocm) ' jobs.jsonl || true
exit 0
fi
echo "Could not read the run's jobs (attempt $attempt); retrying"
sleep $((attempt * 5))
done
echo "::warning::Could not read the run's jobs; build_result will be 'unknown'."
: > jobs.jsonl
- name: Publish to qualification-data branch
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.resolve-upstream.outputs.tag }}
UPSTREAM_SHA: ${{ needs.resolve-upstream.outputs.sha }}
PUBLISHED_ROCM: ${{ needs.release.outputs.published_rocm }}
FINAL_CHECKED: ${{ needs.release.outputs.final_checked }}
UNCHANGED: ${{ needs.resolve-upstream.outputs.skip }}
run: |
set -euo pipefail
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
REPO_URL="https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
BRANCH="qualification-data"
pushed=0
for attempt in 1 2 3 4 5; do
rm -rf data
found=0
git ls-remote --exit-code --heads "$REPO_URL" "$BRANCH" >/dev/null || found=$?
if [ "$found" -eq 0 ]; then
if ! git clone --quiet --depth 1 --branch "$BRANCH" "$REPO_URL" data; then
echo "Clone failed (attempt $attempt); retrying"; sleep $((attempt * 3)); continue
fi
elif [ "$found" -eq 2 ]; then
echo "$BRANCH does not exist yet; creating it"
git init --quiet data
git -C data checkout --quiet --orphan "$BRANCH"
git -C data remote add origin "$REPO_URL"
else
echo "Could not reach the repository (attempt $attempt); retrying"; sleep $((attempt * 3)); continue
fi
if [ "$UNCHANGED" = "true" ]; then
python3 lemonade-ci/.github/qualify-rocm/publish_qualification.py --mark-unchanged \
--data-dir data/qualification --tag "$TAG" --upstream-sha "$UPSTREAM_SHA"
else
python3 lemonade-ci/.github/qualify-rocm/publish_qualification.py \
--records-dir records \
--data-dir data/qualification \
--operating-systems "$ROCM_OPERATING_SYSTEMS" \
--rocm-versions "$ROCM_VERSIONS" \
--tag "$TAG" \
--upstream-sha "$UPSTREAM_SHA" \
--jobs-file jobs.jsonl \
--published-artifacts "$PUBLISHED_ROCM" \
--final-checked "$FINAL_CHECKED"
fi
cp lemonade-ci/.github/qualify-rocm/FEED.md data/qualification/SCHEMA.md
git -C data add -A
if git -C data diff --cached --quiet; then
echo "Nothing changed; the feed already holds this run."
pushed=1; break
fi
if [ "$UNCHANGED" = "true" ]; then message="unchanged"; else message="run"; fi
git -C data commit --quiet -m "qualification: ${message} ${{ github.run_id }} (${TAG})"
if git -C data push --quiet origin "$BRANCH"; then
pushed=1; break
fi
echo "Push rejected (attempt $attempt), most likely because another run published first; retrying"
sleep $((attempt * 3))
done
[ "$pushed" = 1 ] || { echo "::error::Could not publish to $BRANCH after 5 attempts."; exit 1; }
echo "Feed: https://raw.githubusercontent.com/${{ github.repository }}/${BRANCH}/qualification/index.json"