Skip to content

Commit bfd737b

Browse files
feat: Port SGLang from v1 to v2 (#5484)
* Improve vLLM workflows (#5480) * combinr workflow for vllm Signed-off-by: sirutBuasai <[email protected]> * formatting Signed-off-by: sirutBuasai <[email protected]> * fix region Signed-off-by: sirutBuasai <[email protected]> * fix artifacts path Signed-off-by: sirutBuasai <[email protected]> * isntall dependencies Signed-off-by: sirutBuasai <[email protected]> * reverse order Signed-off-by: sirutBuasai <[email protected]> * add port Signed-off-by: sirutBuasai <[email protected]> * move scripts into their separate dir Signed-off-by: sirutBuasai <[email protected]> * change port Signed-off-by: sirutBuasai <[email protected]> * style: format pre-commit check Signed-off-by: sirutBuasai <[email protected]> * chore: run test choices Signed-off-by: sirutBuasai <[email protected]> * remove commitizen Signed-off-by: sirutBuasai <[email protected]> * use main branch Signed-off-by: sirutBuasai <[email protected]> * fix dir Signed-off-by: sirutBuasai <[email protected]> * run benchmark sglang Signed-off-by: sirutBuasai <[email protected]> * ac run container id instead Signed-off-by: sirutBuasai <[email protected]> * add port and host Signed-off-by: sirutBuasai <[email protected]> * use composite action Signed-off-by: sirutBuasai <[email protected]> * input secrets Signed-off-by: sirutBuasai <[email protected]> * use shell bash Signed-off-by: sirutBuasai <[email protected]> * remove interactive Signed-off-by: sirutBuasai <[email protected]> * logs tail 200 Signed-off-by: sirutBuasai <[email protected]> * add sleep Signed-off-by: sirutBuasai <[email protected]> * add cleanup Signed-off-by: sirutBuasai <[email protected]> * remove -it Signed-off-by: sirutBuasai <[email protected]> * fix names Signed-off-by: sirutBuasai <[email protected]> * use container cleanup action Signed-off-by: sirutBuasai <[email protected]> * remove unused step Signed-off-by: sirutBuasai <[email protected]> * try env.containerid Signed-off-by: sirutBuasai <[email protected]> * use env Signed-off-by: sirutBuasai <[email protected]> * add -it Signed-off-by: sirutBuasai <[email protected]> * full run Signed-off-by: sirutBuasai <[email protected]> * use output Signed-off-by: sirutBuasai <[email protected]> * use vars expose Signed-off-by: sirutBuasai <[email protected]> * use input Signed-off-by: sirutBuasai <[email protected]> * comment artifacts name Signed-off-by: sirutBuasai <[email protected]> * set output Signed-off-by: sirutBuasai <[email protected]> * echo Signed-off-by: sirutBuasai <[email protected]> * add outputs id Signed-off-by: sirutBuasai <[email protected]> * iamge uri output Signed-off-by: sirutBuasai <[email protected]> * test using hardcoded string Signed-off-by: sirutBuasai <[email protected]> * no echo Signed-off-by: sirutBuasai <[email protected]> * set my output Signed-off-by: sirutBuasai <[email protected]> * use image uri Signed-off-by: sirutBuasai <[email protected]> * use secret image uri file Signed-off-by: sirutBuasai <[email protected]> * fix inputs Signed-off-by: sirutBuasai <[email protected]> * correct docker pull Signed-off-by: sirutBuasai <[email protected]> * use non screte var Signed-off-by: sirutBuasai <[email protected]> * use steps image_uri Signed-off-by: sirutBuasai <[email protected]> * remove unused steps Signed-off-by: sirutBuasai <[email protected]> * change uri var name Signed-off-by: sirutBuasai <[email protected]> * change step name Signed-off-by: sirutBuasai <[email protected]> * run regression test Signed-off-by: sirutBuasai <[email protected]> * change container_pull to ecr_authenticate Signed-off-by: sirutBuasai <[email protected]> * remove }} Signed-off-by: sirutBuasai <[email protected]> * use 12xlarge fleet Signed-off-by: sirutBuasai <[email protected]> * use base sglang Signed-off-by: sirutBuasai <[email protected]> * revert dockerfile Signed-off-by: sirutBuasai <[email protected]> * run using g6e Signed-off-by: sirutBuasai <[email protected]> * remove unnecessary wait Signed-off-by: sirutBuasai <[email protected]> * rename tests Signed-off-by: sirutBuasai <[email protected]> * use matrix srt test Signed-off-by: sirutBuasai <[email protected]> * remove srt Signed-off-by: sirutBuasai <[email protected]> * add pytest requirements Signed-off-by: sirutBuasai <[email protected]> * add add conftest Signed-off-by: sirutBuasai <[email protected]> * test_utils Signed-off-by: sirutBuasai <[email protected]> * remove dup isort Signed-off-by: sirutBuasai <[email protected]> * run test exampels Signed-off-by: sirutBuasai <[email protected]> * fix runner name Signed-off-by: sirutBuasai <[email protected]> * force rich terminal Signed-off-by: sirutBuasai <[email protected]> * remove console width Signed-off-by: sirutBuasai <[email protected]> * disable rich tracebacks Signed-off-by: sirutBuasai <[email protected]> * add columns Signed-off-by: sirutBuasai <[email protected]> * fix intall Signed-off-by: sirutBuasai <[email protected]> * remove rich logger Signed-off-by: sirutBuasai <[email protected]> * remove rich logger Signed-off-by: sirutBuasai <[email protected]> * add sm endpoint Signed-off-by: sirutBuasai <[email protected]> * source and install dependencies Signed-off-by: sirutBuasai <[email protected]> * reduce sleep time Signed-off-by: sirutBuasai <[email protected]> * use serve cmd instead Signed-off-by: sirutBuasai <[email protected]> * activate venev Signed-off-by: sirutBuasai <[email protected]> * add pytest cache Signed-off-by: sirutBuasai <[email protected]> * enable debug Signed-off-by: sirutBuasai <[email protected]> * input image uri Signed-off-by: sirutBuasai <[email protected]> * use assert in test instead Signed-off-by: sirutBuasai <[email protected]> * remove f Signed-off-by: sirutBuasai <[email protected]> * show test output Signed-off-by: sirutBuasai <[email protected]> * use ack test direction Signed-off-by: sirutBuasai <[email protected]> * remove predictor Signed-off-by: sirutBuasai <[email protected]> * fix self error Signed-off-by: sirutBuasai <[email protected]> * fix input Signed-off-by: sirutBuasai <[email protected]> * remove model_id yield Signed-off-by: sirutBuasai <[email protected]> * fix get endpoint status Signed-off-by: sirutBuasai <[email protected]> * add predictory class Signed-off-by: sirutBuasai <[email protected]> * change predictor Signed-off-by: sirutBuasai <[email protected]> * format tests Signed-off-by: sirutBuasai <[email protected]> * change pytest cmd Signed-off-by: sirutBuasai <[email protected]> * move aws_session to global conftest Signed-off-by: sirutBuasai <[email protected]> * move aws_session to global conftest Signed-off-by: sirutBuasai <[email protected]> * fix comments Signed-off-by: sirutBuasai <[email protected]> * fix comments Signed-off-by: sirutBuasai <[email protected]> * remove force color from pytest workflow and move to global Signed-off-by: sirutBuasai <[email protected]> * rename workflow Signed-off-by: sirutBuasai <[email protected]> * test remove paths Signed-off-by: sirutBuasai <[email protected]> * add runner setup script Signed-off-by: sirutBuasai <[email protected]> * uv venv project name Signed-off-by: sirutBuasai <[email protected]> * use json serializers Signed-off-by: sirutBuasai <[email protected]> * sagemaker requirements Signed-off-by: sirutBuasai <[email protected]> * change conccurency name Signed-off-by: sirutBuasai <[email protected]> * remove concurrency Signed-off-by: sirutBuasai <[email protected]> --------- Signed-off-by: sirutBuasai <[email protected]> Co-authored-by: Jinyan Li <[email protected]>
1 parent 1ef9189 commit bfd737b

File tree

16 files changed

+861
-82
lines changed

16 files changed

+861
-82
lines changed

.github/actions/pr-permission-gate/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ inputs:
44
required-level:
55
description: Minimum permission level required (read|triage|write|maintain|admin)
66
default: write
7+
78
runs:
8-
using: "composite"
9+
using: composite
910
steps:
1011
- name: Check PR sender permission
1112
uses: actions/github-script@v7

.github/workflows/pr-sglang.yml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: PR - SGLang
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- "**sglang**"
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: pr-sglang-${{ github.event.pull_request.number }}
15+
cancel-in-progress: true
16+
17+
env:
18+
SGLANG_VERSION: "0.5.5"
19+
PYTHON_VERSION: "py312"
20+
CUDA_VERSION: "cu129"
21+
OS_VERSION: "ubuntu22.04"
22+
FORCE_COLOR: "1"
23+
24+
jobs:
25+
check-changes:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
sglang-sagemaker: ${{ steps.changes.outputs.sglang-sagemaker }}
29+
steps:
30+
- uses: actions/checkout@v5
31+
- uses: actions/setup-python@v6
32+
with:
33+
python-version: "3.12"
34+
- uses: pre-commit/[email protected]
35+
with:
36+
extra_args: --all-files
37+
- name: Detect file changes
38+
id: changes
39+
uses: dorny/paths-filter@v3
40+
with:
41+
filters: |
42+
sglang-sagemaker:
43+
- "docker/sglang/Dockerfile"
44+
45+
build-sglang-image:
46+
needs: [check-changes]
47+
if: needs.check-changes.outputs.sglang-sagemaker == 'true'
48+
runs-on:
49+
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
50+
fleet:x86-build-runner
51+
outputs:
52+
image-uri: ${{ steps.image-uri-build.outputs.IMAGE_URI }}
53+
steps:
54+
- uses: actions/checkout@v5
55+
- run: .github/scripts/runner_setup.sh
56+
- run: .github/scripts/buildkitd.sh
57+
58+
- name: ECR login
59+
uses: ./.github/actions/ecr-authenticate
60+
with:
61+
aws_region: ${{ vars.AWS_REGION }}
62+
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
63+
64+
- name: Resolve image URI for build
65+
id: image-uri-build
66+
run: |
67+
IMAGE_URI=${{ vars.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 }}
68+
echo "Image URI to build: $IMAGE_URI"
69+
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV
70+
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_OUTPUT
71+
72+
- name: Build image
73+
run: |
74+
# base image: https://hub.docker.com/r/lmsysorg/sglang/tags
75+
docker buildx build --progress plain \
76+
--build-arg CACHE_REFRESH="$(date +"%Y-%m-%d")" \
77+
--build-arg BASE_IMAGE="lmsysorg/sglang:v${{ env.SGLANG_VERSION }}-${{ env.CUDA_VERSION }}-amd64" \
78+
--cache-to=type=inline \
79+
--cache-from=type=registry,ref=${IMAGE_URI} \
80+
--tag ${IMAGE_URI} \
81+
--target sglang-sagemaker \
82+
-f docker/sglang/Dockerfile .
83+
84+
- name: Container push
85+
run: |
86+
docker push ${IMAGE_URI}
87+
docker rmi ${IMAGE_URI}
88+
89+
sglang-local-benchmark-test:
90+
needs: [build-sglang-image]
91+
if: needs.build-sglang-image.result == 'success'
92+
runs-on:
93+
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
94+
fleet:x86-g6xl-runner
95+
steps:
96+
- name: Checkout DLC source
97+
uses: actions/checkout@v5
98+
99+
- name: Container pull
100+
uses: ./.github/actions/ecr-authenticate
101+
with:
102+
aws_region: ${{ vars.AWS_REGION }}
103+
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
104+
image_uri: ${{ needs.build-sglang-image.outputs.image-uri }}
105+
106+
- name: Setup for SGLang datasets
107+
run: |
108+
mkdir -p /tmp/sglang/dataset
109+
if [ ! -f /tmp/sglang/dataset/ShareGPT_V3_unfiltered_cleaned_split.json ]; then
110+
echo "Downloading ShareGPT dataset..."
111+
wget -P /tmp/sglang/dataset https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
112+
else
113+
echo "ShareGPT dataset already exists. Skipping download."
114+
fi
115+
116+
- name: Start container
117+
run: |
118+
CONTAINER_ID=$(docker run -d -it --rm --gpus=all \
119+
-v ${HOME}/.cache/huggingface:/root/.cache/huggingface \
120+
-v /tmp/sglang/dataset:/dataset \
121+
-p 30000:30000 \
122+
-e SM_SGLANG_MODEL_PATH=Qwen/Qwen3-0.6B \
123+
-e SM_SGLANG_REASONING_PARSER=qwen3 \
124+
-e SM_SGLANG_HOST=127.0.0.1 \
125+
-e SM_SGLANG_PORT=30000 \
126+
-e HF_TOKEN=${{ secrets.HUGGING_FACE_HUB_TOKEN }} \
127+
${{ needs.build-sglang-image.outputs.image-uri }})
128+
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV
129+
echo "Waiting for container startup ..."
130+
sleep 60s
131+
docker logs ${CONTAINER_ID}
132+
133+
- name: Run SGLang tests
134+
run: |
135+
docker exec ${CONTAINER_ID} python3 -m sglang.bench_serving \
136+
--backend sglang \
137+
--host 127.0.0.1 --port 30000 \
138+
--num-prompts 1000 \
139+
--model Qwen/Qwen3-0.6B \
140+
--dataset-name sharegpt \
141+
--dataset-path /dataset/ShareGPT_V3_unfiltered_cleaned_split.json
142+
143+
- name: Cleanup container and images
144+
if: always()
145+
uses: ./.github/actions/container-cleanup
146+
with:
147+
container_id: ${{ env.CONTAINER_ID }}
148+
149+
sglang-lang-test:
150+
needs: [build-sglang-image]
151+
if: needs.build-sglang-image.result == 'success'
152+
runs-on:
153+
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
154+
fleet:x86-g6exl-runner
155+
steps:
156+
- name: Checkout DLC source
157+
uses: actions/checkout@v5
158+
159+
- name: Container pull
160+
uses: ./.github/actions/ecr-authenticate
161+
with:
162+
aws_region: ${{ vars.AWS_REGION }}
163+
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
164+
image_uri: ${{ needs.build-sglang-image.outputs.image-uri }}
165+
166+
- name: Checkout SGLang tests
167+
uses: actions/checkout@v5
168+
with:
169+
repository: sgl-project/sglang
170+
ref: v${{ env.SGLANG_VERSION }}
171+
path: sglang_source
172+
173+
- name: Start container
174+
run: |
175+
CONTAINER_ID=$(docker run -d -it --rm --gpus=all --entrypoint /bin/bash \
176+
-v ${HOME}/.cache/huggingface:/root/.cache/huggingface \
177+
-v ./sglang_source:/workdir --workdir /workdir \
178+
-e HF_TOKEN=${{ secrets.HUGGING_FACE_HUB_TOKEN }} \
179+
${{ needs.build-sglang-image.outputs.image-uri }})
180+
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV
181+
182+
- name: Setup for SGLang tests
183+
run: |
184+
docker exec ${CONTAINER_ID} sh -c '
185+
set -eux
186+
187+
bash scripts/ci/ci_install_dependency.sh
188+
'
189+
190+
- name: Run SGLang tests
191+
run: |
192+
docker exec ${CONTAINER_ID} sh -c '
193+
set -eux
194+
nvidia-smi
195+
196+
# Frontend Test
197+
cd /workdir/test/lang
198+
python3 run_suite.py --suite per-commit
199+
'
200+
201+
- name: Cleanup container and images
202+
if: always()
203+
uses: ./.github/actions/container-cleanup
204+
with:
205+
container_id: ${{ env.CONTAINER_ID }}
206+
207+
sglang-sagemaker-endpoint-test:
208+
needs: [build-sglang-image]
209+
if: needs.build-sglang-image.result == 'success'
210+
runs-on:
211+
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
212+
fleet:default-runner
213+
steps:
214+
- name: Checkout DLC source
215+
uses: actions/checkout@v5
216+
217+
- run: .github/scripts/runner_setup.sh
218+
- name: Install test dependencies
219+
run: |
220+
uv venv
221+
source .venv/bin/activate
222+
223+
uv pip install -r test/requirements.txt
224+
uv pip install -r test/sglang/sagemaker/requirements.txt
225+
226+
- name: Run sagemaker tests
227+
run: |
228+
source .venv/bin/activate
229+
cd test/
230+
python3 -m pytest -vs -rA --image-uri ${{ needs.build-sglang-image.outputs.image-uri }} sglang/sagemaker

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ __pycache__
33
.idea
44
*.pyc
55
.venv
6-
.ruff_cache
6+
.ruff_cache
7+
.pytest_cache

0 commit comments

Comments
 (0)