Skip to content

Commit

Permalink
Add CUDA artifact selection on publish (pytorch#2005)
Browse files Browse the repository at this point in the history
Summary:
- Add CUDA version selection on artifact publishing
- Add new workflow file for testing installations of FBGEMM_GPU through pip

Pull Request resolved: pytorch#2005

Reviewed By: shintaro-iwasaki

Differential Revision: D49084679

Pulled By: q10

fbshipit-source-id: 2406734aebef9d998e06c733bdb7377ea30bcd61
  • Loading branch information
q10 authored and facebook-github-bot committed Sep 8, 2023
1 parent 4decf7b commit b5bc229
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 50 deletions.
32 changes: 0 additions & 32 deletions .github/scripts/fbgemm_gpu_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -402,35 +402,3 @@ build_fbgemm_gpu_develop () {

echo "[BUILD] FBGEMM-GPU build + develop completed"
}

install_fbgemm_gpu_package () {
local env_name="$1"
local package_name="$2"
if [ "$package_name" == "" ]; then
echo "Usage: ${FUNCNAME[0]} ENV_NAME WHEEL_NAME"
echo "Example(s):"
echo " ${FUNCNAME[0]} build_env fbgemm_gpu.whl # Install the package (wheel)"
return 1
else
echo "################################################################################"
echo "# Install FBGEMM-GPU Package (Wheel)"
echo "#"
echo "# [TIMESTAMP] $(date --utc +%FT%T.%3NZ)"
echo "################################################################################"
echo ""
fi

echo "[INSTALL] Printing out FBGEMM-GPU wheel SHA: ${package_name}"
print_exec sha1sum "${package_name}"
print_exec sha256sum "${package_name}"
print_exec md5sum "${package_name}"

echo "[INSTALL] Installing FBGEMM-GPU wheel: ${package_name} ..."
(exec_with_retries conda run -n "${env_name}" python -m pip install "${package_name}") || return 1

echo "[INSTALL] Checking imports ..."
(test_python_import "${env_name}" fbgemm_gpu) || return 1
(test_python_import "${env_name}" fbgemm_gpu.split_embedding_codegen_lookup_invokers) || return 1

echo "[INSTALL] Wheel installation completed ..."
}
134 changes: 134 additions & 0 deletions .github/scripts/fbgemm_gpu_install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.


# shellcheck disable=SC1091,SC2128
. "$( dirname -- "$BASH_SOURCE"; )/utils_base.bash"

################################################################################
# FBGEMM_GPU Install Functions
################################################################################

install_fbgemm_gpu_wheel () {
local env_name="$1"
local wheel_path="$2"
if [ "$wheel_path" == "" ]; then
echo "Usage: ${FUNCNAME[0]} ENV_NAME WHEEL_NAME"
echo "Example(s):"
echo " ${FUNCNAME[0]} build_env fbgemm_gpu.whl # Install the package (wheel)"
return 1
else
echo "################################################################################"
echo "# Install FBGEMM-GPU from Wheel"
echo "#"
echo "# [TIMESTAMP] $(date --utc +%FT%T.%3NZ)"
echo "################################################################################"
echo ""
fi

echo "[INSTALL] Printing out FBGEMM-GPU wheel SHA: ${wheel_path}"
print_exec sha1sum "${wheel_path}"
print_exec sha256sum "${wheel_path}"
print_exec md5sum "${wheel_path}"

echo "[INSTALL] Installing FBGEMM-GPU wheel: ${wheel_path} ..."
(exec_with_retries conda run -n "${env_name}" python -m pip install "${wheel_path}") || return 1

echo "[INSTALL] Checking imports ..."
(test_python_import "${env_name}" fbgemm_gpu) || return 1
(test_python_import "${env_name}" fbgemm_gpu.split_embedding_codegen_lookup_invokers) || return 1

echo "[INSTALL] FBGEMM-GPU installation through wheel completed ..."
}



install_fbgemm_gpu_pip () {
local env_name="$1"
local fbgemm_gpu_version="$2"
local fbgemm_gpu_variant_type="$3"
local fbgemm_gpu_variant_version="$4"
if [ "$fbgemm_gpu_variant_type" == "" ]; then
echo "Usage: ${FUNCNAME[0]} ENV_NAME FBGEMM_GPU_VERSION FBGEMM_GPU_VARIANT_TYPE [FBGEMM_GPU_VARIANT_VERSION]"
echo "Example(s):"
echo " ${FUNCNAME[0]} build_env 0.5.0rc2 cuda 12.1.1 # Install a specific version of the package (PyPI)"
return 1
else
echo "################################################################################"
echo "# Install FBGEMM-GPU Package from PIP"
echo "#"
echo "# [TIMESTAMP] $(date --utc +%FT%T.%3NZ)"
echo "################################################################################"
echo ""
fi

# Set the package variant
if [ "$fbgemm_gpu_variant_type" == "cuda" ]; then
# Extract the CUDA version or default to 11.8.0
local cuda_version="${fbgemm_gpu_variant_version:-11.8.0}"
# shellcheck disable=SC2206
local cuda_version_arr=(${cuda_version//./ })
# Convert, i.e. cuda 11.7.1 => cu117
local fbgemm_gpu_variant="cu${cuda_version_arr[0]}${cuda_version_arr[1]}"
elif [ "$fbgemm_gpu_variant_type" == "rocm" ]; then
# Extract the ROCM version or default to 5.5.1
local rocm_version="${fbgemm_gpu_variant_version:-5.5.1}"
# shellcheck disable=SC2206
local rocm_version_arr=(${rocm_version//./ })
# Convert, i.e. rocm 5.5.1 => rocm5.5
local fbgemm_gpu_variant="rocm${rocm_version_arr[0]}.${rocm_version_arr[1]}"
else
local fbgemm_gpu_variant_type="cpu"
local fbgemm_gpu_variant="cpu"
fi
echo "[INSTALL] Extracted FBGEMM-GPU variant: ${fbgemm_gpu_variant}"

# Set the package name and installation channel
# if [ "$fbgemm_gpu_version" == "nightly" ] || [ "$fbgemm_gpu_version" == "test" ]; then
# local fbgemm_gpu_package="--pre fbgemm-gpu"
# local fbgemm_gpu_channel="https://download.pytorch.org/whl/${fbgemm_gpu_version}/${fbgemm_gpu_variant}/"
# elif [ "$fbgemm_gpu_version" == "latest" ]; then
# local fbgemm_gpu_package="fbgemm-gpu"
# local fbgemm_gpu_channel="https://download.pytorch.org/whl/${fbgemm_gpu_variant}/"
# else
# local fbgemm_gpu_package="fbgemm-gpu==${fbgemm_gpu_version}+${fbgemm_gpu_variant}"
# local fbgemm_gpu_channel="https://download.pytorch.org/whl/${fbgemm_gpu_variant}/"
# fi

if [ "$fbgemm_gpu_variant_type" == "cuda" ]; then
if [ "$fbgemm_gpu_version" == "nightly" ]; then
local fbgemm_gpu_package="fbgemm-gpu-nightly"
elif [ "$fbgemm_gpu_version" == "latest" ]; then
local fbgemm_gpu_package="fbgemm-gpu"
else
local fbgemm_gpu_package="fbgemm-gpu==${fbgemm_gpu_version}"
fi

elif [ "$fbgemm_gpu_variant_type" == "rocm" ]; then
echo "ROCm is currently not supported in PyPI!"
return 1

else
if [ "$fbgemm_gpu_version" == "nightly" ]; then
local fbgemm_gpu_package="fbgemm-gpu-nightly-cpu"
elif [ "$fbgemm_gpu_version" == "latest" ]; then
local fbgemm_gpu_package="fbgemm-gpu-cpu"
else
local fbgemm_gpu_package="fbgemm-gpu-cpu==${fbgemm_gpu_version}"
fi
fi

echo "[INSTALL] Attempting to install FBGEMM-GPU ${fbgemm_gpu_version}+${fbgemm_gpu_variant} through PIP ..."
# shellcheck disable=SC2086
(exec_with_retries conda run -n "${env_name}" pip install ${fbgemm_gpu_package}) || return 1

echo "[INSTALL] Checking imports ..."
(test_python_import "${env_name}" fbgemm_gpu) || return 1
(test_python_import "${env_name}" fbgemm_gpu.split_embedding_codegen_lookup_invokers) || return 1

echo "[INSTALL] FBGEMM-GPU installation through PIP completed ..."
}
4 changes: 1 addition & 3 deletions .github/scripts/fbgemm_gpu_test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ test_setup_conda_environment () {
else
install_pytorch_pip "${env_name}" "${pytorch_version}" "${pytorch_variant_type}" "${pytorch_variant_version}" || return 1
fi

return "${env_name}"
}

test_fbgemm_gpu_build_and_install () {
Expand All @@ -184,7 +182,7 @@ test_fbgemm_gpu_build_and_install () {
build_fbgemm_gpu_package "${env_name}" release "${pytorch_variant_type}" || return 1
# shellcheck disable=SC2164
cd -
install_fbgemm_gpu_package "${env_name}" fbgemm_gpu/dist/*.whl || return 1
install_fbgemm_gpu_wheel "${env_name}" fbgemm_gpu/dist/*.whl || return 1

cd fbgemm_gpu/test || return 1
run_fbgemm_gpu_tests "${env_name}" || return 1
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/setup_env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# shellcheck disable=SC1091,SC2128
. "$( dirname -- "$BASH_SOURCE"; )/fbgemm_gpu_docs.bash"
# shellcheck disable=SC1091,SC2128
. "$( dirname -- "$BASH_SOURCE"; )/fbgemm_gpu_install.bash"
# shellcheck disable=SC1091,SC2128
. "$( dirname -- "$BASH_SOURCE"; )/fbgemm_gpu_lint.bash"
# shellcheck disable=SC1091,SC2128
. "$( dirname -- "$BASH_SOURCE"; )/fbgemm_gpu_test.bash"
Expand Down
8 changes: 4 additions & 4 deletions .github/scripts/utils_pytorch.bash
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ install_pytorch_pip () {

# Set the package variant
if [ "$pytorch_variant_type" == "cuda" ]; then
# Extract the CUDA version or default to 11.7.1
local cuda_version="${pytorch_variant_version:-11.7.1}"
# Extract the CUDA version or default to 11.8.0
local cuda_version="${pytorch_variant_version:-11.8.0}"
# shellcheck disable=SC2206
local cuda_version_arr=(${cuda_version//./ })
# Convert, i.e. cuda 11.7.1 => cu117
local pytorch_variant="cu${cuda_version_arr[0]}${cuda_version_arr[1]}"
elif [ "$pytorch_variant_type" == "rocm" ]; then
# Extract the ROCM version or default to 5.3
local rocm_version="${pytorch_variant_version:-5.3}"
# Extract the ROCM version or default to 5.5.1
local rocm_version="${pytorch_variant_version:-5.5.1}"
# shellcheck disable=SC2206
local rocm_version_arr=(${rocm_version//./ })
# Convert, i.e. rocm 5.5.1 => rocm5.5
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/fbgemm_gpu_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ jobs:
- name: Prepare FBGEMM_GPU Build
run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV

- name: Build FBGEMM_GPU-ROCM Nightly
- name: Build FBGEMM_GPU-ROCm Nightly
run: . $PRELUDE; cd fbgemm_gpu; build_fbgemm_gpu_develop $BUILD_ENV rocm gfx90a

- name: Test FBGEMM_GPU-ROCM Nightly Installation
- name: Test FBGEMM_GPU-ROCm Nightly Installation
timeout-minutes: 10
run: . $PRELUDE; cd fbgemm_gpu/test; run_fbgemm_gpu_tests $BUILD_ENV rocm

Expand Down Expand Up @@ -154,10 +154,10 @@ jobs:
- name: Prepare FBGEMM_GPU Build
run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV

- name: Build FBGEMM_GPU-ROCM Nightly
- name: Build FBGEMM_GPU-ROCm Nightly
run: . $PRELUDE; cd fbgemm_gpu; build_fbgemm_gpu_develop $BUILD_ENV rocm

- name: Test FBGEMM_GPU-ROCM Nightly Installation
- name: Test FBGEMM_GPU-ROCm Nightly Installation
timeout-minutes: 15
run: . $PRELUDE; cd fbgemm_gpu/test; run_fbgemm_gpu_tests $BUILD_ENV rocm

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fbgemm_gpu_cpu_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
run: |
. $PRELUDE
pwd; ls -la .
install_fbgemm_gpu_package $BUILD_ENV *.whl
install_fbgemm_gpu_wheel $BUILD_ENV *.whl
- name: Test with PyTest
timeout-minutes: 10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fbgemm_gpu_cpu_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
run: |
. $PRELUDE
pwd; ls -la .
install_fbgemm_gpu_package $BUILD_ENV *.whl
install_fbgemm_gpu_wheel $BUILD_ENV *.whl
- name: Test with PyTest
timeout-minutes: 10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fbgemm_gpu_cuda_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV

- name: Install FBGEMM_GPU Nightly
run: . $PRELUDE; install_fbgemm_gpu_package $BUILD_ENV *.whl
run: . $PRELUDE; install_fbgemm_gpu_wheel $BUILD_ENV *.whl

- name: Test with PyTest
timeout-minutes: 10
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/fbgemm_gpu_cuda_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ on:
type: boolean
required: false
default: false
cuda_version:
description: CUDA Version to Use for PyPI Publishing
type: choice
required: false
options: [ "11.8.0", "12.1.1" ]
default: "11.8.0"

concurrency:
# Cancel previous runs in the PR if a new commit is pushed
Expand Down Expand Up @@ -124,8 +130,6 @@ jobs:
]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
cuda-version: [ "11.8.0", "12.1.1" ]
# Specify exactly ONE CUDA version for artifact publish
cuda-version-publish: [ "11.8.0" ]
needs: build_artifact

steps:
Expand Down Expand Up @@ -164,14 +168,14 @@ jobs:
run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV

- name: Install FBGEMM_GPU
run: . $PRELUDE; install_fbgemm_gpu_package $BUILD_ENV *.whl
run: . $PRELUDE; install_fbgemm_gpu_wheel $BUILD_ENV *.whl

- name: Test with PyTest
timeout-minutes: 10
run: . $PRELUDE; cd fbgemm_gpu/test; run_fbgemm_gpu_tests $BUILD_ENV

- name: Push FBGEMM_GPU Binary to PYPI
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_pypi == 'true' && matrix.cuda-version == matrix.cuda-version-publish }}
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_pypi == 'true' && matrix.cuda-version == github.event.inputs.cuda_version }}
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: . $PRELUDE; publish_to_pypi $BUILD_ENV fbgemm_gpu-*.whl "$PYPI_TOKEN"
Loading

0 comments on commit b5bc229

Please sign in to comment.