|
| 1 | +name: Unit tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + # Every day at 02:15 AM UTC |
| 7 | + - cron: "15 2 * * *" |
| 8 | + push: |
| 9 | + branches: [testing-ci] |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + |
| 17 | + build-cpu: |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + os: [ubuntu-22.04, windows-2025] |
| 21 | + arch: [x86_64] |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Setup MSVC |
| 27 | + if: startsWith(matrix.os, 'windows') |
| 28 | + uses: ilammy/[email protected] # to use cl |
| 29 | + |
| 30 | + - name: Build C++ |
| 31 | + run: bash .github/scripts/build-cpu.sh |
| 32 | + env: |
| 33 | + build_os: ${{ matrix.os }} |
| 34 | + build_arch: ${{ matrix.arch }} |
| 35 | + |
| 36 | + - name: Upload build artifact |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: lib_cpu_${{ matrix.os }}_${{ matrix.arch }} |
| 40 | + path: output/${{ matrix.os }}/${{ matrix.arch }}/* |
| 41 | + retention-days: 7 |
| 42 | + |
| 43 | + build-cuda: |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + cuda_version: ["11.8.0", "12.8.1"] |
| 47 | + os: [ubuntu-22.04, windows-2025] |
| 48 | + arch: [x86_64] |
| 49 | + runs-on: ${{ matrix.os }} |
| 50 | + |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Install CUDA Toolkit |
| 55 | + |
| 56 | + if: startsWith(matrix.os, 'windows') |
| 57 | + id: cuda-toolkit |
| 58 | + with: |
| 59 | + cuda: ${{ matrix.cuda_version }} |
| 60 | + method: "network" |
| 61 | + sub-packages: '["nvcc","cudart","cusparse","cublas","thrust","nvrtc_dev","cublas_dev","cusparse_dev"]' |
| 62 | + use-github-cache: false |
| 63 | + |
| 64 | + - name: Setup MSVC |
| 65 | + if: startsWith(matrix.os, 'windows') |
| 66 | + uses: ilammy/[email protected] # to use cl |
| 67 | + |
| 68 | + # We're running on T4 only for now, so we only target sm75. |
| 69 | + - name: Build C++ / CUDA |
| 70 | + run: bash .github/scripts/build-cuda.sh |
| 71 | + env: |
| 72 | + build_os: ${{ matrix.os }} |
| 73 | + build_arch: x86_64 |
| 74 | + cuda_version: ${{ matrix.cuda_version }} |
| 75 | + cuda_targets: "75" |
| 76 | + |
| 77 | + - name: Upload build artifact |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: lib_cuda_${{matrix.cuda_version}}_${{ matrix.os }}_${{ matrix.arch }} |
| 81 | + path: output/${{ matrix.os }}/${{ matrix.arch }}/* |
| 82 | + retention-days: 7 |
| 83 | + |
| 84 | + cpu-tests: |
| 85 | + needs: build-cpu |
| 86 | + strategy: |
| 87 | + fail-fast: false |
| 88 | + matrix: |
| 89 | + os: [ubuntu-22.04, windows-2025] |
| 90 | + arch: [x86_64] |
| 91 | + torch_version: ["2.7.0"] |
| 92 | + runs-on: ${{ matrix.os }} |
| 93 | + env: |
| 94 | + BNB_TEST_DEVICE: cpu |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + |
| 98 | + - name: Download build artifact |
| 99 | + uses: actions/download-artifact@v4 |
| 100 | + with: |
| 101 | + name: lib_cpu_${{ matrix.os }}_${{ matrix.arch }} |
| 102 | + path: bitsandbytes/ |
| 103 | + merge-multiple: true |
| 104 | + |
| 105 | + - name: Setup Python |
| 106 | + uses: actions/setup-python@v5 |
| 107 | + with: |
| 108 | + python-version: 3.9 |
| 109 | + |
| 110 | + - name: Install dependencies |
| 111 | + run: | |
| 112 | + pip install torch==${{ matrix.torch_version }} --index-url https://download.pytorch.org/whl/cpu |
| 113 | + pip install -e ".[test]" |
| 114 | + pip install pytest-cov |
| 115 | +
|
| 116 | + - name: Show installed packages |
| 117 | + run: pip list |
| 118 | + |
| 119 | + - name: Run tests |
| 120 | + run: pytest |
| 121 | + |
| 122 | + cuda-tests: |
| 123 | + needs: build-cuda |
| 124 | + strategy: |
| 125 | + fail-fast: false |
| 126 | + matrix: |
| 127 | + os: [ubuntu-22.04, windows-2025] |
| 128 | + arch: [x86_64] |
| 129 | + cuda_version: ["11.8.0", "12.8.1"] |
| 130 | + include: |
| 131 | + - cuda_version: "11.8.0" |
| 132 | + torch_version: "2.4.1" |
| 133 | + pypi_index: "https://download.pytorch.org/whl/cu118" |
| 134 | + - cuda_version: "12.8.1" |
| 135 | + torch_version: "2.7.0" |
| 136 | + pypi_index: "https://download.pytorch.org/whl/cu128" |
| 137 | + exclude: |
| 138 | + # Our current T4 Windows runner has a driver too old (471.11) |
| 139 | + # and cannot support CUDA 12+. Skip for now. |
| 140 | + - os: windows-2025 |
| 141 | + cuda_version: "12.8.1" |
| 142 | + runs-on: |
| 143 | + labels: ${{ contains(matrix.os, 'windows') && 'CUDA-Windows-x64' || 'CUDA-Linux-x64' }} |
| 144 | + env: |
| 145 | + BNB_TEST_DEVICE: cuda |
| 146 | + steps: |
| 147 | + - name: Show GPU Information |
| 148 | + run: nvidia-smi |
| 149 | + |
| 150 | + - uses: actions/checkout@v4 |
| 151 | + |
| 152 | + - name: Download build artifact |
| 153 | + uses: actions/download-artifact@v4 |
| 154 | + with: |
| 155 | + name: lib_cuda_${{ matrix.cuda_version }}_${{ matrix.os }}_${{ matrix.arch }} |
| 156 | + path: bitsandbytes/ |
| 157 | + merge-multiple: true |
| 158 | + |
| 159 | + - name: Setup Python |
| 160 | + uses: actions/setup-python@v5 |
| 161 | + with: |
| 162 | + python-version: 3.9 |
| 163 | + |
| 164 | + - name: Install dependencies |
| 165 | + run: | |
| 166 | + pip install torch==${{ matrix.torch_version }} --index-url ${{ matrix.pypi_index }} |
| 167 | + pip install -e ".[test]" |
| 168 | + pip install pytest-cov |
| 169 | +
|
| 170 | + - name: Show installed packages |
| 171 | + run: pip list |
| 172 | + |
| 173 | + - name: Run tests |
| 174 | + run: pytest |
0 commit comments