[WIP] add aws code build

This commit is contained in:
Junya Morioka
2025-08-14 12:45:00 +09:00
parent d680fc502f
commit 3d839f92da
7 changed files with 225 additions and 60 deletions
+95 -48
View File
@@ -20,7 +20,7 @@ jobs:
--notes "TBD"
# #########################################################
# Build wheels with GitHub hosted runner
# Linux
# #########################################################
# build_wheels_linux:
# name: Build Linux
@@ -71,52 +71,52 @@ jobs:
# cuda-version: ${{ matrix.cuda-version }}
# secrets: inherit
build_wheels_linux_self_hosted:
name: Build Linux (self-hosted)
needs: create_releases
strategy:
fail-fast: false
matrix:
flash-attn-version: ["2.7.4"]
python-version: ["3.10", "3.11", "3.12"]
torch-version: ["2.5.1", "2.6.0", "2.7.1", "2.8.0"]
# https://developer.nvidia.com/cuda-toolkit-archive
cuda-version: ["12.4.1", "12.8.1", "12.9.1"]
exclude:
# torch < 2.2 does not support Python 3.12
- python-version: "3.12"
torch-version: "2.0.1"
- python-version: "3.12"
torch-version: "2.1.2"
# torch 2.0.1 does not support CUDA 12.x
- torch-version: "2.0.1"
cuda-version: "12.1.1"
- torch-version: "2.0.1"
cuda-version: "12.4.1"
- torch-version: "2.0.1"
cuda-version: "12.6.3"
- torch-version: "2.0.1"
cuda-version: "12.8.1"
# torch 2.6.0 does not support CUDA 12.1
- torch-version: "2.6.0"
cuda-version: "12.1.1"
# torch 2.7.0 does not support CUDA 12.4
- torch-version: "2.7.0"
cuda-version: "12.4.1"
# torch < 2.8 does not support CUDA 12.9
- torch-version: "2.5.1"
cuda-version: "12.9.1"
- torch-version: "2.6.3"
cuda-version: "12.9.1"
- torch-version: "2.7.1"
cuda-version: "12.9.1"
uses: ./.github/workflows/build_linux_self_host.yml
with:
flash-attn-version: ${{ matrix.flash-attn-version }}
python-version: ${{ matrix.python-version }}
torch-version: ${{ matrix.torch-version }}
cuda-version: ${{ matrix.cuda-version }}
secrets: inherit
# build_wheels_linux_self_hosted:
# name: Build Linux (self-hosted)
# needs: create_releases
# strategy:
# fail-fast: false
# matrix:
# flash-attn-version: ["2.7.4"]
# python-version: ["3.10", "3.11", "3.12"]
# torch-version: ["2.5.1", "2.6.0", "2.7.1", "2.8.0"]
# # https://developer.nvidia.com/cuda-toolkit-archive
# cuda-version: ["12.4.1", "12.8.1", "12.9.1"]
# exclude:
# # torch < 2.2 does not support Python 3.12
# - python-version: "3.12"
# torch-version: "2.0.1"
# - python-version: "3.12"
# torch-version: "2.1.2"
# # torch 2.0.1 does not support CUDA 12.x
# - torch-version: "2.0.1"
# cuda-version: "12.1.1"
# - torch-version: "2.0.1"
# cuda-version: "12.4.1"
# - torch-version: "2.0.1"
# cuda-version: "12.6.3"
# - torch-version: "2.0.1"
# cuda-version: "12.8.1"
# # torch 2.6.0 does not support CUDA 12.1
# - torch-version: "2.6.0"
# cuda-version: "12.1.1"
# # torch 2.7.0 does not support CUDA 12.4
# - torch-version: "2.7.0"
# cuda-version: "12.4.1"
# # torch < 2.8 does not support CUDA 12.9
# - torch-version: "2.5.1"
# cuda-version: "12.9.1"
# - torch-version: "2.6.3"
# cuda-version: "12.9.1"
# - torch-version: "2.7.1"
# cuda-version: "12.9.1"
# uses: ./.github/workflows/build_linux_self_host.yml
# with:
# flash-attn-version: ${{ matrix.flash-attn-version }}
# python-version: ${{ matrix.python-version }}
# torch-version: ${{ matrix.torch-version }}
# cuda-version: ${{ matrix.cuda-version }}
# secrets: inherit
# build_wheels_windows:
# name: Build Windows
@@ -165,11 +165,58 @@ jobs:
# cuda-version: ${{ matrix.cuda-version }}
# secrets: inherit
build_wheels_windows_code_build:
name: Build Windows (AWS CodeBuild)
needs: create_releases
strategy:
fail-fast: false
matrix:
flash-attn-version: ["2.7.4", "2.8.2"]
python-version: ["3.10", "3.11", "3.12"]
torch-version: ["2.7.1", "2.8.0"]
# https://developer.nvidia.com/cuda-toolkit-archive
cuda-version: ["12.8.1"]
exclude:
# torch < 2.2 does not support Python 3.12
- python-version: "3.12"
torch-version: "2.0.1"
- python-version: "3.12"
torch-version: "2.1.2"
# torch 2.0.1 does not support CUDA 12.x
- torch-version: "2.0.1"
cuda-version: "12.1.1"
- torch-version: "2.0.1"
cuda-version: "12.4.1"
- torch-version: "2.0.1"
cuda-version: "12.6.3"
- torch-version: "2.0.1"
cuda-version: "12.8.1"
# torch 2.6.0 does not support CUDA 12.1
- torch-version: "2.6.0"
cuda-version: "12.1.1"
# torch 2.7.0 does not support CUDA 12.4
- torch-version: "2.7.0"
cuda-version: "12.4.1"
# torch < 2.8 does not support CUDA 12.9
- torch-version: "2.5.1"
cuda-version: "12.9.1"
- torch-version: "2.6.3"
cuda-version: "12.9.1"
- torch-version: "2.7.1"
cuda-version: "12.9.1"
uses: ./.github/workflows/build_windows.yml
with:
flash-attn-version: ${{ matrix.flash-attn-version }}
python-version: ${{ matrix.python-version }}
torch-version: ${{ matrix.torch-version }}
cuda-version: ${{ matrix.cuda-version }}
secrets: inherit
update_release_notes:
name: Update Release Notes
# needs:
# [build_wheels_linux, build_wheels_linux_self_hosted, build_wheels_windows]
needs: [build_wheels_linux_self_hosted]
needs: [build_wheels_windows_code_build]
if: always()
runs-on: ubuntu-latest
steps:
+1 -1
View File
@@ -26,7 +26,7 @@ on:
jobs:
build_wheels:
name: Build wheels and Upload (Linux x86_64)
name: Build wheels and Upload (Linux x86_64, ${{ inputs.flash-attn-version }}, ${{ inputs.python-version }}, ${{ inputs.torch-version }}, ${{ inputs.cuda-version }})
runs-on: ubuntu-22.04
env:
DEBIAN_FRONTEND: noninteractive
+3 -3
View File
@@ -26,7 +26,7 @@ on:
jobs:
build_wheels_self_hosted:
name: Build wheels and Upload (Linux x86_64, self-hosted runner)
name: Build wheels and Upload (Linux x86_64, self-hosted runner, ${{ inputs.flash-attn-version }}, ${{ inputs.python-version }}, ${{ inputs.torch-version }}, ${{ inputs.cuda-version }})
runs-on: self-hosted
container:
image: ubuntu:22.04
@@ -36,7 +36,7 @@ jobs:
env:
DEBIAN_FRONTEND: noninteractive
TERM: xterm-256color
timeout-minutes: 2000
timeout-minutes: 10000
steps:
- name: Install tools
shell: bash
@@ -101,7 +101,7 @@ jobs:
export LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
- name: Build wheels
timeout-minutes: 1200
timeout-minutes: 10000
id: build_wheels
shell: bash
env:
+15 -6
View File
@@ -26,9 +26,8 @@ on:
jobs:
build_windows_wheels:
name: Build wheels and Upload (Windows x86_64, GitHub hosted runner)
name: Build wheels and Upload (Windows x86_64, GitHub hosted runner, ${{ inputs.flash-attn-version }}, ${{ inputs.python-version }}, ${{ inputs.torch-version }}, ${{ inputs.cuda-version }})
runs-on: windows-2022
timeout-minutes: 1000
env:
MAX_JOBS: 2
NVCC_THREADS: 2
@@ -50,12 +49,22 @@ jobs:
use-github-cache: false
use-local-cache: false
- name: Install VS2022 BuildTools
- name: Install Visual Studio BuildTools (C++/CMake + Windows SDK)
shell: pwsh
run: |
choco install -y visualstudio2022buildtools `
--version=117.14.1 `
--params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
choco upgrade -y visualstudio2022buildtools `
--params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 `
--includeRecommended --includeOptional"
- name: Setup MSVC Developer Command Prompt
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install build dependencies
shell: pwsh
@@ -0,0 +1,108 @@
# #########################################################
# Build wheels with AWS CodeBuild on Windows x86_64
# #########################################################
name: "[Windows x86_64, AWS CodeBuild] Build wheels and upload to GitHub Releases"
on:
workflow_call:
inputs:
flash-attn-version:
description: "Flash-Attention version"
required: true
type: string
python-version:
description: "Python version"
required: true
type: string
torch-version:
description: "PyTorch version"
required: true
type: string
cuda-version:
description: "CUDA version"
required: true
type: string
jobs:
build_wheels:
name: Build wheels and Upload (Windows x86_64, AWS CodeBuild, ${{ inputs.flash-attn-version }}, ${{ inputs.python-version }}, ${{ inputs.torch-version }}, ${{ inputs.cuda-version }})
timeout-minutes: 129600
runs-on: codebuild-flash-attention-pre-build-wheel-windows-${{ github.run_id }}-${{ github.run_attempt }}
# Large Instance
env:
MAX_JOBS: 4
NVCC_THREADS: 3
steps:
- uses: actions/checkout@v4
- name: Enable Git long paths
shell: pwsh
run: git config --system core.longpaths true
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- uses: Jimver/cuda-toolkit@v0.2.24
with:
cuda: ${{ inputs.cuda-version }}
method: "network"
use-github-cache: false
use-local-cache: false
- name: Install Visual Studio BuildTools (C++/CMake + Windows SDK)
shell: pwsh
run: |
choco upgrade -y visualstudio2022buildtools `
--params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 `
--includeRecommended --includeOptional"
- name: Setup MSVC Developer Command Prompt
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install build dependencies
shell: pwsh
run: |
pip install -U pip setuptools==75.8.0 wheel packaging psutil numpy ninja
- name: Build wheels
shell: pwsh
run: |
.\build_windows.ps1 -FlashAttnVersion "${{ inputs.flash-attn-version }}" -PythonVersion "${{ inputs.python-version }}" -TorchVersion "${{ inputs.torch-version }}" -CudaVersion "${{ inputs.cuda-version }}"
$wheelName = Get-ChildItem -Path "flash-attention\dist\*.whl" | Select-Object -First 1 | ForEach-Object { $_.Name }
echo "wheel_name=$wheelName" >> $env:GITHUB_ENV
- name: Install Test
shell: pwsh
run: |
pip install --no-cache-dir flash-attention/dist/$env:wheel_name
python -c "import flash_attn; print(flash_attn.__version__)"
- name: Upload Release Asset
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$tag_name = "${env:GITHUB_REF}".Replace("refs/tags/", "")
$wheel_path = "flash-attention/dist/$env:wheel_name"
# Check if the file exists
if (-not (Test-Path $wheel_path)) {
$tag_name = "${env:GITHUB_REF}".Replace("refs/tags/", "")
$wheel_path = "flash-attention/dist/$env:wheel_name"
# Check if the file exists
if (-not (Test-Path $wheel_path)) {
Write-Host "Error: Wheel file not found at $wheel_path"
exit 1
}
# Upload the release asset using GitHub CLI
gh release upload "$tag_name" "$wheel_path" --clobber
+1 -1
View File
@@ -54,7 +54,7 @@ jobs:
MAX_JOBS: 4
NVCC_THREADS: 3
run: |
.\build_windows.ps1 -FlashAttnVersion "2.7.4" -PythonVersion "3.11" -TorchVersion "2.7.1" -CudaVersion "12.8.1"
.\build_windows.ps1 -FlashAttnVersion "2.5.9" -PythonVersion "3.11" -TorchVersion "2.4.1" -CudaVersion "12.4.1"
$wheelName = Get-ChildItem -Path "flash-attention\dist\*.whl" | Select-Object -First 1 | ForEach-Object { $_.Name }
echo "wheel_name=$wheelName" >> $env:GITHUB_ENV
+2 -1
View File
@@ -71,4 +71,5 @@ python setup.py bdist_wheel --dist-dir=dist
$baseWheelName = Get-ChildItem -Path "dist\*.whl" | Select-Object -First 1 | ForEach-Object { $_.Name }
$wheelName = $baseWheelName.Replace($FlashAttnVersion, "$FlashAttnVersion+cu$MatrixCudaVersion" + "torch$MatrixTorchVersion")
Move-Item "dist\$baseWheelName" "dist\$wheelName"
Write-Host "Built wheel: $wheelName"
Write-Host "Built wheel: $wheelName"
cd ..