|
| 1 | +# Compile and test fhevm-backend on a single L40 GPU, on hyperstack |
| 2 | +name: GPU backend tests (L40) |
| 3 | + |
| 4 | +env: |
| 5 | + CARGO_TERM_COLOR: always |
| 6 | + ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 7 | + RUSTFLAGS: "-C target-cpu=native" |
| 8 | + RUST_BACKTRACE: "full" |
| 9 | + RUST_MIN_STACK: "8388608" |
| 10 | + IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }} |
| 11 | + CHECKOUT_TOKEN: ${{ secrets.REPO_CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} |
| 12 | + # Secrets will be available only to zama-ai organization members |
| 13 | + SECRETS_AVAILABLE: ${{ secrets.JOB_SECRET != '' }} |
| 14 | + |
| 15 | +on: |
| 16 | + # Allows you to run this workflow manually from the Actions tab as an alternative. |
| 17 | + workflow_dispatch: |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - fhevm-engine/Cargo.toml |
| 21 | + - fhevm-engine/coprocessor/Cargo.toml |
| 22 | + - fhevm-engine/coprocessor/build.rs |
| 23 | + - fhevm-engine/coprocessor/src/** |
| 24 | + - fhevm-engine/executor/Cargo.toml |
| 25 | + - fhevm-engine/executor/build.rs |
| 26 | + - fhevm-engine/executor/src/** |
| 27 | + - fhevm-engine/scheduler/src/** |
| 28 | + - fhevm-engine/scheduler/Cargo.toml |
| 29 | + - fhevm-engine/scheduler/build.rs |
| 30 | + - proto/** |
| 31 | + - '.github/workflows/gpu-tests.yml' |
| 32 | + - ci/slab.toml |
| 33 | + push: |
| 34 | + branches: |
| 35 | + - main |
| 36 | + paths: |
| 37 | + - fhevm-engine/Cargo.toml |
| 38 | + - fhevm-engine/coprocessor/Cargo.toml |
| 39 | + - fhevm-engine/coprocessor/build.rs |
| 40 | + - fhevm-engine/coprocessor/src/** |
| 41 | + - fhevm-engine/executor/Cargo.toml |
| 42 | + - fhevm-engine/executor/build.rs |
| 43 | + - fhevm-engine/executor/src/** |
| 44 | + - fhevm-engine/scheduler/src/** |
| 45 | + - fhevm-engine/scheduler/Cargo.toml |
| 46 | + - fhevm-engine/scheduler/build.rs |
| 47 | + - proto/** |
| 48 | + - '.github/workflows/gpu-tests.yml' |
| 49 | + - ci/slab.toml |
| 50 | + |
| 51 | +jobs: |
| 52 | + should-run: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + permissions: |
| 55 | + pull-requests: read |
| 56 | + outputs: |
| 57 | + gpu_test: ${{ env.IS_PULL_REQUEST == 'false' || steps.changed-files.outputs.gpu_any_changed }} |
| 58 | + steps: |
| 59 | + - name: Checkout fhevm-backend |
| 60 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + persist-credentials: 'false' |
| 64 | + token: ${{ env.CHECKOUT_TOKEN }} |
| 65 | + |
| 66 | + - name: Check for file changes |
| 67 | + id: changed-files |
| 68 | + uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 |
| 69 | + with: |
| 70 | + files_yaml: | |
| 71 | + gpu: |
| 72 | + - fhevm-engine/Cargo.toml |
| 73 | + - fhevm-engine/coprocessor/Cargo.toml |
| 74 | + - fhevm-engine/coprocessor/build.rs |
| 75 | + - fhevm-engine/coprocessor/src/** |
| 76 | + - fhevm-engine/executor/Cargo.toml |
| 77 | + - fhevm-engine/executor/build.rs |
| 78 | + - fhevm-engine/executor/src/** |
| 79 | + - fhevm-engine/scheduler/src/** |
| 80 | + - fhevm-engine/scheduler/Cargo.toml |
| 81 | + - fhevm-engine/scheduler/build.rs |
| 82 | + - proto/** |
| 83 | + - '.github/workflows/gpu-tests.yml' |
| 84 | + - ci/slab.toml |
| 85 | +
|
| 86 | + setup-instance: |
| 87 | + name: Setup instance (fhevm-backend GPU tests - L40) |
| 88 | + needs: should-run |
| 89 | + if: github.event_name == 'workflow_dispatch' || |
| 90 | + needs.should-run.outputs.gpu_test == 'true' |
| 91 | + runs-on: ubuntu-latest |
| 92 | + permissions: |
| 93 | + contents: read |
| 94 | + outputs: |
| 95 | + runner-name: ${{ steps.start-remote-instance.outputs.label }} |
| 96 | + steps: |
| 97 | + - name: Start remote instance |
| 98 | + id: start-remote-instance |
| 99 | + if: env.SECRETS_AVAILABLE == 'true' |
| 100 | + uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac |
| 101 | + with: |
| 102 | + mode: start |
| 103 | + github-token: ${{ secrets.SLAB_ACTION_TOKEN }} |
| 104 | + slab-url: ${{ secrets.SLAB_BASE_URL }} |
| 105 | + job-secret: ${{ secrets.JOB_SECRET }} |
| 106 | + backend: hyperstack |
| 107 | + profile: l40 |
| 108 | + |
| 109 | + fhevm-backend-gpu: |
| 110 | + name: fhevm-backend GPU tests - L40 |
| 111 | + needs: [ should-run, setup-instance ] |
| 112 | + if: github.event_name != 'pull_request' || |
| 113 | + (github.event_name == 'pull_request' && needs.setup-instance.result != 'skipped') |
| 114 | + concurrency: |
| 115 | + group: ${{ github.workflow }}_${{ github.head_ref || github.ref }} |
| 116 | + cancel-in-progress: true |
| 117 | + runs-on: ${{ needs.setup-instance.outputs.runner-name }} |
| 118 | + permissions: |
| 119 | + contents: read |
| 120 | + strategy: |
| 121 | + fail-fast: false |
| 122 | + # explicit include-based build matrix, of known valid options |
| 123 | + matrix: |
| 124 | + include: |
| 125 | + - os: ubuntu-22.04 |
| 126 | + cuda: "12.2" |
| 127 | + gcc: 11 |
| 128 | + steps: |
| 129 | + - name: Checkout fhevm-backend |
| 130 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 131 | + with: |
| 132 | + persist-credentials: 'false' |
| 133 | + token: ${{ env.CHECKOUT_TOKEN }} |
| 134 | + lfs: true |
| 135 | + |
| 136 | + - name: Checkout LFS objects |
| 137 | + run: git lfs checkout |
| 138 | + |
| 139 | + - name: Setup Hyperstack dependencies |
| 140 | + uses: ./.github/actions/gpu_setup |
| 141 | + with: |
| 142 | + cuda-version: ${{ matrix.cuda }} |
| 143 | + gcc-version: ${{ matrix.gcc }} |
| 144 | + github-instance: ${{ env.SECRETS_AVAILABLE == 'false' }} |
| 145 | + |
| 146 | + - name: Install latest stable |
| 147 | + uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 |
| 148 | + with: |
| 149 | + toolchain: stable |
| 150 | + |
| 151 | + - name: Install cargo dependencies |
| 152 | + run: | |
| 153 | + sudo apt-get install -y protobuf-compiler && \ |
| 154 | + cargo install sqlx-cli |
| 155 | +
|
| 156 | + - name: Install foundry |
| 157 | + uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c |
| 158 | + |
| 159 | + - name: Cache cargo |
| 160 | + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 161 | + with: |
| 162 | + path: | |
| 163 | + ~/.cargo/registry |
| 164 | + ~/.cargo/git |
| 165 | + target |
| 166 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 167 | + restore-keys: ${{ runner.os }}-cargo- |
| 168 | + |
| 169 | + - name: Init database |
| 170 | + run: make init_db |
| 171 | + working-directory: fhevm-engine/coprocessor |
| 172 | + |
| 173 | + - name: Run tests on GPU |
| 174 | + run: | |
| 175 | + date |
| 176 | + #DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor cargo test --release --features=gpu -- --test-threads=1 |
| 177 | + working-directory: fhevm-engine |
| 178 | + |
| 179 | + |
| 180 | + teardown-instance: |
| 181 | + name: Teardown instance (fhevm-backend-gpu L40 test) |
| 182 | + if: ${{ always() && needs.setup-instance.result == 'success' }} |
| 183 | + needs: [ setup-instance, fhevm-backend-gpu ] |
| 184 | + runs-on: ubuntu-latest |
| 185 | + permissions: |
| 186 | + contents: read |
| 187 | + steps: |
| 188 | + - name: Stop remote instance |
| 189 | + id: stop-instance |
| 190 | + if: env.SECRETS_AVAILABLE == 'true' |
| 191 | + uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac |
| 192 | + with: |
| 193 | + mode: stop |
| 194 | + github-token: ${{ secrets.SLAB_ACTION_TOKEN }} |
| 195 | + slab-url: ${{ secrets.SLAB_BASE_URL }} |
| 196 | + job-secret: ${{ secrets.JOB_SECRET }} |
| 197 | + label: ${{ needs.setup-instance.outputs.runner-name }} |
0 commit comments