|
| 1 | +name: vLLM Profiling |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run every week on Sunday at midnight |
| 6 | + - cron: '0 0 * * 0' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + vllm_branch: |
| 10 | + description: vLLM branch (main, releases/vERSION for release validation, or refs/pull/PR_NUMBER/head for pre-merge check on pull request) |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + default: main |
| 14 | + vllm_commit: |
| 15 | + description: vLLM commit (optional, default to the latest commit in the branch that has not yet been benchmarked) |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + models: |
| 19 | + description: | |
| 20 | + A comma-separated list of models (optional, default to run everything) |
| 21 | + required: false |
| 22 | + type: string |
| 23 | + default: 'facebook/opt-125m' |
| 24 | + pull_request: |
| 25 | + paths: |
| 26 | + - .github/workflows/vllm-profiling.yml |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +jobs: |
| 33 | + set-parameters: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - uses: actions/setup-python@v5 |
| 40 | + with: |
| 41 | + python-version: '3.12' |
| 42 | + profiling: |
| 43 | + name: Run vLLM profiling |
| 44 | + needs: set-parameters |
| 45 | + strategy: |
| 46 | + fail-fast: false |
| 47 | + matrix: |
| 48 | + include: |
| 49 | + # TODO: Figure out later if we need to scale this up to multiple runners |
| 50 | + - runs-on: linux.aws.h100.4 |
| 51 | + device-name: cuda |
| 52 | + runs-on: ${{ matrix.runs-on }} |
| 53 | + environment: pytorch-x-vllm |
| 54 | + permissions: |
| 55 | + id-token: write |
| 56 | + contents: read |
| 57 | + steps: |
| 58 | + - name: Checkout repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Checkout vLLM repository |
| 62 | + uses: actions/checkout@v4 |
| 63 | + with: |
| 64 | + repository: vllm-project/vllm |
| 65 | + path: vllm |
| 66 | + ref: ${{ inputs.vllm_branch || 'main' }} |
| 67 | + fetch-depth: 0 |
| 68 | + |
| 69 | + - uses: actions/setup-python@v5 |
| 70 | + # Amazon Linux fails on this step |
| 71 | + continue-on-error: true |
| 72 | + with: |
| 73 | + python-version: '3.12' |
| 74 | + cache: 'pip' |
| 75 | + |
| 76 | + - name: Check if the device is supported |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + set -eux |
| 80 | +
|
| 81 | + if command -v nvidia-smi; then |
| 82 | + DEVICE_NAME=cuda |
| 83 | + nvidia-smi |
| 84 | + elif command -v rocm-smi; then |
| 85 | + DEVICE_NAME=rocm |
| 86 | + rocm-smi |
| 87 | + else |
| 88 | + DEVICE_NAME=cpu |
| 89 | + lscpu |
| 90 | + fi |
| 91 | + echo "DEVICE_NAME=$DEVICE_NAME" >> $GITHUB_ENV |
| 92 | +
|
| 93 | + - name: Set GPU name and type |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + set -eux |
| 97 | +
|
| 98 | + if [[ "${DEVICE_NAME}" == "cuda" ]]; then |
| 99 | + DEVICE_TYPE=$(nvidia-smi -i 0 --query-gpu=name --format=csv,noheader | awk '{print $2}') |
| 100 | + elif [[ "${DEVICE_NAME}" == "rocm" ]]; then |
| 101 | + DEVICE_TYPE=$(rocminfo | grep "Marketing Name" | tail -n1 | awk -F':' '{print $2}' | xargs) |
| 102 | + elif [[ "${DEVICE_NAME}" == "cpu" ]]; then |
| 103 | + DEVICE_TYPE=$(lscpu | grep 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | cut -f 2 -d " ") |
| 104 | + fi |
| 105 | + echo "DEVICE_TYPE=$DEVICE_TYPE" >> $GITHUB_ENV |
| 106 | +
|
| 107 | + - name: Install dependencies |
| 108 | + shell: bash |
| 109 | + run: | |
| 110 | + set -eux |
| 111 | +
|
| 112 | + if [[ "${DEVICE_NAME}" == "rocm" ]]; then |
| 113 | + pip install -r .github/scripts/requirements.txt \ |
| 114 | + --extra-index-url https://download.pytorch.org/whl/rocm6.3 |
| 115 | + else |
| 116 | + pip install -r .github/scripts/requirements.txt \ |
| 117 | + --extra-index-url https://download.pytorch.org/whl/cu128 |
| 118 | + fi |
| 119 | +
|
| 120 | + - name: Set Docker registry |
| 121 | + shell: bash |
| 122 | + env: |
| 123 | + HEAD_BRANCH: ${{ inputs.vllm_branch || 'main' }} |
| 124 | + run: | |
| 125 | + set -eux |
| 126 | +
|
| 127 | + # Mimic the logic from vllm ci-infra test template |
| 128 | + if [[ "${HEAD_BRANCH}" == "main" ]]; then |
| 129 | + DOCKER_IMAGE_PREFIX=public.ecr.aws/q9t5s3a7/vllm-ci-postmerge-repo |
| 130 | + else |
| 131 | + DOCKER_IMAGE_PREFIX=public.ecr.aws/q9t5s3a7/vllm-ci-test-repo |
| 132 | + fi |
| 133 | +
|
| 134 | + DOCKER_IMAGE_SUFFIX="" |
| 135 | + if [[ "${DEVICE_NAME}" == "rocm" ]]; then |
| 136 | + DOCKER_IMAGE_PREFIX=docker.io/rocm/vllm-ci |
| 137 | + elif [[ "${DEVICE_NAME}" == "cpu" ]]; then |
| 138 | + DOCKER_IMAGE_SUFFIX=-cpu |
| 139 | + fi |
| 140 | + echo "DOCKER_IMAGE_PREFIX=$DOCKER_IMAGE_PREFIX" >> $GITHUB_ENV |
| 141 | + echo "DOCKER_IMAGE_SUFFIX=$DOCKER_IMAGE_SUFFIX" >> $GITHUB_ENV |
| 142 | +
|
| 143 | + - name: Check for last commit |
| 144 | + env: |
| 145 | + HEAD_BRANCH: ${{ inputs.vllm_branch || 'main' }} |
| 146 | + HEAD_SHA: ${{ inputs.vllm_commit || '' }} |
| 147 | + run: | |
| 148 | + set -eux |
| 149 | +
|
| 150 | + if [[ -z "${HEAD_SHA}" ]]; then |
| 151 | + pushd vllm |
| 152 | + # Looking back the latest 100 commits is enough |
| 153 | + for i in {0..99} |
| 154 | + do |
| 155 | + # Check if the image is there, if it doesn't then check an older one |
| 156 | + # because the commit is too recent |
| 157 | + HEAD_SHA=$(git rev-parse --verify HEAD~${i}) |
| 158 | + DOCKER_IMAGE="${DOCKER_IMAGE_PREFIX}:${HEAD_SHA}${DOCKER_IMAGE_SUFFIX}" |
| 159 | +
|
| 160 | + # No Docker image available yet because the commit is too recent |
| 161 | + if ! docker manifest inspect "${DOCKER_IMAGE}"; then |
| 162 | + continue |
| 163 | + fi |
| 164 | + done |
| 165 | + popd |
| 166 | + fi |
| 167 | +
|
| 168 | + echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV |
| 169 | +
|
| 170 | + # Print the profiling commit for rereference |
| 171 | + echo "### Run profiling on [${HEAD_SHA}](https://github.com/vllm-project/vllm/commit/${HEAD_SHA})" >> "${GITHUB_STEP_SUMMARY}" |
| 172 | +
|
| 173 | + - name: Setup CUDA GPU_FLAG for docker run |
| 174 | + if: env.DEVICE_NAME == 'cuda' |
| 175 | + run: | |
| 176 | + echo "GPU_FLAG=--gpus all -e NVIDIA_DRIVER_CAPABILITIES=all" >> "${GITHUB_ENV}" |
| 177 | +
|
| 178 | + - name: Setup ROCm |
| 179 | + if: env.DEVICE_NAME == 'rocm' |
| 180 | + uses: pytorch/pytorch/./.github/actions/setup-rocm@main |
| 181 | + |
| 182 | + - name: Setup SCCACHE_SERVER_PORT environment for docker run when on container |
| 183 | + run: | |
| 184 | + echo "SCCACHE_SERVER_PORT_DOCKER_FLAG=-e SCCACHE_SERVER_PORT=$((RUNNER_UID + 4226))" >> "${GITHUB_ENV}" |
| 185 | +
|
| 186 | + - name: Run vLLM profiling |
| 187 | + env: |
| 188 | + SCCACHE_BUCKET: ossci-compiler-cache-circleci-v2 |
| 189 | + SCCACHE_REGION: us-east-1 |
| 190 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} |
| 191 | + DOCKER_IMAGE: ${{ env.DOCKER_IMAGE_PREFIX }}:${{ env.HEAD_SHA }}${{ env.DOCKER_IMAGE_SUFFIX }} |
| 192 | + # vLLM-related environment variables |
| 193 | + VLLM_USE_MODELSCOPE: false |
| 194 | + VLLM_TORCH_PROFILER_DIR: ~/tmp/workspace/vllm_profile |
| 195 | + CUDA_VISIBLE_DEVICES: 0 |
| 196 | + VLLM_USE_V1: 1 |
| 197 | + # Profiling parameters |
| 198 | + MODEL_NAME: ${{ inputs.models || 'facebook/opt-125m' }} |
| 199 | + SERVED_MODEL_NAME: ${{ inputs.models || 'facebook/opt-125m' }} |
| 200 | + RANDOM_INPUT_LEN: 750 |
| 201 | + RANDOM_OUTPUT_LEN: 75 |
| 202 | + PORT: 8000 |
| 203 | + NUM_PROMPTS: 100 |
| 204 | + DATASET_NAME: random |
| 205 | + |
| 206 | + run: | |
| 207 | + set -eux |
| 208 | +
|
| 209 | + if [[ "${DEVICE_NAME}" == "cpu" ]]; then |
| 210 | + ON_CPU=1 |
| 211 | + else |
| 212 | + ON_CPU=0 |
| 213 | + fi |
| 214 | +
|
| 215 | + container_name=$(docker run \ |
| 216 | + ${GPU_FLAG:-} \ |
| 217 | + ${SCCACHE_SERVER_PORT_DOCKER_FLAG:-} \ |
| 218 | + -e SCCACHE_BUCKET \ |
| 219 | + -e SCCACHE_REGION \ |
| 220 | + -e DEVICE_NAME \ |
| 221 | + -e DEVICE_TYPE \ |
| 222 | + -e HF_TOKEN \ |
| 223 | + -e VLLM_USE_MODELSCOPE \ |
| 224 | + -e VLLM_TORCH_PROFILER_DIR \ |
| 225 | + -e CUDA_VISIBLE_DEVICES \ |
| 226 | + -e VLLM_USE_V1 \ |
| 227 | + -e MODEL_NAME \ |
| 228 | + -e SERVED_MODEL_NAME \ |
| 229 | + -e RANDOM_INPUT_LEN \ |
| 230 | + -e RANDOM_OUTPUT_LEN \ |
| 231 | + -e PORT \ |
| 232 | + -e NUM_PROMPTS \ |
| 233 | + -e DATASET_NAME \ |
| 234 | + -e ON_CPU="${ON_CPU}" \ |
| 235 | + --ipc=host \ |
| 236 | + --tty \ |
| 237 | + --detach \ |
| 238 | + --security-opt seccomp=unconfined \ |
| 239 | + --shm-size=4g \ |
| 240 | + -v "${GITHUB_WORKSPACE}:/tmp/workspace" \ |
| 241 | + -w /tmp/workspace \ |
| 242 | + "${DOCKER_IMAGE}" |
| 243 | + ) |
| 244 | + docker exec -t "${container_name}" bash -c "bash .github/scripts/run_vllm_profiling.sh" |
| 245 | +
|
| 246 | + # Keep a copy of the profiling results on GitHub for reference |
| 247 | + - uses: actions/upload-artifact@v4 |
| 248 | + with: |
| 249 | + name: profiling-results--${{ env.DEVICE_TYPE }} |
| 250 | + path: vllm/profiling-results |
0 commit comments