Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored Aug 10, 2024
0 parents commit c0604f5
Show file tree
Hide file tree
Showing 20 changed files with 968 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/actions/apply-patches/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Apply patches

inputs:
name:
required: true
type: string

path:
default: .
type: string

version:
default: ~
type: string

runs:
using: "composite"

steps:
- name: Apply patches
shell: bash
run: |
set -e
# Constants
readonly CONTENT_PATH="patches/${{ inputs.name }}"
readonly VERSION="${{ inputs.version }}"
# API endpoint template
contents() {
echo "/repos/${{ github.repository }}/contents/$1?ref=${{ github.sha }}"
}
# Function to apply patch
apply() {
# Apply patch
if [[ "$1" == *.patch ]]; then
# Log patch name
echo "Applying patch $1..."
# Apply
gh api "$(contents $CONTENT_PATH/$1)" --jq '.content' | base64 -d | patch -p1
fi
# Apply script
if [[ "$1" == *.sh ]]; then
# Log script name
echo "Applying script $1..."
# Apply
gh api "$(contents $CONTENT_PATH/$1)" --jq '.content' | base64 -d | bash
fi
}
# Is version-specific patches present?
HAS_VERSION_DIR=0
# Go to directory
cd "${{ inputs.path }}"
# Apply patches
for name in $(gh api "$(contents $CONTENT_PATH)" --jq '.[].name'); do
# If directory with current version name present, apply patches in directory later
if [[ "$name" == "$VERSION" ]]; then
HAS_VERSION_DIR=1
fi
# Apply patch
apply "$name"
done
# Apply patches for current version
if [[ "$HAS_VERSION_DIR" == "1" ]]; then
for name in $(gh api "$(contents $CONTENT_PATH/$VERSION)" --jq '.[].name'); do
apply "$VERSION/$name"
done
fi
env:
GH_TOKEN: ${{ github.token }}
77 changes: 77 additions & 0 deletions .github/actions/build-triton/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build Triton wheels

inputs:
name:
default: triton
type: string

patches_version:
default: ~
type: string

python_version:
required: true
type: string

ref:
default: main
type: string

repository:
default: triton-lang/triton
type: string

version:
default: ~
type: string

runs:
using: "composite"

steps:
- name: Normalize wheel name
shell: bash
run: echo WHEEL_NAME=${WHEEL_NAME/-/_} >> "$GITHUB_ENV"
env:
WHEEL_NAME: "${{ inputs.name }}"

- name: Checkout ${{ inputs.repository }} (${{ inputs.ref }})
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository }}
path: ${{ env.WHEEL_NAME }}

- if: inputs.patches_version != ''
name: Apply patches (${{ inputs.patches_version }})
uses: ./.github/actions/apply-patches
with:
name: ${{ env.WHEEL_NAME }}
path: ${{ env.WHEEL_NAME }}
version: ${{ inputs.patches_version }}

- name: Resolve SOURCE_DATE_EPOCH
shell: bash
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" | tee "$GITHUB_ENV"

- name: Build wheels
uses: pypa/cibuildwheel@v2.18.0
with:
package-dir: ${{ env.WHEEL_NAME }}/python
env:
CIBW_BUILD: cp${{ inputs.python_version }}-manylinux_x86_64
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64:latest
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64:latest
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}

- name: Repackage wheels
uses: ./.github/actions/repackage-wheels
with:
name: ${{ env.WHEEL_NAME }}
version: ${{ inputs.wheel_version }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.WHEEL_NAME }}-cp${{ inputs.python_version }}
path: wheelhouse/*.whl
81 changes: 81 additions & 0 deletions .github/actions/build-vllm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build vLLM wheels

inputs:
name:
default: vllm
type: string

patches_version:
default: ~
type: string

ref:
default: main
type: string

repository:
default: vllm-project/vllm
type: string

version:
default: ~
type: string

runs:
using: "composite"

steps:
- name: Normalize wheel name
shell: bash
run: echo WHEEL_NAME=${WHEEL_NAME/-/_} >> "$GITHUB_ENV"
env:
WHEEL_NAME: "${{ inputs.name }}"

- name: Clear cache
shell: bash
run: rm -fr /opt/hostedtoolcache

- name: Checkout ${{ inputs.repository }} (${{ inputs.ref }})
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository }}
path: ${{ env.WHEEL_NAME }}

- if: inputs.patches_version != ''
name: Apply patches (${{ inputs.patches_version }})
uses: ./.github/actions/apply-patches
with:
name: ${{ env.WHEEL_NAME }}
path: ${{ env.WHEEL_NAME }}
version: ${{ inputs.patches_version }}

- name: Resolve SOURCE_DATE_EPOCH
shell: bash
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" | tee "$GITHUB_ENV"

- name: Build wheels
uses: pypa/cibuildwheel@v2.18.0
with:
package-dir: ${{ env.WHEEL_NAME }}
env:
CIBW_BUILD: cp38-manylinux_x86_64
CIBW_ENVIRONMENT: >
CMAKE_BUILD_TYPE=Release
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ghcr.io/sasha0552/manylinux2014_x86_64-cuda:latest
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/sasha0552/manylinux2014_x86_64-cuda:latest
CIBW_REPAIR_WHEEL_COMMAND: ~
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}

- name: Repackage wheels
uses: ./.github/actions/repackage-wheels
with:
name: ${{ env.WHEEL_NAME }}
version: ${{ inputs.wheel_version }}
tags: cp38-abi3-manylinux1_x86_64

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.WHEEL_NAME }}
path: wheelhouse/*.whl
28 changes: 28 additions & 0 deletions .github/actions/publish-wheels/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish wheels

inputs:
prefix:
required: true
type: string

runs:
using: "composite"

steps:
- name: Download artifact
uses: actions/download-artifact@v4

- name: Remove previous wheels
uses: mknejp/delete-release-assets@v1
with:
assets: "${{ inputs.prefix }}*.whl"
fail-if-no-assets: false
fail-if-no-release: false
tag: wheels
token: ${{ github.token }}

- name: Upload wheels
uses: softprops/action-gh-release@v2
with:
files: "**/${{ inputs.prefix }}*.whl"
tag_name: wheels
Loading

0 comments on commit c0604f5

Please sign in to comment.