|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +name: Functional GPU (NVIDIA Tesla T4 x1) |
| 4 | + |
| 5 | +on: |
| 6 | + # run against every merge commit to 'main' and release branches |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - release-* |
| 11 | + # only run on PRs that touch certain regex paths |
| 12 | + pull_request_target: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + - release-* |
| 16 | + paths: |
| 17 | + # note this should match the merging criteria in 'mergify.yml' |
| 18 | + - "**.py" |
| 19 | + - "pyproject.toml" |
| 20 | + - "requirements**.txt" |
| 21 | + - 'tox.ini' |
| 22 | + - ".github/workflows/functional-gpu-nvidia-t4-x1.yml" # This workflow |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +env: |
| 29 | + LC_ALL: en_US.UTF-8 |
| 30 | + |
| 31 | +defaults: |
| 32 | + run: |
| 33 | + shell: bash |
| 34 | + |
| 35 | +permissions: |
| 36 | + contents: read |
| 37 | + |
| 38 | +jobs: |
| 39 | + start-small-ec2-runner: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + outputs: |
| 42 | + label: ${{ steps.start-ec2-runner.outputs.label }} |
| 43 | + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} |
| 44 | + steps: |
| 45 | + - name: Configure AWS credentials |
| 46 | + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 |
| 47 | + with: |
| 48 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 49 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 50 | + aws-region: ${{ vars.AWS_REGION }} |
| 51 | + |
| 52 | + - name: Start EC2 runner |
| 53 | + id: start-ec2-runner |
| 54 | + uses: machulav/ec2-github-runner@1827d6ca7544d7044ddbd2e9360564651b463da2 # v2.3.7 |
| 55 | + with: |
| 56 | + mode: start |
| 57 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 58 | + ec2-image-id: ${{ vars.AWS_EC2_AMI }} |
| 59 | + ec2-instance-type: g4dn.2xlarge |
| 60 | + subnet-id: subnet-02d230cffd9385bd4 |
| 61 | + security-group-id: sg-06300447c4a5fbef3 |
| 62 | + iam-role-name: instructlab-ci-runner |
| 63 | + aws-resource-tags: > |
| 64 | + [ |
| 65 | + {"Key": "Name", "Value": "instructlab-ci-github-small-runner"}, |
| 66 | + {"Key": "GitHubRepository", "Value": "${{ github.repository }}"}, |
| 67 | + {"Key": "GitHubRef", "Value": "${{ github.ref }}"}, |
| 68 | + {"Key": "GitHubPR", "Value": "${{ github.event.number }}"} |
| 69 | + ] |
| 70 | +
|
| 71 | + functional-gpu-small-test: |
| 72 | + needs: |
| 73 | + - start-small-ec2-runner |
| 74 | + runs-on: ${{ needs.start-small-ec2-runner.outputs.label }} |
| 75 | + |
| 76 | + # It is important that this job has no write permissions and has |
| 77 | + # no access to any secrets. This part is where we are running |
| 78 | + # untrusted code from PRs. |
| 79 | + permissions: {} |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Install Packages |
| 83 | + run: | |
| 84 | + cat /etc/os-release |
| 85 | + sudo dnf install -y gcc gcc-c++ make git python3.11 python3.11-devel |
| 86 | +
|
| 87 | + - name: Checkout instructlab/sdg |
| 88 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 89 | + with: |
| 90 | + # https://github.com/actions/checkout/issues/249 |
| 91 | + fetch-depth: 0 |
| 92 | + |
| 93 | + - name: Fetch and checkout PR |
| 94 | + if: github.event_name == 'pull_request_target' |
| 95 | + run: | |
| 96 | + git fetch origin pull/${{ github.event.pull_request.number }}/merge:pr-merge-${{ github.event.pull_request.number }} |
| 97 | + git checkout pr-merge-${{ github.event.pull_request.number }} |
| 98 | + git log -1 --format="%H %s" |
| 99 | +
|
| 100 | + - name: Install instructlab/sdg |
| 101 | + run: | |
| 102 | + export PATH="/home/ec2-user/.local/bin:/usr/local/cuda/bin:$PATH" |
| 103 | + python3.11 -m venv --upgrade-deps venv |
| 104 | + . venv/bin/activate |
| 105 | + nvidia-smi |
| 106 | + python3.11 -m pip install tox tox-gh>=1.2 |
| 107 | + python3.11 -m pip cache remove llama_cpp_python |
| 108 | +
|
| 109 | + CMAKE_ARGS="-DLLAMA_CUDA=on" python3.11 -m pip install -r requirements-dev.txt |
| 110 | +
|
| 111 | + - name: Check disk before tests |
| 112 | + run: | |
| 113 | + df -h |
| 114 | +
|
| 115 | + - name: Run functional gpu tests with tox |
| 116 | + run: | |
| 117 | + . venv/bin/activate |
| 118 | + tox -e py3-functional-gpu |
| 119 | +
|
| 120 | + - name: Check disk after tests |
| 121 | + run: | |
| 122 | + df -h |
| 123 | +
|
| 124 | + stop-small-ec2-runner: |
| 125 | + needs: |
| 126 | + - start-small-ec2-runner |
| 127 | + - functional-gpu-small-test |
| 128 | + runs-on: ubuntu-latest |
| 129 | + if: ${{ always() }} |
| 130 | + steps: |
| 131 | + - name: Configure AWS credentials |
| 132 | + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 |
| 133 | + with: |
| 134 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 135 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 136 | + aws-region: ${{ vars.AWS_REGION }} |
| 137 | + |
| 138 | + - name: Stop EC2 runner |
| 139 | + uses: machulav/ec2-github-runner@1827d6ca7544d7044ddbd2e9360564651b463da2 # v2.3.7 |
| 140 | + with: |
| 141 | + mode: stop |
| 142 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 143 | + label: ${{ needs.start-small-ec2-runner.outputs.label }} |
| 144 | + ec2-instance-id: ${{ needs.start-small-ec2-runner.outputs.ec2-instance-id }} |
| 145 | + |
| 146 | + functional-gpu-small-workflow-complete: |
| 147 | + # we don't want to block PRs on failed EC2 cleanup |
| 148 | + # so not requiring "stop-small-ec2-runner" as well |
| 149 | + needs: ["start-small-ec2-runner", "functional-gpu-small-test"] |
| 150 | + runs-on: ubuntu-latest |
| 151 | + steps: |
| 152 | + - name: Functional GPU Workflow Complete |
| 153 | + run: echo "Functional GPU Workflow Complete" |
0 commit comments