Skip to content
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

Merged
merged 8 commits into from
Dec 31, 2024

Conversation

shuaills
Copy link
Contributor

Motivation

related to #2662

Copy link
Collaborator

@zhaochenyang20 zhaochenyang20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!@

Comment on lines 9 to 11
bash
git clone https://github.com/sgl-project/sglang.git
cd sglang
Copy link
Collaborator

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

Comment on lines 13 to 14
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.
Copy link
Collaborator

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.

Comment on lines 20 to 24
bash
pip3 install pre-commit
cd sglang
pre-commit install
pre-commit run --all-files
Copy link
Collaborator

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

## 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this line.

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.
Copy link
Collaborator

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.

Comment on lines 38 to 67
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.
Copy link
Collaborator

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.

Comment on lines 69 to 70
6. **Pass Pre-Commit and Submit a PR**
After confirming the docs build successfully and pass all checks, open a Pull Request.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete.


### 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.
Copy link
Collaborator

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.

### 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.
Copy link
Collaborator

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.


## 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@zhaochenyang20 zhaochenyang20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


### 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.
Copy link
Collaborator

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.
Copy link
Collaborator

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:
Copy link
Collaborator

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**:
Copy link
Collaborator

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)
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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

Comment on lines 53 to 55
- **`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.
Copy link
Collaborator

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.

docs/references/contribution_guide.md Show resolved Hide resolved
- 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:
Copy link
Collaborator

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:

  1. 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)
  1. 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()

@zhaochenyang20 zhaochenyang20 merged commit 0a765bb into sgl-project:main Dec 31, 2024
1 of 2 checks passed
@shuaills shuaills deleted the doc/contributor-guide branch January 2, 2025 22:24
XiaotongJiang pushed a commit to XiaotongJiang/sglang that referenced this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants