|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# All rights reserved. |
| 3 | +# This source code is licensed under the BSD-style license found in the |
| 4 | +# LICENSE file in the root directory of this source tree. |
| 5 | + |
| 6 | +# This workflow is used for FBGEMM_GPU-CUDA Benchmarking |
| 7 | +name: FBGEMM_GPU-CPU Benchmark |
| 8 | + |
| 9 | +on: |
| 10 | + # PR Trigger (enabled for regression checks and debugging) |
| 11 | + # |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + |
| 16 | + # Manual Trigger |
| 17 | + # |
| 18 | + workflow_dispatch: |
| 19 | + inputs: |
| 20 | + pytorch_channel_version: |
| 21 | + description: Package Channel + Version to Use for PyTorch Installation, in `<channel>[/<version>]` Format |
| 22 | + type: string |
| 23 | + required: false |
| 24 | + default: "" |
| 25 | + publish_to_pypi: |
| 26 | + description: Publish Artifact to PyPI |
| 27 | + type: boolean |
| 28 | + required: false |
| 29 | + default: false |
| 30 | + |
| 31 | +concurrency: |
| 32 | + # Cancel previous runs in the PR if a new commit is pushed |
| 33 | + # https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre |
| 34 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +jobs: |
| 38 | + # Build on CPU hosts, run tests, and upload to GHA |
| 39 | + build_artifact: |
| 40 | + if: ${{ github.repository_owner == 'pytorch' }} |
| 41 | + runs-on: ${{ matrix.host-machine.instance }} |
| 42 | + container: |
| 43 | + image: amazonlinux:2023 |
| 44 | + options: --user root |
| 45 | + defaults: |
| 46 | + run: |
| 47 | + shell: bash |
| 48 | + env: |
| 49 | + PRELUDE: .github/scripts/setup_env.bash |
| 50 | + BUILD_ENV: build_binary |
| 51 | + BUILD_VARIANT: cpu |
| 52 | + continue-on-error: true |
| 53 | + strategy: |
| 54 | + # Don't fast-fail all the other builds if one of the them fails |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + host-machine: [ |
| 58 | + { arch: x86, instance: "linux.4xlarge" }, |
| 59 | + { arch: arm, instance: "linux.arm64.2xlarge" }, |
| 60 | + ] |
| 61 | + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] |
| 62 | + compiler: [ "gcc", "clang" ] |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Setup Build Container |
| 66 | + run: yum update -y; yum install -y binutils findutils git pciutils sudo wget which |
| 67 | + |
| 68 | + - name: Checkout the Repository |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Display System Info |
| 72 | + run: . $PRELUDE; print_system_info |
| 73 | + |
| 74 | + - name: Display GPU Info |
| 75 | + run: . $PRELUDE; print_gpu_info |
| 76 | + |
| 77 | + - name: Setup Miniconda |
| 78 | + run: . $PRELUDE; setup_miniconda $HOME/miniconda |
| 79 | + |
| 80 | + - name: Create Conda Environment |
| 81 | + run: . $PRELUDE; create_conda_environment $BUILD_ENV ${{ matrix.python-version }} |
| 82 | + |
| 83 | + - name: Install C/C++ Compilers |
| 84 | + run: . $PRELUDE; install_cxx_compiler $BUILD_ENV ${{ matrix.compiler }} |
| 85 | + |
| 86 | + - name: Install Build Tools |
| 87 | + run: . $PRELUDE; install_build_tools $BUILD_ENV |
| 88 | + |
| 89 | + - name: Install PyTorch-CPU Nightly |
| 90 | + run: . $PRELUDE; install_pytorch_pip $BUILD_ENV ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.pytorch_channel_version) || 'nightly' }} cpu |
| 91 | + |
| 92 | + - name: Collect PyTorch Environment Info |
| 93 | + if: ${{ success() || failure() }} |
| 94 | + run: if . $PRELUDE && which conda; then collect_pytorch_env_info $BUILD_ENV; fi |
| 95 | + |
| 96 | + - name: Prepare FBGEMM_GPU Build |
| 97 | + run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV |
| 98 | + |
| 99 | + - name: Build FBGEMM_GPU Wheel |
| 100 | + run: . $PRELUDE; cd fbgemm_gpu; build_fbgemm_gpu_package $BUILD_ENV nightly cpu |
| 101 | + |
| 102 | + - name: Upload Built Wheel as GHA Artifact |
| 103 | + uses: actions/upload-artifact@v4 |
| 104 | + with: |
| 105 | + name: fbgemm_gpu_nightly_cpu_${{ matrix.host-machine.arch }}_${{ matrix.compiler }}_py${{ matrix.python-version }}.whl |
| 106 | + path: fbgemm_gpu/dist/*.whl |
| 107 | + if-no-files-found: error |
| 108 | + |
| 109 | + |
| 110 | + # Download the built artifact from GHA, test on GPU, and push to PyPI |
| 111 | + benchmark_artifact: |
| 112 | + if: ${{ github.repository_owner == 'pytorch' }} |
| 113 | + runs-on: ${{ matrix.host-machine.instance }} |
| 114 | + container: |
| 115 | + image: amazonlinux:2023 |
| 116 | + options: --user root |
| 117 | + defaults: |
| 118 | + run: |
| 119 | + shell: bash |
| 120 | + env: |
| 121 | + PRELUDE: .github/scripts/setup_env.bash |
| 122 | + BUILD_ENV: build_binary |
| 123 | + BUILD_VARIANT: cpu |
| 124 | + strategy: |
| 125 | + fail-fast: false |
| 126 | + matrix: |
| 127 | + host-machine: [ |
| 128 | + { arch: x86, instance: "linux.4xlarge", timeout: 20 }, |
| 129 | + { arch: arm, instance: "linux.arm64.2xlarge", timeout: 30 }, |
| 130 | + ] |
| 131 | + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] |
| 132 | + compiler: [ "gcc", "clang" ] |
| 133 | + needs: build_artifact |
| 134 | + |
| 135 | + steps: |
| 136 | + - name: Setup Build Container |
| 137 | + run: yum update -y; yum install -y binutils findutils git pciutils sudo wget which |
| 138 | + |
| 139 | + - name: Checkout the Repository |
| 140 | + uses: actions/checkout@v4 |
| 141 | + |
| 142 | + - name: Download Wheel Artifact from GHA |
| 143 | + uses: actions/download-artifact@v4 |
| 144 | + with: |
| 145 | + name: fbgemm_gpu_nightly_cpu_${{ matrix.host-machine.arch }}_${{ matrix.compiler }}_py${{ matrix.python-version }}.whl |
| 146 | + |
| 147 | + - name: Display System Info |
| 148 | + run: . $PRELUDE; print_system_info; print_ec2_info |
| 149 | + |
| 150 | + - name: Display GPU Info |
| 151 | + run: . $PRELUDE; print_gpu_info |
| 152 | + |
| 153 | + - name: Setup Miniconda |
| 154 | + run: . $PRELUDE; setup_miniconda $HOME/miniconda |
| 155 | + |
| 156 | + - name: Create Conda Environment |
| 157 | + run: . $PRELUDE; create_conda_environment $BUILD_ENV ${{ matrix.python-version }} |
| 158 | + |
| 159 | + - name: Install C/C++ Compilers for Updated LIBGCC |
| 160 | + run: . $PRELUDE; install_cxx_compiler $BUILD_ENV ${{ matrix.compiler }} |
| 161 | + |
| 162 | + - name: Install PyTorch-CPU Nightly |
| 163 | + run: . $PRELUDE; install_pytorch_pip $BUILD_ENV ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.pytorch_channel_version) || 'nightly' }} cpu |
| 164 | + |
| 165 | + - name: Collect PyTorch Environment Info |
| 166 | + if: ${{ success() || failure() }} |
| 167 | + run: if . $PRELUDE && which conda; then collect_pytorch_env_info $BUILD_ENV; fi |
| 168 | + |
| 169 | + - name: Prepare FBGEMM_GPU Build |
| 170 | + run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV |
| 171 | + |
| 172 | + - name: Install FBGEMM_GPU Wheel |
| 173 | + run: . $PRELUDE; install_fbgemm_gpu_wheel $BUILD_ENV *.whl |
| 174 | + |
| 175 | + - name: Run FBGEMM_GPU Benchmark |
| 176 | + timeout-minutes: 40 |
| 177 | + run: . $PRELUDE; run_tbe_microbench $BUILD_ENV |
0 commit comments