Skip to content

Commit 5db360f

Browse files
committed
upd
1 parent 82e9f47 commit 5db360f

File tree

2 files changed

+82
-58
lines changed

2 files changed

+82
-58
lines changed

.github/workflows/release-flashinfer-aot-modules-wheel.yml

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
name: Build and Release flashinfer-aot-modules wheels
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
tag:
7-
description: 'Tag (e.g., v1.2.3) to build wheels for'
8-
required: true
9-
type: string
4+
# workflow_dispatch:
5+
# inputs:
6+
# tag:
7+
# description: 'Tag (e.g., v1.2.3) to build wheels for'
8+
# required: true
9+
# type: string
10+
11+
pull_request:
12+
branches:
13+
- main
1014

1115
env:
1216
FLASHINFER_CUDA_ARCH_LIST: "7.5 8.0 8.9 9.0 10.0 10.3 12.0"
@@ -15,52 +19,52 @@ jobs:
1519
validate-tag:
1620
runs-on: ubuntu-latest
1721
steps:
18-
- name: Validate tag format
19-
run: |
20-
if [[ ! "${{ inputs.tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([a-z0-9]+)?$ ]]; then
21-
echo "Error: Tag '${{ inputs.tag }}' does not match the expected format (e.g., v1.2.3 or v1.2.3.post1 or v1.2.3rc1)"
22-
exit 1
23-
fi
24-
echo "✓ Tag format is valid: ${{ inputs.tag }}"
25-
26-
- name: Check out tag
27-
uses: actions/checkout@v4
28-
with:
29-
ref: ${{ inputs.tag }}
30-
submodules: true
31-
32-
- name: Verify tag matches version.txt
33-
run: |
34-
# Extract version from tag (remove 'v' prefix)
35-
TAG_VERSION="${{ inputs.tag }}"
36-
TAG_VERSION="${TAG_VERSION#v}"
37-
38-
# Check version.txt - this is the source of truth
39-
if [ ! -f "version.txt" ]; then
40-
echo "Error: version.txt file not found!"
41-
exit 1
42-
fi
43-
44-
VERSION_TXT=$(cat version.txt | tr -d '[:space:]')
45-
46-
if [ "$TAG_VERSION" != "$VERSION_TXT" ]; then
47-
echo "❌ CRITICAL ERROR: version.txt does not match tag!"
48-
echo " Tag version: $TAG_VERSION"
49-
echo " version.txt: $VERSION_TXT"
50-
echo ""
51-
echo "Please update version.txt to match the release version before creating a release."
52-
echo "The tag should be 'v$VERSION_TXT' (e.g., if version.txt contains '1.2.3', tag should be 'v1.2.3')"
53-
exit 1
54-
fi
55-
56-
echo "✓ version.txt matches tag version: $VERSION_TXT"
22+
# - name: Validate tag format
23+
# run: |
24+
# if [[ ! "${{ inputs.tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([a-z0-9]+)?$ ]]; then
25+
# echo "Error: Tag '${{ inputs.tag }}' does not match the expected format (e.g., v1.2.3 or v1.2.3.post1 or v1.2.3rc1)"
26+
# exit 1
27+
# fi
28+
# echo "✓ Tag format is valid: ${{ inputs.tag }}"
29+
30+
# - name: Check out tag
31+
# uses: actions/checkout@v4
32+
# with:
33+
# ref: ${{ inputs.tag }}
34+
# submodules: true
35+
36+
# - name: Verify tag matches version.txt
37+
# run: |
38+
# # Extract version from tag (remove 'v' prefix)
39+
# TAG_VERSION="${{ inputs.tag }}"
40+
# TAG_VERSION="${TAG_VERSION#v}"
41+
42+
# # Check version.txt - this is the source of truth
43+
# if [ ! -f "version.txt" ]; then
44+
# echo "Error: version.txt file not found!"
45+
# exit 1
46+
# fi
47+
48+
# VERSION_TXT=$(cat version.txt | tr -d '[:space:]')
49+
50+
# if [ "$TAG_VERSION" != "$VERSION_TXT" ]; then
51+
# echo "❌ CRITICAL ERROR: version.txt does not match tag!"
52+
# echo " Tag version: $TAG_VERSION"
53+
# echo " version.txt: $VERSION_TXT"
54+
# echo ""
55+
# echo "Please update version.txt to match the release version before creating a release."
56+
# echo "The tag should be 'v$VERSION_TXT' (e.g., if version.txt contains '1.2.3', tag should be 'v1.2.3')"
57+
# exit 1
58+
# fi
59+
60+
# echo "✓ version.txt matches tag version: $VERSION_TXT"
5761

5862
build-wheel:
5963
# needs: validate-tag
6064
strategy:
6165
fail-fast: false
6266
matrix:
63-
cuda: ["129"] #['126', '128', '129', '130']
67+
cuda: ["12.9"] #['12.6', '12.8', '12.9', '13.0']
6468
arch: ["x86_64"] #['x86_64', 'aarch64']
6569

6670
# Use self-hosted runners with specific labels based on architecture
@@ -69,31 +73,26 @@ jobs:
6973
steps:
7074
- uses: actions/checkout@v4
7175
with:
72-
ref: ${{ inputs.tag }}
76+
# ref: ${{ inputs.tag }}
7377
submodules: true
7478

7579
- name: Build wheel in container
80+
env:
81+
DOCKER_IMAGE: ${{ matrix.arch == 'aarch64' && format('pytorch/manylinux2_28_aarch64-builder:cuda{0}', matrix.cuda) || format('pytorch/manylinux2_28_builder:cuda{0}', matrix.cuda) }}
7682
run: |
7783
chown -R $CI_UID:$CI_GID ${{ github.workspace }}
78-
# Create output directory for wheels
79-
mkdir -p ${{ github.workspace }}/wheel-output
8084
8185
# Run the build script inside the container with proper mounts
8286
docker run --rm \
8387
-v ${{ github.workspace }}:/workspace \
84-
-v ${{ github.workspace }}/wheel-output:/output \
8588
-e CUDA_VERSION="${{ matrix.cuda }}" \
8689
-e ARCH="${{ matrix.arch }}" \
8790
-e FLASHINFER_CUDA_ARCH_LIST="${FLASHINFER_CUDA_ARCH_LIST}" \
88-
-e OUTPUT_DIR="/output" \
8991
--user $CI_UID:$CI_GID \
9092
-w /workspace \
91-
flashinfer/flashinfer-ci-cu${{ matrix.cuda }} \
93+
${{ env.DOCKER_IMAGE }} \
9294
bash /workspace/scripts/build_flashinfer_aot_modules_whl.sh
93-
94-
# Move wheels to the expected location for artifact upload
95-
mv wheel-output/* flashinfer-aot-modules/dist/ 2>/dev/null || true
96-
timeout-minutes: 300
95+
timeout-minutes: 180
9796

9897
- name: Display wheel size
9998
run: du -h flashinfer-aot-modules/dist/*

flashinfer-aot-modules/build_backend.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
limitations under the License.
1515
"""
1616

17+
import os
1718
import sys
19+
import sysconfig
1820
from pathlib import Path
1921
from setuptools import build_meta as _orig
22+
from setuptools.dist import strtobool
2023

2124
# Add parent directory to path to import flashinfer modules
2225
sys.path.insert(0, str(Path(__file__).parent.parent))
@@ -96,8 +99,30 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
9699

97100
print(f"Created build metadata file with version {version}")
98101

99-
# Now build the wheel using setuptools
100-
return _orig.build_wheel(wheel_directory, config_settings, metadata_directory)
102+
# Configure py_limited_api
103+
use_limited_api = strtobool(os.getenv("FLASHINFER_AOT_USE_PY_LIMITED_API", "1"))
104+
105+
# Temporarily create a setup.cfg to pass py_limited_api option
106+
setup_cfg_path = Path(__file__).parent / "setup.cfg"
107+
setup_cfg_created = False
108+
109+
if use_limited_api and not sysconfig.get_config_var("Py_GIL_DISABLED"):
110+
print("Building with py_limited_api=cp39 for ABI3 compatibility")
111+
if not setup_cfg_path.exists():
112+
with open(setup_cfg_path, "w") as f:
113+
f.write("[bdist_wheel]\n")
114+
f.write("py_limited_api=cp39\n")
115+
setup_cfg_created = True
116+
117+
try:
118+
# Now build the wheel using setuptools
119+
result = _orig.build_wheel(wheel_directory, config_settings, metadata_directory)
120+
finally:
121+
# Clean up temporary setup.cfg if we created it
122+
if setup_cfg_created and setup_cfg_path.exists():
123+
setup_cfg_path.unlink()
124+
125+
return result
101126

102127

103128
def build_sdist(sdist_directory, config_settings=None):

0 commit comments

Comments
 (0)