-
Notifications
You must be signed in to change notification settings - Fork 917
237 lines (203 loc) · 7.71 KB
/
gha_workflow_llama_models_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: "Run Llama-models Tests"
on:
pull_request_target:
types: ["opened"]
branches:
- 'main'
paths:
- 'models/**/*.py'
workflow_dispatch:
inputs:
runner:
description: 'GHA Runner Scale Set label to run workflow on.'
required: true
default: "llama-models-gha-runner-gpu"
branch:
description: "Branch to checkout"
required: true
default: "main"
debug:
description: 'Run debugging steps?'
required: false
default: "true"
sleep_time:
description: '[DEBUG] sleep time for debugging'
required: true
default: "0"
require_model:
description: 'Is a model required?'
required: true
default: "true"
model_vision:
description: 'Llama vision model ID'
required: false
default: "Llama3.2-11B-Vision-Instruct"
model_text:
description: 'Llama text model ID'
required: false
default: "Llama3.2-3B-Instruct"
api_key:
description: 'Provider API key'
required: true
default: "---"
env:
TOKENIZER_PATH: "models/llama3/api/tokenizer.model"
MODELS_PATH: "/data/llama3.2"
VISION_MODEL_CHECKPOINT_DIR: "/data/llama3.2/${{ inputs.model_vision }}"
TEXT_MODEL_CHECKPOINT_DIR: "/data/llama3.2/${{ inputs.model_text }}"
API_KEY: "${{ inputs.api_key }}"
jobs:
execute_workflow:
name: Execute workload on Self-Hosted CPU k8s runner
defaults:
run:
shell: bash # default shell to run all steps for a given job.
runs-on: ${{ inputs.runner != '' && inputs.runner || 'llama-models-gha-runner-cpu' }}
if: always()
steps:
##############################
#### INITIAL DEBUG CHECKS ####
##############################
- name: "[DEBUG] Check content of the EFS mount"
id: debug_efs_volume
continue-on-error: true
if: inputs.debug == 'true'
run: |
echo "========= Content of the EFS mount ============="
ls -la ${{ env.MODELS_PATH }}
- name: "Check if models exist in EFS volume"
id: check_if_models_exist
if: ${{ inputs.require_model == 'true' }}
run: |
# Check if vision model is provided and exists
if [ -n "${{ inputs.model_vision }}" ]; then
if [ ! -d "${{ env.VISION_MODEL_CHECKPOINT_DIR }}" ]; then
echo "Model '${{ inputs.model_vision }}' does not exist in mounted EFS volume, Terminating workflow."
exit 1
else
echo "Content of '${{ inputs.model_vision }}' model"
ls -la "${{ env.VISION_MODEL_CHECKPOINT_DIR }}"
fi
fi
# Check if text model is provided and exists
if [ -n "${{ inputs.model_text }}" ]; then
if [ ! -d "${{ env.TEXT_MODEL_CHECKPOINT_DIR }}" ]; then
echo "Model '${{ inputs.model_text }}' does not exist in mounted EFS volume, Terminating workflow."
exit 1
else
echo "Content of '${{ inputs.model_text }}' model"
ls -la "${{ env.TEXT_MODEL_CHECKPOINT_DIR }}"
fi
fi
- name: "[DEBUG] Get runner container OS information"
id: debug_os_info
if: ${{ inputs.debug == 'true' }}
run: |
cat /etc/os-release
#######################
#### CODE CHECKOUT ####
#######################
- name: "Checkout 'meta-llama/llama-models' repository"
id: checkout_repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: "[DEBUG] Content of the repository after checkout"
id: debug_content_after_checkout
if: ${{ inputs.debug == 'true' }}
run: |
ls -la ${GITHUB_WORKSPACE}
##########################################################
#### OPTIONAL SLEEP DEBUG ####
# #
# Use to "exec" into the test k8s POD and run tests #
# manually to identify what dependencies are being used. #
# #
##########################################################
- name: "[DEBUG] sleep"
id: debug_sleep
if: ${{ inputs.debug == 'true' && inputs.sleep_time != '' }}
run: |
sleep ${{ inputs.sleep_time }}
##################################
#### DEPENDENCY INSTALLATIONS ####
##################################
- name: "Installing 'apt' required packages"
id: install_apt
run: |
echo "[STEP] Installing 'apt' required packages"
sudo apt update -y
sudo apt upgrade -y
sudo apt install python3-pip -y
- name: "Installing 'llama-models' dependencies"
id: install_pip_generic
run: |
echo "[STEP] Installing 'llama-models' models"
pip install -U pip setuptools
pip install -r requirements.txt
pip install blobfile
pip install llama-models
pip install xmlrunner
pip install pytest
- name: "Installing specific manual_dispatch dependencies"
id: manual_install_pip
if: github.event_name == 'workflow_dispatch'
run: |
echo "[STEP] Installing specific dependencies for manual dispatch workflows"
pip install numpy
pip install torch
pip install fairscale
pip install termcolor
pip install torchvision
############################################
#### AUTOMATIC TESTING ON PULL REQUESTS ####
############################################
#### Run tests ####
- name: "PR - Run Tests"
id: pr_run_tests
working-directory: "${{ github.workspace }}"
if: github.event_name == 'pull_request_target'
run: |
echo "[STEP] Running PyTest tests at 'GITHUB_WORKSPACE' path: ${GITHUB_WORKSPACE} | path: ${{ github.workspace }}"
python3 -m pytest --ignore=models/llama3/tests/api/test_generation.py --junitxml="${{ github.workspace }}/result.xml"
#### Create test summary ####
- name: "PR - Test Summary"
id: pr_test_summary_create
if: github.event_name == 'pull_request_target'
uses: test-summary/action@v2
with:
paths: "${{ github.workspace }}/result.xml"
output: test-summary.md
- name: "PR - Upload Test Summary"
id: pr_test_summary_upload
if: github.event_name == 'pull_request_target'
uses: actions/upload-artifact@v3
with:
name: test-summary
path: test-summary.md
#### Update PR request ####
- name: "PR - Update comment"
id: pr_update_comment
if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v2
with:
filePath: test-summary.md
########################
#### MANUAL TESTING ####
########################
#### Run tests ####
- name: "Manual - Run Tests"
id: manual_run_tests
working-directory: "${{ github.workspace }}"
if: github.event_name == 'workflow_dispatch'
run: |
echo "[STEP] Running PyTest tests at 'GITHUB_WORKSPACE' path: ${GITHUB_WORKSPACE} | path: ${{ github.workspace }}"
free -m
python3 -m pytest --junitxml="${{ github.workspace }}/result.xml"
#### Create test summary ####
- name: "Manual - Test Summary"
id: manual_test_summary
if: always() && github.event_name == 'workflow_dispatch'
uses: test-summary/action@v2
with:
paths: "${{ github.workspace }}/result.xml"