Skip to content

Commit d18baf6

Browse files
authored
update skypilot yaml and us uv instead of pip (sgl-project#279)
1 parent 4e59891 commit d18baf6

File tree

4 files changed

+27
-50
lines changed

4 files changed

+27
-50
lines changed

docs/basic_usage/qwen.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Qwen is Alibaba's family of large language models optimized for diverse applicat
77
Launch a Qwen-7B-Chat server on TPU:
88

99
```bash
10-
JAX_COMPILATION_CACHE_DIR=/tmp/jit_cache python3 -u -m sgl_jax.launch_server \
10+
JAX_COMPILATION_CACHE_DIR=/tmp/jit_cache uv run python -u -m sgl_jax.launch_server \
1111
--model-path Qwen/Qwen-7B-Chat \
1212
--trust-remote-code \
1313
--dist-init-addr=0.0.0.0:10011 \
@@ -56,7 +56,7 @@ Set `--mem-fraction-static 0.8` for optimal TPU memory utilization. For larger m
5656

5757
### Throughput Testing
5858
```bash
59-
python3 -m sgl_jax.bench_serving \
59+
uv run python -m sgl_jax.bench_serving \
6060
--backend sgl-jax \
6161
--dataset-name random \
6262
--num-prompts 100 \

docs/get_started/install.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ You can install SGLang-Jax using one of the methods below.
44

55
This page is mainly applicable to TPU devices running through JAX.
66

7-
## Method 1: With pip or uv
7+
## Method 1: With uv
88

9-
🚧 **Under Construction** 🚧
9+
```bash
10+
uv venv --python 3.12 && source .venv/bin/activate
11+
uv pip install sglang-jax
12+
```
1013

1114
## Method 2: From source
1215

@@ -16,11 +19,11 @@ git clone https://github.com/sgl-project/sglang-jax
1619
cd sglang-jax
1720

1821
# Install the python packages
19-
pip install --upgrade pip setuptools packaging
20-
pip install -e "python[all]"
22+
uv venv --python 3.12 && source .venv/bin/activate
23+
uv pip install -e python/
2124

2225
# Run Qwen-7B Model
23-
JAX_COMPILATION_CACHE_DIR=/tmp/jit_cache python3 -u -m sgl_jax.launch_server --model-path Qwen/Qwen-7B-Chat --trust-remote-code --dist-init-addr=0.0.0.0:10011 --nnodes=1 --tp-size=4 --device=tpu --random-seed=3 --node-rank=0 --mem-fraction-static=0.8 --max-prefill-tokens=8192 --download-dir=/tmp --dtype=bfloat16 --skip-server-warmup --host 0.0.0.0 --port 30000
26+
JAX_COMPILATION_CACHE_DIR=/tmp/jit_cache uv run python -u -m sgl_jax.launch_server --model-path Qwen/Qwen-7B-Chat --trust-remote-code --dist-init-addr=0.0.0.0:10011 --nnodes=1 --tp-size=4 --device=tpu --random-seed=3 --node-rank=0 --mem-fraction-static=0.8 --max-prefill-tokens=8192 --download-dir=/tmp --dtype=bfloat16 --skip-server-warmup --host 0.0.0.0 --port 30000
2427
```
2528

2629
## Method 3: Using docker
@@ -31,11 +34,7 @@ JAX_COMPILATION_CACHE_DIR=/tmp/jit_cache python3 -u -m sgl_jax.launch_server --m
3134

3235
🚧 **Under Construction** 🚧
3336

34-
## Method 5: Using docker compose
35-
36-
🚧 **Under Construction** 🚧
37-
38-
## Method 6: Run on Cloud TPU with SkyPilot
37+
## Method 5: Run on Cloud TPU with SkyPilot
3938

4039
<details>
4140
<summary>More</summary>
@@ -54,25 +53,19 @@ resources:
5453
accelerator_args:
5554
tpu_vm: True
5655
runtime_version: v2-alpha-tpuv6e
57-
file_mounts:
58-
~/.ssh/id_rsa: ~/.ssh/id_rsa
59-
setup: |
60-
chmod 600 ~/.ssh/id_rsa
61-
rm ~/.ssh/config
62-
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone https://github.com/sgl-project/sglang-jax
6356
run: |
64-
cd sglang-jax
65-
pip install -e "python[all]"
66-
JAX_COMPILATION_CACHE_DIR=/tmp/jit_cache python3 -u -m sgl_jax.launch_server --model-path Qwen/Qwen-7B-Chat --trust-remote-code --dist-init-addr=0.0.0.0:10011 --nnodes=1 --tp-size=4 --device=tpu --random-seed=3 --node-rank=0 --mem-fraction-static=0.8 --max-prefill-tokens=8192 --download-dir=/tmp --dtype=bfloat16 --skip-server-warmup --attention-backend=fa --host 0.0.0.0 --port 30000
57+
git clone https://github.com/sgl-project/sglang-jax.git
58+
cd sglang-jax && git fetch origin $REF:$REF && git checkout $REF
59+
uv venv --python 3.12
60+
source .venv/bin/activate
61+
uv pip install -e python/
6762
```
6863
6964
</details>
7065
7166
```bash
7267
sky launch -c sglang-jax sglang.yaml --infra=gcp
7368

74-
# Get the HTTP API endpoint
75-
sky status --endpoint 30000 sglang-jax
7669
```
7770
- For debugging and testing purposes, you can use spot instances to reduce costs by adding the `--use-spot` flag to your SkyPilot commands:
7871
```bash

scripts/launch_tpu.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,15 @@ sanitize_ref() {
3636
ref=$(echo "$ref" | sed 's/^[^a-zA-Z]*//')
3737
# Ensure it doesn't end with dash, dot or underscore
3838
ref=$(echo "$ref" | sed 's/[-._]*$//')
39-
# Truncate to reasonable length (max 40 chars to leave room for prefix/suffix)
40-
ref=$(echo "$ref" | cut -c1-40)
39+
# Truncate to reasonable length (max 20 chars to leave room for prefix/suffix)
40+
ref=$(echo "$ref" | cut -c1-20)
4141
# If empty after sanitization, use "default"
4242
if [ -z "$ref" ]; then
4343
ref="default"
4444
fi
4545
echo "$ref"
4646
}
4747

48-
# Check environment variables
49-
if [ -z "$USERNAME" ]; then
50-
echo "Error: USERNAME environment variable is not set"
51-
exit 1
52-
fi
53-
54-
if [ -z "$GIT_TOKEN" ]; then
55-
echo "Error: GIT_TOKEN environment variable is not set"
56-
exit 1
57-
fi
58-
5948
# Sanitize ref name
6049
SANITIZED_REF=$(sanitize_ref "$REF")
6150

@@ -73,9 +62,9 @@ sed -e "s|\$ACCELERATOR|${ACCELERATOR}|g" \
7362

7463
# Create cluster name with ref
7564
if [ -n "$TEST_TYPE" ]; then
76-
CLUSTER_NAME="sgl-jax-ci-$ACCELERATOR-$SANITIZED_REF-$TEST_TYPE"
65+
CLUSTER_NAME="sgl-jax-$ACCELERATOR-$SANITIZED_REF-$TEST_TYPE-$RANDOM"
7766
else
78-
CLUSTER_NAME="sgl-jax-ci-$ACCELERATOR-$SANITIZED_REF"
67+
CLUSTER_NAME="sgl-jax-$ACCELERATOR-$SANITIZED_REF-$RANDOM"
7968
fi
8069

8170
# Execute sky launch command
@@ -93,9 +82,7 @@ sky launch "$TEMP_YAML" \
9382
--infra=gcp \
9483
-i 10 \
9584
--down \
96-
-y \
97-
--secret USERNAME=${USERNAME} \
98-
--secret GIT_TOKEN=${GIT_TOKEN}
85+
-y
9986

10087
# Store the exit code
10188
EXIT_CODE=$?

scripts/tpu_resource.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
resources:
22
accelerators: $ACCELERATOR
3-
use_spot: True
4-
disk_size: 512 # Ensure model checkpoints can fit.
5-
disk_tier: best
6-
7-
secrets:
8-
USERNAME: null
9-
GIT_TOKEN: null
10-
3+
accelerator_args:
4+
tpu_vm: True
5+
runtime_version: v2-alpha-tpuv6e
6+
use_spot: True # The default instance is spot.
117

128
setup: |
139
if [ -d "sglang-jax" ]; then pip uninstall -y sgl-jax || true && rm -rf sglang-jax; fi
14-
git clone https://${USERNAME}:${GIT_TOKEN}@github.com/sgl-project/sglang-jax.git
10+
git clone https://github.com/sgl-project/sglang-jax.git
1511
cd sglang-jax && git fetch origin $REF:$REF && git checkout $REF
1612
uv venv --python 3.12
1713
source .venv/bin/activate
1814
uv pip install -e python/
1915
bash scripts/killall_sglang.sh
16+
uv tool install evalscope

0 commit comments

Comments
 (0)