colossalai

Форк
0
/
build_on_pr.yml 
204 строки · 7.1 Кб
1
name: Build on PR
2

3
on:
4
  pull_request:
5
    types: [synchronize, opened, reopened, ready_for_review, closed, edited]
6
    branches:
7
      - "main"
8
      - "develop"
9
      - "feature/**"
10
    paths:
11
      - ".github/workflows/build_on_pr.yml" # run command & env variables change
12
      - "colossalai/**" # source code change
13
      - "!colossalai/**.md" # ignore doc change
14
      - "op_builder/**" # cuda extension change
15
      - "!op_builder/**.md" # ignore doc change
16
      - "requirements/**" # requirements change
17
      - "tests/**" # test change
18
      - "!tests/**.md" # ignore doc change
19
      - "pytest.ini" # test config change
20
      - "setup.py" # install command change
21
  create:
22
  delete:
23

24
jobs:
25
  detect:
26
    name: Detect file change
27
    if: |
28
      github.event_name == 'pull_request' &&
29
      (github.event.action == 'synchronize' || github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review') &&
30
      github.event.pull_request.draft == false &&
31
      github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI'
32
    outputs:
33
      changedExtenisonFiles: ${{ steps.find-extension-change.outputs.all_changed_files }}
34
      anyExtensionFileChanged: ${{ steps.find-extension-change.outputs.any_changed }}
35
      changedLibraryFiles: ${{ steps.find-lib-change.outputs.all_changed_files }}
36
      anyLibraryFileChanged: ${{ steps.find-lib-change.outputs.any_changed }}
37
    runs-on: ubuntu-latest
38
    concurrency:
39
      group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-detect-change
40
      cancel-in-progress: true
41
    steps:
42
      - uses: actions/checkout@v2
43
        with:
44
          fetch-depth: 0
45
          ref: ${{ github.event.pull_request.head.sha }}
46

47
      - name: Locate base commit
48
        id: locate-base-sha
49
        run: |
50
          curBranch=$(git rev-parse --abbrev-ref HEAD)
51
          commonCommit=$(git merge-base origin/main $curBranch)
52
          echo $commonCommit
53
          echo "baseSHA=$commonCommit" >> $GITHUB_OUTPUT
54

55
      - name: Find the changed extension-related files
56
        id: find-extension-change
57
        uses: tj-actions/changed-files@v35
58
        with:
59
          base_sha: ${{ steps.locate-base-sha.outputs.baseSHA }}
60
          files: |
61
            op_builder/**
62
            colossalai/kernel/**
63
            setup.py
64

65
      - name: Find the changed library-related files
66
        id: find-lib-change
67
        uses: tj-actions/changed-files@v35
68
        with:
69
          base_sha: ${{ steps.locate-base-sha.outputs.baseSHA }}
70
          files: |
71
            **/*.py
72
            **/*.h
73
            **/*.cpp
74
            **/*.cu
75
            **/*.txt
76

77
      - name: List changed files
78
        run: |
79
          for file in ${{ steps.find-extension-change.outputs.all_changed_files }}; do
80
            echo "$file was changed"
81
          done
82
          for file in ${{ steps.find-lib-change.outputs.all_changed_files }}; do
83
            echo "$file was changed"
84
          done
85

86
  build:
87
    name: Build and Test Colossal-AI
88
    needs: detect
89
    if: needs.detect.outputs.anyLibraryFileChanged == 'true'
90
    runs-on: [self-hosted, gpu]
91
    container:
92
      image: hpcaitech/pytorch-cuda:2.1.0-12.1.0
93
      options: --gpus all --rm -v /dev/shm -v /data/scratch/llama-tiny:/data/scratch/llama-tiny
94
    timeout-minutes: 60
95
    defaults:
96
      run:
97
        shell: bash
98
    concurrency:
99
      group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-run-test
100
      cancel-in-progress: true
101
    steps:
102
      - name: Checkout TensorNVMe
103
        uses: actions/checkout@v2
104
        with:
105
          repository: hpcaitech/TensorNVMe
106
          ssh-key: ${{ secrets.SSH_KEY_FOR_CI }}
107
          path: TensorNVMe
108

109
      - name: Restore TensorNVMe Cache
110
        run: |
111
          if [ -d /github/home/tensornvme_cache ] && [ ! -z "$(ls -A /github/home/tensornvme_cache/)" ]; then
112
            cp -p -r /github/home/tensornvme_cache/* /__w/ColossalAI/ColossalAI/TensorNVMe
113
          fi
114

115
      - name: Install TensorNVMe
116
        run: |
117
          cd TensorNVMe
118
          conda install cmake
119
          pip install -r requirements.txt
120
          pip install -v .
121

122
      - name: Store TensorNVMe Cache
123
        run: |
124
          cd TensorNVMe
125
          cp -p -r ./build /github/home/tensornvme_cache/
126
          cp -p -r ./cmake-build /github/home/tensornvme_cache/
127

128
      - name: Checkout Colossal-AI
129
        uses: actions/checkout@v2
130
        with:
131
          ssh-key: ${{ secrets.SSH_KEY_FOR_CI }}
132

133
      - name: Restore Colossal-AI Cache
134
        if: needs.detect.outputs.anyExtensionFileChanged != 'true'
135
        run: |
136
          # -p flag is required to preserve the file timestamp to avoid ninja rebuild
137
          if [ -d /github/home/cuda_ext_cache ] && [ ! -z "$(ls -A /github/home/cuda_ext_cache/)" ]; then
138
            cp -p -r /github/home/cuda_ext_cache/* /__w/ColossalAI/ColossalAI/
139
          fi
140

141
      - name: Install Colossal-AI
142
        run: |
143
          BUILD_EXT=1 pip install -v -e .
144
          pip install -r requirements/requirements-test.txt
145

146
      - name: Store Colossal-AI Cache
147
        run: |
148
          # -p flag is required to preserve the file timestamp to avoid ninja rebuild
149
          cp -p -r /__w/ColossalAI/ColossalAI/build /github/home/cuda_ext_cache/
150

151
      - name: Execute Unit Testing
152
        run: |
153
          CURL_CA_BUNDLE="" PYTHONPATH=$PWD FAST_TEST=1 pytest \
154
          -m "not largedist" \
155
          --durations=0 \
156
          --ignore tests/test_analyzer \
157
          --ignore tests/test_auto_parallel \
158
          --ignore tests/test_fx \
159
          --ignore tests/test_autochunk \
160
          --ignore tests/test_gptq \
161
          --ignore tests/test_infer_ops \
162
          --ignore tests/test_legacy \
163
          --ignore tests/test_smoothquant \
164
          tests/
165
        env:
166
          LD_LIBRARY_PATH: /github/home/.tensornvme/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
167
          LLAMA_PATH: /data/scratch/llama-tiny
168

169
      - name: Collate artifact
170
        env:
171
          PR_NUMBER: ${{ github.event.number }}
172
          changedLibraryFiles: ${{ needs.detect.outputs.changedLibraryFiles }}
173
          anyLibraryFileChanged: ${{ needs.detect.outputs.anyLibraryFileChanged }}
174
          changedExtenisonFiles: ${{ needs.detect.outputs.changedExtenisonFiles }}
175
        run: |
176
          mkdir report
177
          echo $PR_NUMBER > ./report/pr_number
178

179
          # generate coverage.xml if any
180
          if [ "$anyLibraryFileChanged" == "true" ] && [ -e .coverage ]; then
181
            allFiles=""
182
            for file in $changedLibraryFiles; do
183
              if [ "$allFiles" == "" ]; then
184
                allFiles=$file
185
              else
186
                allFiles=$allFiles,$file
187
              fi
188
            done
189

190
            coverage report --data-file .coverage --include $allFiles > ./coverage.txt
191

192
            covPercentage=$(tail -n 1 coverage.txt  | grep -o '[1-9]*%$')
193
            covNum=${covPercentage::-1}
194
            mv coverage.txt ./report
195
            echo $covNum > ./report/cov_number
196
          else
197
            echo "No coverage report is generated"
198
          fi
199

200
      - name: Upload test coverage artifact
201
        uses: actions/upload-artifact@v3
202
        with:
203
          name: report
204
          path: report/

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.