"third_party/libxsmm/src/libxsmm_xcopy.c" did not exist on "3359c1f1af3d67082d590a17a1663169e5fe29b3"
README.md 2.21 KB
Newer Older
Lianmin Zheng's avatar
Lianmin Zheng committed
1
# SGLang Documentation
2
We recommend new contributors start from writing documentation, which helps you quickly understand SGLang codebase. Most documentation files are located under the `docs/` folder. We prefer **Jupyter Notebooks** over Markdown so that all examples can be executed and validated by our docs CI pipeline.
Lianmin Zheng's avatar
Lianmin Zheng committed
3

4
## Docs Workflow
Lianmin Zheng's avatar
Lianmin Zheng committed
5

6
7
8
### Install Dependency

```bash
Lianmin Zheng's avatar
Lianmin Zheng committed
9
10
11
pip install -r requirements.txt
```

12
13
14
15
16
17
18
19
20
21
22
23
### Update Documentation

Update your Jupyter notebooks in the appropriate subdirectories under `docs/`. If you add new files, remember to update `index.rst` (or relevant `.rst` files) accordingly.

- **`pre-commit run --all-files`** manually runs all configured checks, applying fixes if possible. If it fails the first time, re-run it to ensure lint errors are fully resolved. Make sure your code passes all checks **before** creating a Pull Request.
- **Do not commit** directly to the `main` branch. Always create a new branch (e.g., `feature/my-new-feature`), push your changes, and open a PR from that branch.

```bash
# 1) Compile all Jupyter notebooks
make compile

# 2) Generate static HTML
Lianmin Zheng's avatar
Lianmin Zheng committed
24
25
make html

26
27
28
# 3) Preview documentation locally
# Open your browser at the displayed port to view the docs
bash serve.sh
Lianmin Zheng's avatar
Lianmin Zheng committed
29

30
31
32
33
# 4) Clean notebook outputs
# nbstripout removes notebook outputs so your PR stays clean
pip install nbstripout
find . -name '*.ipynb' -exec nbstripout {} \;
34

35
36
37
# 5) Pre-commit checks and create a PR
# After these checks pass, push your changes and open a PR on your branch
pre-commit run --all-files
Lianmin Zheng's avatar
Lianmin Zheng committed
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


If you need to run and shut down a SGLang server or engine, following these examples:

1. Launch and close Sever:

```python
#Launch Sever

from sglang.utils import (
    execute_shell_command,
    wait_for_server,
    terminate_process,
    print_highlight,
)

server_process = execute_shell_command(
    "python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-8B-Instruct --port 30000 --host 0.0.0.0"
)

wait_for_server("http://localhost:30000")

# Terminate Sever

terminate_process(server_process)
Lianmin Zheng's avatar
Lianmin Zheng committed
64
```
65
2. Launch Engine and close Engine
Lianmin Zheng's avatar
Lianmin Zheng committed
66

67
68
```python
# Launch Engine
Lianmin Zheng's avatar
Lianmin Zheng committed
69

70
71
72
73
74
75
76
import sglang as sgl
import asyncio

llm = sgl.Engine(model_path="meta-llama/Meta-Llama-3.1-8B-Instruct")

# Terminalte Engine
llm.shutdown()
77
```