generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 532
342 lines (304 loc) · 12.3 KB
/
pr-sglang.yml
File metadata and controls
342 lines (304 loc) · 12.3 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: PR - SGLang
on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize]
paths:
- "**sglang**"
permissions:
contents: read
pull-requests: read
env:
# CI Image configuration
CONTAINER_TYPE: "general"
FRAMEWORK: "sglang"
SGLANG_VERSION: "0.5.5"
PYTHON_VERSION: "py312"
CUDA_VERSION: "cu129"
OS_VERSION: "ubuntu22.04"
# Prod Image configuration
PROD_SAGEMAKER_IMAGE: sglang:0.5-gpu-py312
# CI environment configuration
FORCE_COLOR: "1"
TEST_ARTIFACTS_DIRECTORY: "/test_artifacts/sglang"
jobs:
gatekeeper:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-gate-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout base branch (safe)
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 1
- name: Run permission gate (from base)
uses: ./.github/actions/pr-permission-gate
check-changes:
needs: [gatekeeper]
if: success()
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-check-changes-${{ github.event.pull_request.number }}
cancel-in-progress: true
outputs:
build-change: ${{ steps.changes.outputs.build-change }}
test-change: ${{ steps.changes.outputs.test-change }}
steps:
- name: Checkout DLC source
uses: actions/checkout@v5
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files
- name: Detect file changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
build-change:
- "docker/sglang/**"
- "scripts/sglang/**"
- "scripts/common/**"
- "scripts/telemetry/**"
- ".github/workflows/pr-sglang*"
test-change:
- "test/sglang/**"
# ======================================================
# =============== SGLang SageMaker jobs ================
# ======================================================
build-sglang-image:
needs: [check-changes]
if: needs.check-changes.outputs.build-change == 'true'
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
fleet:x86-build-runner
buildspec-override:true
concurrency:
group: ${{ github.workflow }}-build-sglang-image-${{ github.event.pull_request.number }}
cancel-in-progress: true
outputs:
ci-image: ${{ steps.image-uri-build.outputs.CI_IMAGE_URI }}
steps:
- uses: actions/checkout@v5
- run: .github/scripts/buildkitd.sh
- name: ECR login
uses: ./.github/actions/ecr-authenticate
with:
aws-account-id: ${{ vars.CI_AWS_ACCOUNT_ID }}
aws-region: ${{ vars.AWS_REGION }}
- name: Resolve image URI for build
id: image-uri-build
run: |
CI_IMAGE_URI=${{ vars.CI_AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/ci:sglang-${{ env.SGLANG_VERSION }}-gpu-${{ env.PYTHON_VERSION }}-${{ env.CUDA_VERSION }}-${{ env.OS_VERSION }}-sagemaker-pr-${{ github.event.pull_request.number }}
echo "Image URI to build: ${CI_IMAGE_URI}"
echo "CI_IMAGE_URI=${CI_IMAGE_URI}" >> ${GITHUB_ENV}
echo "CI_IMAGE_URI=${CI_IMAGE_URI}" >> ${GITHUB_OUTPUT}
- name: Build image
run: |
# base image: https://hub.docker.com/r/lmsysorg/sglang/tags
docker buildx build --progress plain \
--build-arg CACHE_REFRESH="$(date +"%Y-%m-%d")" \
--build-arg BASE_IMAGE="lmsysorg/sglang:v${{ env.SGLANG_VERSION }}-${{ env.CUDA_VERSION }}-amd64" \
--build-arg CONTAINER_TYPE="${{ env.CONTAINER_TYPE }}" \
--build-arg FRAMEWORK="${{ env.FRAMEWORK }}" \
--build-arg FRAMEWORK_VERSION="${{ env.SGLANG_VERSION }}" \
--cache-to=type=inline \
--cache-from=type=registry,ref=${CI_IMAGE_URI} \
--tag ${CI_IMAGE_URI} \
--target sglang-sagemaker \
-f docker/sglang/Dockerfile .
- name: Container push
run: |
docker push ${CI_IMAGE_URI}
docker rmi ${CI_IMAGE_URI}
set-test-environment:
needs: [check-changes, build-sglang-image]
if: |
always() && !failure() && !cancelled() &&
(needs.check-changes.outputs.build-change == 'true' || needs.check-changes.outputs.test-change == 'true')
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-set-test-environment-${{ github.event.pull_request.number }}
cancel-in-progress: true
outputs:
aws-account-id: ${{ steps.set-env.outputs.AWS_ACCOUNT_ID }}
image-uri: ${{ steps.set-env.outputs.IMAGE_URI }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set test environment
id: set-env
run: |
if [[ "${{ needs.build-sglang-image.result }}" == "success" ]]; then
AWS_ACCOUNT_ID=${{ vars.CI_AWS_ACCOUNT_ID }}
IMAGE_URI=${{ needs.build-sglang-image.outputs.ci-image }}
else
AWS_ACCOUNT_ID=${{ vars.PROD_AWS_ACCOUNT_ID }}
IMAGE_URI=${{ vars.PROD_AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/${{ env.PROD_SAGEMAKER_IMAGE }}
fi
echo "Image URI to test: ${IMAGE_URI}"
echo "AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID}" >> ${GITHUB_OUTPUT}
echo "IMAGE_URI=${IMAGE_URI}" >> ${GITHUB_OUTPUT}
sglang-telemetry-test:
needs: [set-test-environment, build-sglang-image]
if: success()
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
buildspec-override:true
concurrency:
group: ${{ github.workflow }}-sglang-telemetry-test-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout DLC source
uses: actions/checkout@v5
- name: Container pull
uses: ./.github/actions/ecr-authenticate
with:
aws-account-id: ${{ needs.set-test-environment.outputs.aws-account-id }}
aws-region: ${{ vars.AWS_REGION }}
image-uri: ${{ needs.set-test-environment.outputs.image-uri }}
- name: Start container
run: |
CONTAINER_ID=$(docker run -d -it --rm --entrypoint /bin/bash \
-e TEST_MODE=1 \
${{ needs.set-test-environment.outputs.image-uri }})
echo "CONTAINER_ID=${CONTAINER_ID}" >> ${GITHUB_ENV}
docker logs ${CONTAINER_ID}
- name: Run tests
run: |
curl http://169.254.169.254/latest/meta-data/instance-id
docker exec ${CONTAINER_ID} bash -c "export TEST_MODE=1 && python /usr/local/bin/deep_learning_container.py --framework sglang --framework-version "0.5.5" --container-type "general" && cat /tmp/test_request.txt"
docker exec ${CONTAINER_ID} bash -c "export TEST_MODE=1 && bash /usr/local/bin/bash_telemetry.sh && sleep 30 && cat /tmp/test_request.txt | grep "${{ env.FRAMEWORK }}""
sglang-local-benchmark-test:
needs: [set-test-environment, build-sglang-image]
if: success()
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
fleet:x86-g6xl-runner
buildspec-override:true
concurrency:
group: ${{ github.workflow }}-sglang-local-benchmark-test-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout DLC source
uses: actions/checkout@v5
- name: Container pull
uses: ./.github/actions/ecr-authenticate
with:
aws-account-id: ${{ needs.set-test-environment.outputs.aws-account-id }}
aws-region: ${{ vars.AWS_REGION }}
image-uri: ${{ needs.set-test-environment.outputs.image-uri }}
- name: Setup for SGLang datasets
run: |
mkdir -p ${TEST_ARTIFACTS_DIRECTORY}/dataset
if [ ! -f ${TEST_ARTIFACTS_DIRECTORY}/dataset/ShareGPT_V3_unfiltered_cleaned_split.json ]; then
echo "Downloading ShareGPT dataset..."
wget -P ${TEST_ARTIFACTS_DIRECTORY}/dataset https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
else
echo "ShareGPT dataset already exists. Skipping download."
fi
- name: Start container
run: |
CONTAINER_ID=$(docker run -d -it --rm --gpus=all \
-v ${HOME}/.cache/huggingface:/root/.cache/huggingface \
-v ${TEST_ARTIFACTS_DIRECTORY}/dataset:/dataset \
-p 30000:30000 \
-e SM_SGLANG_MODEL_PATH=Qwen/Qwen3-0.6B \
-e SM_SGLANG_REASONING_PARSER=qwen3 \
-e SM_SGLANG_HOST=127.0.0.1 \
-e SM_SGLANG_PORT=30000 \
-e HF_TOKEN=${{ secrets.HUGGING_FACE_HUB_TOKEN }} \
${{ needs.set-test-environment.outputs.image-uri }})
echo "CONTAINER_ID=${CONTAINER_ID}" >> ${GITHUB_ENV}
echo "Waiting for serving endpoint startup ..."
sleep 120s
docker logs ${CONTAINER_ID}
- name: Run SGLang tests
run: |
docker exec ${CONTAINER_ID} python3 -m sglang.bench_serving \
--backend sglang \
--host 127.0.0.1 --port 30000 \
--num-prompts 1000 \
--model Qwen/Qwen3-0.6B \
--dataset-name sharegpt \
--dataset-path /dataset/ShareGPT_V3_unfiltered_cleaned_split.json
sglang-frontend-test:
needs: [build-sglang-image, set-test-environment]
if: success()
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
fleet:x86-g6exl-runner
buildspec-override:true
concurrency:
group: ${{ github.workflow }}-sglang-frontend-test-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout DLC source
uses: actions/checkout@v5
- name: Container pull
uses: ./.github/actions/ecr-authenticate
with:
aws-account-id: ${{ needs.set-test-environment.outputs.aws-account-id }}
aws-region: ${{ vars.AWS_REGION }}
image-uri: ${{ needs.set-test-environment.outputs.image-uri }}
- name: Checkout SGLang tests
uses: actions/checkout@v5
with:
repository: sgl-project/sglang
ref: v${{ env.SGLANG_VERSION }}
path: sglang_source
- name: Start container
run: |
CONTAINER_ID=$(docker run -d -it --rm --gpus=all --entrypoint /bin/bash \
-v ${HOME}/.cache/huggingface:/root/.cache/huggingface \
-v ./sglang_source:/workdir --workdir /workdir \
-e HF_TOKEN=${{ secrets.HUGGING_FACE_HUB_TOKEN }} \
${{ needs.set-test-environment.outputs.image-uri }})
echo "CONTAINER_ID=${CONTAINER_ID}" >> ${GITHUB_ENV}
- name: Setup for SGLang tests
run: |
docker exec ${CONTAINER_ID} sh -c '
set -eux
bash scripts/ci/ci_install_dependency.sh
'
- name: Run SGLang tests
run: |
docker exec ${CONTAINER_ID} sh -c '
set -eux
nvidia-smi
# Frontend Test
cd /workdir/test/lang
python3 run_suite.py --suite per-commit
'
sglang-sagemaker-endpoint-test:
needs: [set-test-environment]
if: |
always() && !failure() && !cancelled() &&
needs.set-test-environment.result == 'success'
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
fleet:default-runner
buildspec-override:true
concurrency:
group: ${{ github.workflow }}-sglang-sagemaker-endpoint-test-${{ github.event.pull_request.number }}
cancel-in-progress: false
steps:
- name: Checkout DLC source
uses: actions/checkout@v5
- name: Install test dependencies
run: |
uv venv
source .venv/bin/activate
uv pip install -r test/requirements.txt
uv pip install -r test/sglang/sagemaker/requirements.txt
- name: Run sagemaker tests
run: |
source .venv/bin/activate
cd test/
python3 -m pytest -vs -rA --image-uri ${{ needs.set-test-environment.outputs.image-uri }} sglang/sagemaker