Skip to content

Commit a5e0def

Browse files
authored
minor: Add basic editorconfig and pre-commit hooks to enforce style for whitespaces (sgl-project#1926)
1 parent 9676610 commit a5e0def

File tree

77 files changed

+209
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+209
-172
lines changed

.editorconfig

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# https://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_style = space
9+
indent_size = 4
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[*.{json,yaml,yml}]
14+
indent_size = 2
15+
16+
[*.md]
17+
indent_size = 2
18+
x-soft-wrap-text = true
19+
20+
[*.rst]
21+
indent_size = 4
22+
x-soft-wrap-text = true
23+
24+
[Makefile]
25+
indent_style = tab

.github/pull_request_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
- [ ] Format your code according to the [Contributor Guide](https://github.com/sgl-project/sglang/blob/main/docs/contributor_guide.md).
1414
- [ ] Add unit tests as outlined in the [Contributor Guide](https://github.com/sgl-project/sglang/blob/main/docs/contributor_guide.md).
15-
- [ ] Update documentation as needed, including docstrings or example tutorials.
15+
- [ ] Update documentation as needed, including docstrings or example tutorials.

.github/workflows/close-inactive-issues.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
github-token: ${{secrets.GITHUB_TOKEN}}
2121
script: |
2222
const sixtyDaysAgo = new Date(Date.now() - 60 * 24 * 60 * 60 * 1000);
23-
23+
2424
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
2525
console.log(`Owner: ${owner}, Repo: ${repo}`);
26-
26+
2727
async function fetchIssues(page = 1) {
2828
console.log(`Fetching issues for ${owner}/${repo}, page ${page}`);
2929
return await github.rest.issues.listForRepo({
@@ -36,23 +36,23 @@ jobs:
3636
page: page
3737
});
3838
}
39-
39+
4040
async function processIssues() {
4141
console.log('Starting to process issues');
4242
console.log(`Repository: ${owner}/${repo}`);
43-
43+
4444
let page = 1;
4545
let hasMoreIssues = true;
4646
while (hasMoreIssues) {
4747
try {
4848
const issues = await fetchIssues(page);
4949
console.log(`Fetched ${issues.data.length} issues on page ${page}`);
50-
50+
5151
if (issues.data.length === 0) {
5252
hasMoreIssues = false;
5353
break;
5454
}
55-
55+
5656
for (const issue of issues.data) {
5757
if (new Date(issue.updated_at) < sixtyDaysAgo) {
5858
try {
@@ -87,5 +87,5 @@ jobs:
8787
}
8888
console.log('Finished processing issues');
8989
}
90-
90+
9191
await processIssues();

.github/workflows/execute-notebook.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ concurrency:
1818
group: execute-notebook-${{ github.ref }}
1919
cancel-in-progress: true
2020

21-
21+
2222
jobs:
2323
run-all-notebooks:
2424
runs-on: 1-gpu-runner
@@ -45,4 +45,4 @@ jobs:
4545
run: |
4646
cd docs
4747
make clean
48-
make compile
48+
make compile

.github/workflows/pr-test-rust.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
run: |
3737
source "$HOME/.cargo/env"
3838
cd rust/
39-
cargo test
39+
cargo test

.github/workflows/pr-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ jobs:
237237
run: |
238238
cd test/srt
239239
python3 test_moe_eval_accuracy_large.py
240-
240+
241241
- name: Evaluate MLA Accuracy (TP=2)
242242
timeout-minutes: 10
243243
run: |

.github/workflows/release-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
4848
make html
4949
cd _build/html
50-
50+
5151
git clone https://[email protected]/sgl-project/sgl-project.github.io.git ../sgl-project.github.io --depth 1
5252
rm -rf ../sgl-project.github.io/*
5353
cp -r * ../sgl-project.github.io

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,4 @@ tmp*.txt
185185
work_dirs/
186186
*.csv
187187

188-
!logo.png
188+
!logo.png

.isort.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[settings]
22
profile=black
3-
known_first_party=sglang
3+
known_first_party=sglang

.pre-commit-config.yaml

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
default_language_version:
22
python: python3.9
33

4+
default_stages: [pre-commit, pre-push, manual]
5+
46
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: check-symlinks
11+
- id: destroyed-symlinks
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-yaml
15+
args: [--allow-multiple-documents]
16+
- id: check-toml
17+
- id: check-ast
18+
- id: check-added-large-files
19+
- id: check-merge-conflict
20+
- id: check-executables-have-shebangs
21+
- id: check-shebang-scripts-are-executable
22+
- id: detect-private-key
23+
- id: debug-statements
24+
- id: no-commit-to-branch
525
- repo: https://github.com/PyCQA/isort
626
rev: 5.13.2
727
hooks:
@@ -13,8 +33,3 @@ repos:
1333
additional_dependencies: ['.[jupyter]']
1434
types: [python, jupyter]
1535
types_or: [python, jupyter]
16-
17-
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v5.0.0
19-
hooks:
20-
- id: no-commit-to-branch

3rdparty/amd/profiling/PROFILING.md

-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ Two primary methods are covered:
66

77

88
- [Torch Profiler](https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html)
9-
10-

3rdparty/amd/tuning/TUNING.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ def _triton_kernel_funtion():
2929
...
3030
```
3131
## 2. Torch Tunable Operations
32-
**TunableOp** is a feature in PyTorch that allows for the definition and optimization of custom kernels with tunable parameters. This feature is particularly useful for enhancing the performance of kernels by experimenting with different configurations.
32+
**TunableOp** is a feature in PyTorch that allows for the definition and optimization of custom kernels with tunable parameters. This feature is particularly useful for enhancing the performance of kernels by experimenting with different configurations.
3333

3434
### Key Environment Variables:
35-
1. **PYTORCH_TUNABLEOP_ENABLED**:
35+
1. **PYTORCH_TUNABLEOP_ENABLED**:
3636
- Default: `0`
3737
- Set to `1` to enable TunableOp.
3838

39-
2. **PYTORCH_TUNABLEOP_TUNING**:
39+
2. **PYTORCH_TUNABLEOP_TUNING**:
4040
- Default: `1`
4141
- Set to `0` to disable tuning. If a tuned entry is not found, it will run the tuning step and record the entry when PYTORCH_TUNABLEOP_ENABLED is enabled.
4242

43-
3. **PYTORCH_TUNABLEOP_VERBOSE**:
43+
3. **PYTORCH_TUNABLEOP_VERBOSE**:
4444
- Default: `0`
4545
- Set to `1` to enable verbose output for TunableOp.
4646

@@ -66,20 +66,20 @@ The following are suggestions for optimizing matrix multiplication (GEMM) and co
6666
To tune Triton kernels with GEMM and convolution ops (conv), use the `torch.compile` function with the max-autotune mode. This benchmarks a predefined list of Triton configurations and selects the fastest one for each shape.
6767

6868
### Key Configurations:
69-
1. **Max Autotune**:
69+
1. **Max Autotune**:
7070
- Set `torch._inductor.config.max_autotune = True` or `TORCHINDUCTOR_MAX_AUTOTUNE=1`.
7171

7272
2. **Fine-Grained Control**:
7373
- Enable GEMM tuning: `torch._inductor.config.max_autotune_gemm = True`.
7474
- Enable tuning for pointwise/reduction ops: `torch._inductor.config.max_autotune.pointwise = True`.
7575

76-
3. **Backend Selection**:
76+
3. **Backend Selection**:
7777
- Use `torch._inductor.max_autotune_gemm_backends` to limit backends to TRITON for better performance.
7878

79-
4. **Freezing for Inference**:
79+
4. **Freezing for Inference**:
8080
- Use `torch._inductor.config.freezing=True` to enable constant folding optimizations.
8181

82-
5. **Debugging**:
82+
5. **Debugging**:
8383
- Set `TORCH_COMPILE_DEBUG=1` to extract Triton kernels generated by Inductor.
8484

8585
### Example Code Block:
@@ -98,4 +98,4 @@ TORCHINDUCTOR_FREEZING=1 your_script.sh
9898

9999
For more detailed information on tuning SGLang performance with AMD GPUs, please refer to the following link:
100100

101-
[ROCm Documentation: Triton Kernel Performance Optimization](https://rocm.docs.amd.com/en/latest/how-to/tuning-guides/mi300x/workload.html#triton-kernel-performance-optimization)
101+
[ROCm Documentation: Triton Kernel Performance Optimization](https://rocm.docs.amd.com/en/latest/how-to/tuning-guides/mi300x/workload.html#triton-kernel-performance-optimization)

benchmark/blog_v0_2/405b_sglang.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ python3 -m sglang.bench_serving --backend sglang --dataset-name random --num-pro
2121
python3 -m sglang.bench_serving --backend sglang --dataset-name random --num-prompt 600 --request-rate 2 --random-input 1024 --random-output 1024 > sglang_log32
2222
python3 -m sglang.bench_serving --backend sglang --dataset-name random --num-prompt 1200 --request-rate 4 --random-input 1024 --random-output 1024 > sglang_log33
2323
python3 -m sglang.bench_serving --backend sglang --dataset-name random --num-prompt 2400 --request-rate 8 --random-input 1024 --random-output 1024 > sglang_log34
24-
python3 -m sglang.bench_serving --backend sglang --dataset-name random --num-prompt 3200 --request-rate 16 --random-input 1024 --random-output 1024 > sglang_log35
24+
python3 -m sglang.bench_serving --backend sglang --dataset-name random --num-prompt 3200 --request-rate 16 --random-input 1024 --random-output 1024 > sglang_log35

benchmark/blog_v0_2/405b_vllm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ python3 ../../python/sglang/bench_serving.py --backend vllm --dataset-name rando
2121
python3 ../../python/sglang/bench_serving.py --backend vllm --dataset-name random --num-prompt 600 --request-rate 2 --random-input 1024 --random-output 1024 > vllm_log32
2222
python3 ../../python/sglang/bench_serving.py --backend vllm --dataset-name random --num-prompt 1200 --request-rate 4 --random-input 1024 --random-output 1024 > vllm_log33
2323
python3 ../../python/sglang/bench_serving.py --backend vllm --dataset-name random --num-prompt 2400 --request-rate 8 --random-input 1024 --random-output 1024 > vllm_log34
24-
python3 ../../python/sglang/bench_serving.py --backend vllm --dataset-name random --num-prompt 3200 --request-rate 16 --random-input 1024 --random-output 1024 > vllm_log35
24+
python3 ../../python/sglang/bench_serving.py --backend vllm --dataset-name random --num-prompt 3200 --request-rate 16 --random-input 1024 --random-output 1024 > vllm_log35

benchmark/generative_agents/agent_functions.py

+24-24
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ def poignancy_event_prompt(persona_name, persona_iss, event):
3030
@sgl.function
3131
def generate_event_triple(s, persona_name, action):
3232
s += """Task: Turn the input into (subject, predicate, object).
33-
Input: Sam Johnson is eating breakfast.
34-
Output: (Dolores Murphy, eat, breakfast)
35-
---
33+
Input: Sam Johnson is eating breakfast.
34+
Output: (Dolores Murphy, eat, breakfast)
35+
---
3636
Input: Joon Park is brewing coffee.
3737
Output: (Joon Park, brew, coffee)
3838
---
39-
Input: Jane Cook is sleeping.
39+
Input: Jane Cook is sleeping.
4040
Output: (Jane Cook, is, sleep)
4141
---
42-
Input: Michael Bernstein is writing email on a computer.
42+
Input: Michael Bernstein is writing email on a computer.
4343
Output: (Michael Bernstein, write, email)
4444
---
45-
Input: Percy Liang is teaching students in a classroom.
45+
Input: Percy Liang is teaching students in a classroom.
4646
Output: (Percy Liang, teach, students)
4747
---
48-
Input: Merrie Morris is running on a treadmill.
48+
Input: Merrie Morris is running on a treadmill.
4949
Output: (Merrie Morris, run, treadmill)
5050
---"""
5151
s += persona_name + "is" + action + ".\n"
@@ -56,22 +56,22 @@ def generate_event_triple(s, persona_name, action):
5656
def generate_event_triple_prompt(persona_name, action):
5757
s = ""
5858
s += """Task: Turn the input into (subject, predicate, object).
59-
Input: Sam Johnson is eating breakfast.
60-
Output: (Dolores Murphy, eat, breakfast)
61-
---
59+
Input: Sam Johnson is eating breakfast.
60+
Output: (Dolores Murphy, eat, breakfast)
61+
---
6262
Input: Joon Park is brewing coffee.
6363
Output: (Joon Park, brew, coffee)
6464
---
65-
Input: Jane Cook is sleeping.
65+
Input: Jane Cook is sleeping.
6666
Output: (Jane Cook, is, sleep)
6767
---
68-
Input: Michael Bernstein is writing email on a computer.
68+
Input: Michael Bernstein is writing email on a computer.
6969
Output: (Michael Bernstein, write, email)
7070
---
71-
Input: Percy Liang is teaching students in a classroom.
71+
Input: Percy Liang is teaching students in a classroom.
7272
Output: (Percy Liang, teach, students)
7373
---
74-
Input: Merrie Morris is running on a treadmill.
74+
Input: Merrie Morris is running on a treadmill.
7575
Output: (Merrie Morris, run, treadmill)
7676
---"""
7777
s += persona_name + "is" + action + ".\n"
@@ -107,17 +107,17 @@ def action_location_sector(
107107
current_action,
108108
next_action,
109109
):
110-
s += """Task -- choose an appropriate area from the area options for a task at hand.
110+
s += """Task -- choose an appropriate area from the area options for a task at hand.
111111
Sam Kim lives in {Sam Kim's house} that has Sam Kim's room, bathroom, kitchen.
112-
Sam Kim is currently in {Sam Kim's house} that has Sam Kim's room, bathroom, kitchen.
112+
Sam Kim is currently in {Sam Kim's house} that has Sam Kim's room, bathroom, kitchen.
113113
Area options: {Sam Kim's house, The Rose and Crown Pub, Hobbs Cafe, Oak Hill College, Johnson Park, Harvey Oak Supply Store, The Willows Market and Pharmacy}.
114114
* Stay in the current area if the activity can be done there. Only go out if the activity needs to take place in another place.
115115
* Must be one of the "Area options," verbatim.
116116
For taking a walk, Sam Kim should go to the following area: {Johnson Park}
117117
---
118118
Jane Anderson lives in {Oak Hill College Student Dormatory} that has Jane Anderson's room.
119119
Jane Anderson is currently in {Oak Hill College} that has a classroom, library
120-
Area options: {Oak Hill College Student Dormatory, The Rose and Crown Pub, Hobbs Cafe, Oak Hill College, Johnson Park, Harvey Oak Supply Store, The Willows Market and Pharmacy}.
120+
Area options: {Oak Hill College Student Dormatory, The Rose and Crown Pub, Hobbs Cafe, Oak Hill College, Johnson Park, Harvey Oak Supply Store, The Willows Market and Pharmacy}.
121121
* Stay in the current area if the activity can be done there. Only go out if the activity needs to take place in another place.
122122
* Must be one of the "Area options," verbatim.
123123
For eating dinner, Jane Anderson should go to the following area: {Hobbs Cafe}
@@ -167,17 +167,17 @@ def action_location_sector_prompt(
167167
next_action,
168168
):
169169
s = ""
170-
s += """Task -- choose an appropriate area from the area options for a task at hand.
170+
s += """Task -- choose an appropriate area from the area options for a task at hand.
171171
Sam Kim lives in {Sam Kim's house} that has Sam Kim's room, bathroom, kitchen.
172-
Sam Kim is currently in {Sam Kim's house} that has Sam Kim's room, bathroom, kitchen.
172+
Sam Kim is currently in {Sam Kim's house} that has Sam Kim's room, bathroom, kitchen.
173173
Area options: {Sam Kim's house, The Rose and Crown Pub, Hobbs Cafe, Oak Hill College, Johnson Park, Harvey Oak Supply Store, The Willows Market and Pharmacy}.
174174
* Stay in the current area if the activity can be done there. Only go out if the activity needs to take place in another place.
175175
* Must be one of the "Area options," verbatim.
176176
For taking a walk, Sam Kim should go to the following area: {Johnson Park}
177177
---
178178
Jane Anderson lives in {Oak Hill College Student Dormatory} that has Jane Anderson's room.
179179
Jane Anderson is currently in {Oak Hill College} that has a classroom, library
180-
Area options: {Oak Hill College Student Dormatory, The Rose and Crown Pub, Hobbs Cafe, Oak Hill College, Johnson Park, Harvey Oak Supply Store, The Willows Market and Pharmacy}.
180+
Area options: {Oak Hill College Student Dormatory, The Rose and Crown Pub, Hobbs Cafe, Oak Hill College, Johnson Park, Harvey Oak Supply Store, The Willows Market and Pharmacy}.
181181
* Stay in the current area if the activity can be done there. Only go out if the activity needs to take place in another place.
182182
* Must be one of the "Area options," verbatim.
183183
For eating dinner, Jane Anderson should go to the following area: {Hobbs Cafe}
@@ -226,7 +226,7 @@ def action_location_object(
226226
For cooking, Jane Anderson should go to the following area in Jane Anderson's house:
227227
Answer: {kitchen}
228228
---
229-
Tom Watson is in common room in Tom Watson's apartment.
229+
Tom Watson is in common room in Tom Watson's apartment.
230230
Tom Watson is going to Hobbs Cafe that has the following areas: {cafe}
231231
Stay in the current area if the activity can be done there. Never go into other people's rooms unless necessary.
232232
For getting coffee, Tom Watson should go to the following area in Hobbs Cafe:
@@ -240,7 +240,7 @@ def action_location_object(
240240
+ target_sector_areas
241241
+ "}\n"
242242
)
243-
s += """* Stay in the current area if the activity can be done there.
243+
s += """* Stay in the current area if the activity can be done there.
244244
* NEVER go into other people's rooms unless necessary."""
245245
s += (
246246
persona_name
@@ -268,7 +268,7 @@ def action_location_object_prompt(
268268
For cooking, Jane Anderson should go to the following area in Jane Anderson's house:
269269
Answer: {kitchen}
270270
---
271-
Tom Watson is in common room in Tom Watson's apartment.
271+
Tom Watson is in common room in Tom Watson's apartment.
272272
Tom Watson is going to Hobbs Cafe that has the following areas: {cafe}
273273
Stay in the current area if the activity can be done there. Never go into other people's rooms unless necessary.
274274
For getting coffee, Tom Watson should go to the following area in Hobbs Cafe:
@@ -282,7 +282,7 @@ def action_location_object_prompt(
282282
+ target_sector_areas
283283
+ "}\n"
284284
)
285-
s += """* Stay in the current area if the activity can be done there.
285+
s += """* Stay in the current area if the activity can be done there.
286286
* NEVER go into other people's rooms unless necessary."""
287287
s += (
288288
persona_name

benchmark/json_decode_regex/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ outlines 0.0.22
2020
Run Llama-7B
2121

2222
```
23-
python3 -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000
23+
python3 -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000
2424
```
2525

2626
Run Mixtral-8x7B

0 commit comments

Comments
 (0)