main
md 376 lines 17.6 KB
Rendered Raw
1 # Contributing to vLLM
2
3 Thank you for your interest in contributing to vLLM! Our community is open to everyone and welcomes all kinds of contributions, no matter how small or large. There are several ways you can contribute to the project:
4
5 - Identify and report any issues or bugs.
6 - Request or add support for a new model.
7 - Suggest or implement new features.
8 - Improve documentation or contribute a how-to guide.
9
10 We also believe in the power of community support; thus, answering queries, offering PR reviews, and assisting others are also highly regarded and beneficial contributions.
11
12 Finally, one of the most impactful ways to support us is by raising awareness about vLLM. Talk about it in your blog posts and highlight how it's driving your incredible projects. Express your support on social media if you're using vLLM, or simply offer your appreciation by starring our repository!
13
14 ## Job Board
15
16 Unsure on where to start? Check out the following links for tasks to work on:
17
18 - [Good first issues](https://github.com/vllm-project/vllm/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22)
19 - [Selected onboarding tasks](https://github.com/orgs/vllm-project/projects/6)
20 - [New model requests](https://github.com/vllm-project/vllm/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22new-model%22)
21 - [Models with multi-modal capabilities](https://github.com/orgs/vllm-project/projects/10)
22
23 ## License
24
25 See [LICENSE](../../LICENSE).
26
27 ## Developing
28
29 The first step of contributing to vLLM is to clone the GitHub repository:
30
31 ```bash
32 git clone https://github.com/vllm-project/vllm.git
33 cd vllm
34 ```
35
36 Then, configure your Python virtual environment.
37
38 --8<-- "docs/getting_started/installation/python_env_setup.inc.md"
39
40 If you are only developing vLLM's Python code, install vLLM using:
41
42 ```bash
43 VLLM_USE_PRECOMPILED=1 uv pip install -e .
44 ```
45
46 To rebuild only the Rust frontend binary:
47
48 ```bash
49 ./tools/build_rust.sh # release build
50 ./tools/build_rust.sh --debug # faster build for development
51 ```
52
53 If you are developing vLLM's Python and CUDA/C++ code, install PyTorch first:
54
55 ```bash
56 uv pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu129
57 ```
58
59 Then install the necessary build dependencies from `requirements/build/cuda.txt`, skipping `torch` as it was installed in the previous step:
60
61 ```bash
62 grep -v '^torch==' requirements/build/cuda.txt | uv pip install -r -
63 ```
64
65 Finally install vLLM using:
66
67 ```bash
68 uv pip install -e . --no-build-isolation
69 ```
70
71 For more details about installing from source and installing for other hardware, check out the [installation instructions](../getting_started/installation/README.md) for your hardware and head to the "Build wheel from source" section.
72
73 For an optimized workflow when iterating on C++/CUDA kernels, see the [Incremental Compilation Workflow](./incremental_build.md) for recommendations.
74 For JIT kernel warmup conventions, see [JIT Kernel Warmup](./jit_kernel_warmup.md).
75
76 !!! tip
77 vLLM is compatible with Python versions 3.10 to 3.13. However, vLLM's default [Dockerfile](../../docker/Dockerfile) ships with Python 3.12 and tests in CI (except `mypy`) are run with Python 3.12.
78
79 Therefore, we recommend developing with Python 3.12 to minimise the chance of your local environment clashing with our CI environment.
80
81 ### Linting
82
83 vLLM uses `pre-commit` to lint and format the codebase. See <https://pre-commit.com/#usage> if `pre-commit` is new to you. Setting up `pre-commit` is as easy as:
84
85 ```bash
86 uv pip install pre-commit>=4.5.1
87 pre-commit install
88 ```
89
90 vLLM's `pre-commit` hooks will now run automatically every time you commit.
91
92 When running ShellCheck or markdownlint directly, or configuring an editor
93 integration, use the configuration files in `tools/pre_commit/`:
94 `--rcfile=tools/pre_commit/.shellcheckrc` for ShellCheck and
95 `--config tools/pre_commit/.markdownlint.yaml` for markdownlint-cli2.
96
97 !!! tip "Tips"
98 You can manually run the `pre-commit` hooks using:
99
100 ```bash
101 pre-commit run # runs on staged files
102 pre-commit run -a # runs on all files (short for --all-files)
103 ```
104
105 ---
106
107 Some `pre-commit` hooks only run in CI. If you need to, you can run them locally with:
108
109 ```bash
110 pre-commit run --hook-stage manual mypy-3.11
111 ```
112
113 ### Documentation
114
115 MkDocs is a fast, simple and downright gorgeous static site generator that's geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML configuration file, [mkdocs.yaml](../../mkdocs.yaml).
116
117 Get started with:
118
119 ```bash
120 uv pip install -r requirements/docs.txt
121 ```
122
123 !!! tip
124 Ensure that your Python version is compatible with the plugins
125 (e.g., `mkdocs-awesome-nav` requires Python 3.10+)
126
127 MkDocs comes with a built-in dev-server that lets you preview your documentation as you work on it.
128 From the root of the repository, run the following. Note that by default, the dev-server will run on `127.0.0.1:8000`. Should you want to run the dev-server on a different port, use `-a` like this `mkdocs serve -a localhost:8090`.
129
130 ```bash
131 mkdocs serve # with API ref (~10 minutes)
132 API_AUTONAV_EXCLUDE=vllm mkdocs serve # API ref off (~15 seconds)
133 ```
134
135 Once you see a `Serving on http://<address>:<port>/` line in the logs, the live preview is ready!
136 Open that address in your browser to see it — `http://127.0.0.1:8000/` by default, or whichever host/port you passed to `-a`.
137
138 On pull requests, Read the Docs builds a documentation preview only if the PR changes files that affect the docs (e.g. `docs/`, `examples/` or `mkdocs.yaml`) and the `pre-commit` checks have not failed.
139 Changes to `vllm/` alone do not trigger a build, so if your PR changes the API or CLI reference, add the `build-docs` label to force one.
140
141 For additional features and advanced configurations, refer to the:
142
143 - [MkDocs documentation](https://www.mkdocs.org/)
144 - [Material for MkDocs documentation](https://squidfunk.github.io/mkdocs-material/) (the MkDocs theme we use)
145
146 ### Testing
147
148 vLLM uses `pytest` to test the codebase.
149
150 ```bash
151 # Install the test dependencies used in CI (CUDA only)
152 uv pip install -r requirements/common.txt -r requirements/dev.txt --torch-backend=auto
153
154 # Install some common test dependencies (hardware agnostic)
155 uv pip install pytest pytest-asyncio
156
157 # Run all tests
158 pytest tests/
159
160 # Run tests for a single test file with detailed output
161 pytest -s -v tests/test_logger.py
162 ```
163
164 !!! tip "Install python3-dev if Python.h is missing"
165 If any of the above commands fails with `Python.h: No such file or directory`, install
166 `python3-dev` with `sudo apt install python3-dev`.
167
168 !!! warning "Warnings"
169 Currently, the repository is not fully checked by `mypy`.
170
171 ---
172
173 Currently, not all unit tests pass when run on CPU platforms. If you don't have access to a GPU
174 platform to run unit tests locally, rely on the continuous integration system to run the tests for
175 now.
176
177 ## Issues
178
179 If you encounter a bug or have a feature request, please [search existing issues](https://github.com/vllm-project/vllm/issues?q=is%3Aissue) first to see if it has already been reported. If not, please [file a new issue](https://github.com/vllm-project/vllm/issues/new/choose), providing as much relevant information as possible.
180
181 !!! important
182 If you discover a security vulnerability, please follow the instructions [here](../../SECURITY.md).
183
184 ## Pull Requests & Code Reviews
185
186 Thank you for your contribution to vLLM! Before submitting the pull request,
187 please ensure the PR meets the following criteria. This helps vLLM maintain the
188 code quality and improve the efficiency of the review process.
189
190 ### DCO and Signed-off-by
191
192 When contributing changes to this project, you must agree to the [DCO](../../DCO).
193 Commits must include a `Signed-off-by:` header which certifies agreement with
194 the terms of the DCO.
195
196 Using `-s` with `git commit` will automatically add this header.
197
198 !!! tip
199 You can enable automatic sign-off via your IDE:
200
201 - **PyCharm**: Click on the `Show Commit Options` icon to the right of the `Commit and Push...` button in the `Commit` window.
202 It will bring up a `git` window where you can modify the `Author` and enable `Sign-off commit`.
203 - **VSCode**: Open the [Settings editor](https://code.visualstudio.com/docs/configure/settings)
204 and enable the `Git: Always Sign Off` (`git.alwaysSignOff`) field.
205
206 ### AI Assisted Contributions
207
208 Before making an AI assisted contribution, you must:
209
210 1. **Be involved**: Do not submit "pure agent" PRs. The human submitter is responsible for reviewing all changed lines, validating behavior end-to-end, and running relevant tests.
211 2. **Ensure significance**: Avoid one-off "busywork" PRs (single typo, isolated style cleanup, one mutable default fix, etc.). Bundle mechanical cleanups into a clear, systematic scope.
212
213 When AI tools provide non-trivial assistance in generating or modifying code, you must:
214
215 1. **Review thoroughly**: You remain responsible for all code you submit. Review and understand AI-generated code with the same care as code you write manually.
216 2. **Disclose in PR**: Always mention when a pull request includes AI-generated code. Add a note in the PR description.
217 3. **Mark commits**: Add attribution using commit trailers such as `Co-authored-by:` (other projects use `Assisted-by:` or `Generated-by:`). For example:
218
219 ```text
220 Your commit message here
221
222 Co-authored-by: GitHub Copilot
223 Co-authored-by: Claude
224 Co-authored-by: gemini-code-assist
225 Signed-off-by: Your Name <your.email@example.com>
226 ```
227
228 AI-assisted code must meet all quality standards: proper testing, documentation, adherence to style guides, and thorough review. Attribution helps reviewers evaluate contributions in context and maintains legal clarity for the project.
229
230 ### PR Title and Classification
231
232 PR titles must start with one or more bracketed tags, followed by a space and a
233 concise description, for example, `[Bugfix][Scheduler] Fix priority handling`.
234 Any descriptive tag is accepted. The following well-known tags improve
235 consistency and discoverability; use one of them when it fits, or choose a more
236 specific tag.
237
238 **Type tags** describe the nature of the change:
239
240 - `[Bugfix]`, `[Feature]`, `[Perf]`, and `[Refactor]` for code changes.
241 - `[CI]` or `[CI/Build]`, `[Test]`, and `[Doc]` or `[Docs]` for project
242 infrastructure, tests, and documentation.
243 - `[Misc]` when another type tag does not fit.
244
245 **Scope tags** identify the affected area:
246
247 - `[Model]`, `[Frontend]`, `[Rust Frontend]`, `[Core]`, and `[Kernel]` for major
248 areas of the codebase.
249 - `[Model Runner V2]` or `[MRV2]`, `[Attention]`, `[Multimodal]`,
250 `[Quantization]`, `[MoE]`, `[Spec Decode]`, `[LoRA]`, `[KV Connector]`, and
251 `[KV Offload]` for frequently changed subsystems.
252 - `[ROCm]`, `[XPU]`, `[CPU]`, or `[Hardware][Vendor]` for hardware-specific
253 changes. Replace `Vendor` with the vendor name, for example,
254 `[Hardware][AMD]`.
255
256 Type and scope tags can be combined, and multiple tags from either category can
257 be stacked without spaces. For example, `[Bugfix][KV Offload] Fix block
258 accounting` or `[Perf][ROCm][Kernel] Optimize fused MoE`.
259
260 ### Code Quality
261
262 The PR needs to meet the following code quality standards:
263
264 - We adhere to [Google Python style guide](https://google.github.io/styleguide/pyguide.html) and [Google C++ style guide](https://google.github.io/styleguide/cppguide.html).
265 - Pass all linter checks.
266 - The code needs to be well-documented to ensure future contributors can easily
267 understand the code.
268 - Include sufficient tests to ensure the project stays correct and robust. This
269 includes both unit tests and integration tests.
270 - Please add documentation to `docs/` if the PR modifies the user-facing behaviors of vLLM.
271 It helps vLLM users understand and utilize the new features or changes.
272
273 ### Adding or Changing Kernels
274
275 When actively developing or modifying kernels, using the [Incremental Compilation Workflow](./incremental_build.md) is highly recommended for faster build times.
276 Each custom kernel needs a schema and one or more implementations to be registered with PyTorch.
277
278 - Make sure custom ops are registered following PyTorch guidelines:
279 [Custom C++ and CUDA Operators](https://pytorch.org/tutorials/advanced/cpp_custom_ops.html#cpp-custom-ops-tutorial)
280 and [The Custom Operators Manual](https://docs.google.com/document/d/1_W62p8WJOQQUzPsJYa7s701JXt0qf2OfLub2sbkHOaU).
281 - Custom operations that return `Tensors` require meta-functions.
282 Meta-functions should be implemented and registered in Python so that dynamic
283 dims can be handled automatically. See above documents for a description of
284 meta-functions.
285 - Use [torch.library.opcheck()](https://pytorch.org/docs/stable/library.html#torch.library.opcheck)
286 to test the function registration and meta-function for any registered ops.
287 See `tests/kernels` for examples.
288 - When changing the C++ signature of an existing op, the schema must be updated
289 to reflect the changes.
290 - If a new custom type is needed, see the following document:
291 [Custom Class Support in PT2](https://docs.google.com/document/d/18fBMPuOJ0fY5ZQ6YyrHUppw9FA332CpNtgB6SOIgyuA).
292
293 ### Notes for Large Changes
294
295 Please keep the changes as concise as possible. For major architectural changes
296 (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue
297 (RFC) discussing the technical design and justification. Otherwise, we will tag
298 it with `rfc-required` and might not go through the PR.
299
300 ### What to Expect for the Reviews
301
302 The goal of the vLLM team is to be a *transparent reviewing machine*. We would
303 like to make the review process transparent and efficient and make sure no
304 contributor feels confused or frustrated. However, the vLLM team is small, so we
305 need to prioritize some PRs over others. Here is what you can expect from the
306 review process:
307
308 - After the PR is submitted, the PR will be assigned to a reviewer. Every
309 reviewer will pick up the PRs based on their expertise and availability.
310 - After the PR is assigned, the reviewer will provide status updates every 2-3
311 days. If the PR is not reviewed within 7 days, please feel free to ping the
312 reviewer or the vLLM team.
313 - After the review, the reviewer will put an `action-required` label on the PR
314 if there are changes required. The contributor should address the comments and
315 ping the reviewer to re-review the PR.
316 - Please respond to all comments within a reasonable time frame. If a comment
317 isn't clear or you disagree with a suggestion, feel free to ask for
318 clarification or discuss the suggestion.
319 - Note that not all CI checks will be executed due to limited computational
320 resources. Reviewers with write access and configured trusted contributors
321 can comment `/ci run` for upstream CI or `/amd-ci run` for AMD CI only when
322 CI signals are needed before a PR is ready. After the PR is approved or has
323 the `ready` label, the PR author can use `/ci run`, `/ci retry`, `/ci cancel`,
324 or the corresponding `/amd-ci` variants. New commits do not start upstream
325 CI automatically.
326 - Before creating a Buildkite build, `/ci run` and `/amd-ci run`, including
327 `all` and `nightly`, check the requested PR commit against its target branch
328 in the upstream repository. Your branch must contain every commit currently
329 on that branch: **zero commits behind**. This also applies to PRs targeting
330 release branches or another PR's branch.
331 - If the PR is behind, the bot reports the count without creating a new build.
332 Merge or rebase onto the latest target branch, then rerun the command. If the
333 target branch advances in the meantime, update your branch and try again.
334 - To run CI on an outdated branch at your own risk, append `--allow-stale` to
335 any run command, for example `/ci run --allow-stale` or
336 `/amd-ci run all --allow-stale`. The same authorization requirements apply.
337 The bot reports the lag and warns that outdated CI configuration may cause
338 failures. Before merging, merge or rebase onto the latest target branch and
339 rerun CI without `--allow-stale` on the latest PR commit.
340 - Retrying or cancelling builds does not check branch freshness.
341 - These commands do not modify your branch or enforce merge requirements.
342 Direct Buildkite launches are outside this workflow. No additional token is
343 needed.
344
345 Maintainers must configure required Buildkite status checks on the latest PR
346 commit and enable GitHub's
347 [Require branches to be up to date before merging](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches#require-status-checks-before-merging)
348 protection on the relevant target branches to enforce the merge policy. Select
349 statuses that confirm the required tests completed, using Buildkite as their
350 expected source. An aggregate status that reports "passed and blocked" does not
351 by itself guarantee those tests ran; verify the pipeline's required and optional
352 blocked steps before choosing statuses or changing blocked-build reporting.
353 The CI command workflow does not configure these repository or pipeline settings.
354
355 ### Pull Request Limits and Escalation
356
357 vLLM uses GitHub's [pull request limit](https://github.blog/open-source/maintainers/how-pull-request-limits-are-cutting-down-the-noise/)
358 for contributors without write access. The current cap is 6 open PRs. If this
359 blocks well-intentioned critical work, contact a committer to request bypass
360 list access.
361
362 If you need an expedited review for an important contribution, please email us
363 at:
364
365 <pr-review-request@vllm.ai>
366
367 Using a verifiable company or university email, include:
368
369 - your production or research use case
370 - the problem you encountered
371 - how your contribution addresses it
372
373 ## Thank You
374
375 Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM.
376 All of your contributions help make vLLM a great tool and community for everyone!