From 3f856ea0efa5d34d6e888206b72b3781fc0eec18 Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Fri, 15 Jul 2022 00:18:40 +0800 Subject: [PATCH 1/3] [workflow] updated release bdist workflow --- .github/workflows/build.yml | 2 +- .github/workflows/release_bdist.yml | 39 +++++++++++------- .../scripts/build_colossalai_wheel.py | 40 +++++++++---------- 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07452f4f398d..fa00a6a72c7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: contains( github.event.pull_request.labels.*.name, 'Run Build and Test') runs-on: [self-hosted, gpu] container: - image: hpcaitech/pytorch-cuda:1.10.1-11.3.0 + image: hpcaitech/pytorch-cuda:1.12.0-11.3.0 options: --gpus all --rm -v /data/scratch/cifar-10:/data/scratch/cifar-10 timeout-minutes: 40 steps: diff --git a/.github/workflows/release_bdist.yml b/.github/workflows/release_bdist.yml index 2e5233d0a29c..0efafd56a79d 100644 --- a/.github/workflows/release_bdist.yml +++ b/.github/workflows/release_bdist.yml @@ -3,16 +3,15 @@ name: Release bdist wheel on: workflow_dispatch: inputs: + torch_version: + type: string + description: torch version, separated by comma + required: true + default: "all" cuda_version: - type: choice - description: CUDA Version - default: 'all' + type: string + description: cuda version, separated by comma required: true - options: - - all - - "11.3" - - "11.1" - - "10.2" github_ref: type: string description: Branch or Tag @@ -27,12 +26,22 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - id: set-matrix + env: + TORCH_VERSIONS: ${{ inputs.torch_version }} + CUDA_VERSIONS: ${{ inputs.cuda_version }} run: | - [ "${{github.event.inputs.cuda_version}}" != "" ] && matrix="[\"hpcaitech/cuda-conda:${{github.event.inputs.cuda_version}}\"]" - [ "${{github.event.inputs.cuda_version}}" == "" ] || [ "${{github.event.inputs.cuda_version}}" == "all" ] && \ - matrix="[\"hpcaitech/cuda-conda:11.3\", \"hpcaitech/cuda-conda:11.1\", \"hpcaitech/cuda-conda:10.2\"]" - echo $matrix - echo "::set-output name=matrix::{\"container\":$(echo $matrix)}" + IFS=',' + DOCKER_IMAGE=() + + for cv in $CUDA_VERSIONS + do + DOCKER_IMAGE+=("\"hpcaitech/cuda-conda:${cv}\"") + done + + container=$( IFS=',' ; echo "${DOCKER_IMAGE[*]}" ) + container="[${container}]" + echo "$container" + echo "::set-output name=matrix::{\"container\":$(echo "$container")}" build: name: Release bdist wheels @@ -62,7 +71,9 @@ jobs: - name: Build bdist wheel run: | pip install beautifulsoup4 requests packaging - python ./build_colossalai_wheel.py + python ./build_colossalai_wheel.py --torch_version $TORCH_VERSIONS + env: + TORCH_VERSIONS: ${{ inputs.torch_version }} - name: 🚀 Deploy uses: garygrossgarten/github-action-scp@release with: diff --git a/.github/workflows/scripts/build_colossalai_wheel.py b/.github/workflows/scripts/build_colossalai_wheel.py index dcedca73790c..07d46eec5198 100644 --- a/.github/workflows/scripts/build_colossalai_wheel.py +++ b/.github/workflows/scripts/build_colossalai_wheel.py @@ -15,6 +15,7 @@ def parse_args(): parser = argparse.ArgumentParser() + parser.add_argument('--torch_version', type=str) parser.add_argument('--nightly', action='store_true', help='whether this build is for nightly release, if True, will only build on the latest PyTorch version and Python 3.8') return parser.parse_args() @@ -75,35 +76,34 @@ def build_colossalai(wheel_info): flags = wheel_info['flags'] filename = url.split('/')[-1].replace('%2B', '+') cmd = f'bash ./build_colossalai_wheel.sh {method} {url} {filename} {cuda_version} {python_version} {torch_version} {flags}' - os.system(cmd) + print(cmd) + # os.system(cmd) def main(): args = parse_args() wheel_info = all_wheel_info() - if args.nightly: - latest_torch_version = list(wheel_info.keys()) + # filter wheels on condition + all_torch_versions = list(wheel_info.keys()) + def _compare_version(a, b): + if version.parse(a) > version.parse(b): + return 1 + else: + return -1 - def _compare_version(a, b): - if version.parse(a) > version.parse(b): - return 1 - else: - return -1 + all_torch_versions.sort(key=cmp_to_key(_compare_version)) - latest_torch_version.sort(key=cmp_to_key(_compare_version)) - + if args.nightly: # only keep the latest version - for key in latest_torch_version[:-1]: + for key in all_torch_versions[:-1]: wheel_info.pop(key) - - # we only keep python 3.8 for nightly release - for torch_version, cuda_versioned_info in wheel_info.items(): - for cuda_version, python_versioned_info in cuda_versioned_info.items(): - python_versions = list(python_versioned_info.keys()) - - for key in python_versions: - if key != '3.8': - python_versioned_info.pop(key) + elif args.torch_version != 'all': + torch_versions = args.torch_version.split(',') + # only keep the torch versions specified + for key in all_torch_versions: + if key not in torch_versions: + wheel_info.pop(key) + build_colossalai(wheel_info) if __name__ == '__main__': From f2ab07d22e1ae0645f35173071949029c48a96bb Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Fri, 15 Jul 2022 00:25:30 +0800 Subject: [PATCH 2/3] polish workflow --- .github/workflows/scripts/build_colossalai_wheel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/scripts/build_colossalai_wheel.py b/.github/workflows/scripts/build_colossalai_wheel.py index 07d46eec5198..2d33238e25de 100644 --- a/.github/workflows/scripts/build_colossalai_wheel.py +++ b/.github/workflows/scripts/build_colossalai_wheel.py @@ -76,8 +76,7 @@ def build_colossalai(wheel_info): flags = wheel_info['flags'] filename = url.split('/')[-1].replace('%2B', '+') cmd = f'bash ./build_colossalai_wheel.sh {method} {url} {filename} {cuda_version} {python_version} {torch_version} {flags}' - print(cmd) - # os.system(cmd) + os.system(cmd) def main(): args = parse_args() From 89cf6ca4d6878674ae77a0f8fa351d7e0fd2dba4 Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Fri, 15 Jul 2022 00:41:34 +0800 Subject: [PATCH 3/3] polish workflow --- .github/workflows/release_bdist.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release_bdist.yml b/.github/workflows/release_bdist.yml index 0efafd56a79d..7d5f9e731743 100644 --- a/.github/workflows/release_bdist.yml +++ b/.github/workflows/release_bdist.yml @@ -30,6 +30,8 @@ jobs: TORCH_VERSIONS: ${{ inputs.torch_version }} CUDA_VERSIONS: ${{ inputs.cuda_version }} run: | + echo $TORCH_VERSIONS + echo $CUDA_VERSIONS IFS=',' DOCKER_IMAGE=()