-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Docs] refactor Contribution Guide #2690
[Docs] refactor Contribution Guide #2690
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!@
docs/references/contributor_guide.md
Outdated
bash | ||
git clone https://github.com/sgl-project/sglang.git | ||
cd sglang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git clone https://github.com/<your_user_name>/sglang.git
cd sglang
docs/references/contributor_guide.md
Outdated
2. **Install Dependencies & Build** | ||
Refer to our [Install SGLang](https://sgl-project.github.io/start/install.html) documentation for a detailed explanation of setting up the necessary dependencies and compiling the codebase locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install Dependencies and Build SGLang on the Latest Commit
# Install flashinfer
pip install --upgrade pip
pip install -e "python[all]" --find-links https://flashinfer.ai/whl/cu124/torch2.4/flashinfer/
# Install latest SGLang
cd sglang/python
pip install .
Note: Please check the FlashInfer installation doc to install the proper version according to your PyTorch and CUDA versions.
docs/references/contributor_guide.md
Outdated
bash | ||
pip3 install pre-commit | ||
cd sglang | ||
pre-commit install | ||
pre-commit run --all-files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip3 install pre-commit
cd sglang
pre-commit run --all-files
docs/references/contributor_guide.md
Outdated
## For Newcomers | ||
If you want to contribute or learn but don't have a concrete idea yet, you can pick a task labeled as "good first issue" or "help wanted" from the list below. | ||
[https://github.com/sgl-project/sglang/issues?q=is%3Aissue+label%3A%22good+first+issue%22%2C%22help+wanted%22](https://github.com/sgl-project/sglang/issues?q=is%3Aissue+label%3A%22good+first+issue%22%2C%22help+wanted%22) | ||
- **pre-commit install**: Installs the Git hook, which automatically runs style checks on staged files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this line.
docs/references/contributor_guide.md
Outdated
If you want to contribute or learn but don't have a concrete idea yet, you can pick a task labeled as "good first issue" or "help wanted" from the list below. | ||
[https://github.com/sgl-project/sglang/issues?q=is%3Aissue+label%3A%22good+first+issue%22%2C%22help+wanted%22](https://github.com/sgl-project/sglang/issues?q=is%3Aissue+label%3A%22good+first+issue%22%2C%22help+wanted%22) | ||
- **pre-commit install**: Installs the Git hook, which automatically runs style checks on staged files. | ||
- **pre-commit run --all-files**: Manually runs all the configured checks on your repository, applying automatic fixes where possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit run --all-files
will manually run all the configured checks on your repository, applying automatic fixes where possible. If it fails the first time, please run it again to make sure the lint errors are fixed. Ensure your code passes all these pre-commit link checks. Otherwise, there are grammar errors beyond style in your code. And do not commit to the main branch. Always checkout a new branch with a valid name and commit, then create a pull request on that branch.
docs/references/contributor_guide.md
Outdated
bash | ||
make compile | ||
|
||
This command processes all .ipynb files into intermediate formats. | ||
|
||
2. **Generate HTML Documentation** | ||
|
||
bash | ||
make html | ||
|
||
The generated static site can be found under the _build/html directory. | ||
|
||
3. **Local Preview** | ||
|
||
bash | ||
bash serve.sh | ||
|
||
Open your browser at the specified port to view the docs locally. | ||
|
||
4. **Clean Notebook Outputs & Build Artifacts** | ||
|
||
bash | ||
find . -name '*.ipynb' -exec nbstripout {} \; | ||
make clean | ||
|
||
- **nbstripout** removes all outputs from Jupyter notebooks. | ||
- **make clean** removes temporary files and _build artifacts. | ||
|
||
5. **Modify index.rst (If Necessary)** | ||
Update index.rst whenever you add or remove sections from the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer Jupyter Notebook over Markdown files since its correctness can be ensured by our docs CI.
First make a new file under approperiate path and modify index.rst
if neccessary.
# Compile all .ipynb and markdown files
# The jupyter notebooks will be executed
make compile
# Generate static files and they can be found under _build/html
make html
# Preview the docs
# Open your browser at the specified port to view the docs locally
bash serve.sh
Once you are sure your docs are right and passed compile, make a PR.
# Clean Notebook outputs to make your PR clear
pip install nbstripout
find . -name '*.ipynb' -exec nbstripout {} \;
# Run pre-commit
pre-commit run --all-files
Then you can submit your PR.
TODO: How to run server/engine and close server/engine in docs.
docs/references/contributor_guide.md
Outdated
6. **Pass Pre-Commit and Submit a PR** | ||
After confirming the docs build successfully and pass all checks, open a Pull Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete.
docs/references/contributor_guide.md
Outdated
|
||
### 4.3 Adding or Updating Tests in CI | ||
|
||
- Create new test files under test/srt, ensure they are referenced in test/srt/run_suite.py, or they will not be picked up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create new test files under
/test
, and ensure they are referenced in/test/srt/run_suite.py
or/test/lang/run_suite.py
, other they will not be picked up in CI.
docs/references/contributor_guide.md
Outdated
### 4.3 Adding or Updating Tests in CI | ||
|
||
- Create new test files under test/srt, ensure they are referenced in test/srt/run_suite.py, or they will not be picked up. | ||
- In CI, all tests are executed automatically. You may modify the corresponding workflow in .github/workflows/ if you wish to include custom test groups or additional checks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In CI, all tests are executed automatically. You may modify the corresponding workflow in
/.github/workflows
if you wish to include custom test groups or additional checks.
docs/references/contributor_guide.md
Outdated
|
||
## 5. Tips for Newcomers | ||
|
||
If you want to contribute but don’t have a specific idea in mind, start by picking up issues labeled [“good first issue” or “help wanted”](https://github.com/sgl-project/sglang/issues?q=is%3Aissue+label%3A%22good+first+issue%22%2C%22help+wanted%22). These tasks typically have lower complexity and provide an excellent introduction to the codebase. Feel free to ask questions or request clarifications in the corresponding issue threads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also modify https://sgl-project.github.io/backend/openai_api_completions.html
Great job!!!
|
||
### 1.1 Fork and Clone the Repository | ||
|
||
> **Note**: SGLang does **not** accept PRs on the main repo. Please fork the repository under your GitHub account, then clone your fork locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete >
|
||
### 1.2 Install Dependencies & Build | ||
|
||
Refer to our [Install SGLang](https://sgl-project.github.io/start/install.html) documentation for more details on setting up the necessary dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete our
|
||
Refer to our [Install SGLang](https://sgl-project.github.io/start/install.html) documentation for more details on setting up the necessary dependencies. | ||
|
||
Before installing packages like FlashInfer, ensure your local PyTorch and CUDA versions match: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install correct version of flashinfer according to your local xxx
``` | ||
|
||
Based on this information, choose the correct FlashInfer package (or any other CUDA-dependent library). | ||
Below is an example assuming you have **PyTorch 2.4** with **CUDA 12.4**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below is an example on PyTorch 2.4 with CUDA 12.4:
Below is an example assuming you have **PyTorch 2.4** with **CUDA 12.4**: | ||
|
||
```bash | ||
# Example: Installing FlashInfer (Pick the right version for your CUDA/PyTorch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
Example: Installing FlashInfer (Pick the right version for your CUDA/PyTorch)
|
||
```bash | ||
python -c "import torch; print('PyTorch Version:', torch.__version__); print('CUDA Version:', torch.version.cuda)" | ||
nvidia-smi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this
pip install --upgrade pip | ||
pip install -e "python[all]" --find-links https://flashinfer.ai/whl/cu124/torch2.4/flashinfer/ | ||
|
||
# Now install the latest SGLang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install the lateset SGLang on your own fork repo
- **`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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make them into one line.
- Add or 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. | ||
|
||
- For tasks that require a running SGLang backend, you might launch a server process or an engine instance. Once you finish testing or using it, **remember to shut it down**. Refer to: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need to run and shut up a SGLang server or engine, following these examples:
- Launch and close Sever:
#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)
- Launch Engine
# Launch Engine
import sglang as sgl
import asyncio
llm = sgl.Engine(model_path="meta-llama/Meta-Llama-3.1-8B-Instruct")
# Terminalte Engine
llm.shutdown()
Motivation
related to #2662