main
yaml 327 lines 12.6 KB
Raw
1 default_install_hook_types:
2 - pre-commit
3 - commit-msg
4 default_stages:
5 - pre-commit # Run locally
6 - manual # Run in CI
7 exclude: 'vllm/third_party/.*|vllm/models/kimi_k3/nvidia/ops/third_party/.*|vllm/models/kimi_k3/amd/ops/third_party/.*'
8 repos:
9 - repo: https://github.com/astral-sh/ruff-pre-commit
10 rev: v0.14.0
11 hooks:
12 - id: ruff-check
13 args: [--output-format, github, --fix]
14 - id: ruff-format
15 - repo: https://github.com/crate-ci/typos
16 rev: v1.43.5
17 hooks:
18 - id: typos
19 args: [--force-exclude]
20 - repo: https://github.com/pre-commit/mirrors-clang-format
21 rev: v21.1.2
22 hooks:
23 - id: clang-format
24 exclude: 'csrc/libtorch_stable/moe/topk_softmax_kernels.cu|vllm/third_party/.*'
25 types_or: [c++, cuda]
26 args: [--style=file, --verbose]
27 - repo: https://github.com/DavidAnson/markdownlint-cli2
28 rev: v0.21.0
29 hooks:
30 - id: markdownlint-cli2
31 language_version: lts
32 args: [--config, tools/pre_commit/.markdownlint.yaml, --fix]
33 exclude: (^|/)CLAUDE\.md$
34 - repo: https://github.com/rhysd/actionlint
35 rev: v1.7.7
36 hooks:
37 - id: actionlint
38 - repo: https://github.com/shellcheck-py/shellcheck-py
39 rev: 745eface02aef23e168a8afb6b5737818efbea95 # v0.11.0.1
40 hooks:
41 - id: shellcheck
42 args: ["-s", "bash", "--format=gcc", "--rcfile=tools/pre_commit/.shellcheckrc"]
43 - repo: https://github.com/astral-sh/uv-pre-commit
44 rev: 0.11.1
45 hooks:
46 - id: pip-compile
47 args: [
48 requirements/test/cuda.in,
49 -c, requirements/cuda.txt,
50 -o, requirements/test/cuda.txt,
51 --index-strategy, unsafe-best-match,
52 --torch-backend, cu130,
53 --python-platform, x86_64-manylinux_2_28,
54 --python-version, "3.12",
55 ]
56 files: ^requirements/(common|cuda|test/cuda)\.(in|txt)$
57 - id: pip-compile
58 alias: pip-compile-rocm
59 name: pip-compile-rocm
60 args: [
61 requirements/test/rocm.in,
62 -c, requirements/rocm.txt,
63 -o, requirements/test/rocm.txt,
64 --index-strategy, unsafe-best-match,
65 --python-platform, x86_64-manylinux_2_28,
66 --python-version, "3.12",
67 # Exclude torch and CUDA/NVIDIA packages
68 --no-emit-package, torch,
69 --no-emit-package, torchvision,
70 --no-emit-package, torchaudio,
71 --no-emit-package, triton,
72 --no-emit-package, cuda-bindings,
73 --no-emit-package, cuda-pathfinder,
74 --no-emit-package, cuda-toolkit,
75 --no-emit-package, cupy-cuda12x,
76 # nvidia packages (unsuffixed / unified naming)
77 --no-emit-package, nvidia-cublas,
78 --no-emit-package, nvidia-cuda-cupti,
79 --no-emit-package, nvidia-cuda-nvrtc,
80 --no-emit-package, nvidia-cuda-runtime,
81 --no-emit-package, nvidia-cudnn,
82 --no-emit-package, nvidia-cufft,
83 --no-emit-package, nvidia-cufile,
84 --no-emit-package, nvidia-curand,
85 --no-emit-package, nvidia-cusolver,
86 --no-emit-package, nvidia-cusparse,
87 --no-emit-package, nvidia-cusparselt,
88 --no-emit-package, nvidia-nccl,
89 --no-emit-package, nvidia-nvjitlink,
90 --no-emit-package, nvidia-nvshmem,
91 --no-emit-package, nvidia-nvtx,
92 # nvidia cu12 packages
93 --no-emit-package, nvidia-cublas-cu12,
94 --no-emit-package, nvidia-cuda-cupti-cu12,
95 --no-emit-package, nvidia-cuda-nvrtc-cu12,
96 --no-emit-package, nvidia-cuda-runtime-cu12,
97 --no-emit-package, nvidia-cudnn-cu12,
98 --no-emit-package, nvidia-cufft-cu12,
99 --no-emit-package, nvidia-cufile-cu12,
100 --no-emit-package, nvidia-curand-cu12,
101 --no-emit-package, nvidia-cusolver-cu12,
102 --no-emit-package, nvidia-cusparse-cu12,
103 --no-emit-package, nvidia-cusparselt-cu12,
104 --no-emit-package, nvidia-nccl-cu12,
105 --no-emit-package, nvidia-nvjitlink-cu12,
106 --no-emit-package, nvidia-nvshmem-cu12,
107 --no-emit-package, nvidia-nvtx-cu12,
108 # nvidia cu13 packages
109 --no-emit-package, nvidia-cublas-cu13,
110 --no-emit-package, nvidia-cuda-cupti-cu13,
111 --no-emit-package, nvidia-cuda-nvrtc-cu13,
112 --no-emit-package, nvidia-cuda-runtime-cu13,
113 --no-emit-package, nvidia-cudnn-cu13,
114 --no-emit-package, nvidia-cufft-cu13,
115 --no-emit-package, nvidia-cufile-cu13,
116 --no-emit-package, nvidia-curand-cu13,
117 --no-emit-package, nvidia-cusolver-cu13,
118 --no-emit-package, nvidia-cusparse-cu13,
119 --no-emit-package, nvidia-cusparselt-cu13,
120 --no-emit-package, nvidia-nccl-cu13,
121 --no-emit-package, nvidia-nvjitlink-cu13,
122 --no-emit-package, nvidia-nvshmem-cu13,
123 --no-emit-package, nvidia-nvtx-cu13,
124 ]
125 files: ^requirements/(common|rocm|test/rocm)\.(in|txt)$
126 - id: pip-compile
127 alias: pip-compile-xpu
128 name: pip-compile-xpu
129 args: [
130 requirements/test/xpu.in,
131 -c, requirements/xpu.txt,
132 -o, requirements/test/xpu.txt,
133 --index-strategy, unsafe-best-match,
134 --python-platform, x86_64-manylinux_2_39,
135 --python-version, "3.12",
136 ]
137 files: ^requirements/(common|xpu|test/xpu)\.(in|txt)$
138 - id: pip-compile
139 alias: pip-compile-cpu
140 name: pip-compile-cpu
141 args: [
142 requirements/test/cuda.in,
143 -o, requirements/test/cpu.txt,
144 --index-strategy, unsafe-best-match,
145 --torch-backend, cpu,
146 --python-platform, x86_64-manylinux_2_28,
147 --python-version, "3.12",
148 ]
149 files: ^requirements/(common|cpu|test/(cuda|cpu))\.(in|txt)$
150 exclude: ^requirements/test/cuda\.txt$
151 - id: pip-compile
152 alias: pip-compile-docs
153 name: pip-compile-docs
154 args: [
155 requirements/docs.in,
156 -o, requirements/docs.txt,
157 --python-platform, x86_64-manylinux_2_28,
158 --python-version, "3.12",
159 ]
160 files: ^requirements/docs\.(in|txt)$
161 - repo: https://github.com/pre-commit/pre-commit-hooks
162 rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c
163 hooks:
164 - id: check-json
165 files: ^\.buildkite/.*\.json$
166 - repo: local
167 hooks:
168 - id: format-torch-nightly-test
169 name: reformat test/nightly-torch.txt to be in sync with test/cuda.in
170 language: python
171 entry: python tools/pre_commit/generate_nightly_torch_test.py
172 files: ^requirements/test/cuda\.(in|txt)$
173 - id: check-label-rules
174 name: Check auto-label rules still match real files
175 language: python
176 entry: python tools/pre_commit/check_label_rules.py
177 files: ^\.github/mergify\.yml$
178 pass_filenames: false
179 additional_dependencies: [PyYAML, regex]
180 - id: check-buildkite-step-keys
181 name: Check every Buildkite step declares an explicit key
182 language: python
183 entry: python tools/pre_commit/check_buildkite_step_keys.py
184 files: ^\.buildkite/.*\.ya?ml$
185 pass_filenames: false
186 additional_dependencies: [PyYAML]
187 - id: check-test-tethering
188 name: Check new tests are wired into Buildkite CI
189 language: python
190 entry: python tools/pre_commit/check_test_tethering.py
191 files: ^(tests/.*\.py|\.buildkite/(test_areas|hardware_tests|intel_jobs)/.*\.yaml|\.buildkite/(test-amd|ci_config[^/]*)\.yaml|tools/pre_commit/test_tethering_allowlist\.txt)$
192 additional_dependencies: [PyYAML, regex]
193 verbose: true # full-scan `note:` lines are advisory, so the hook passes
194 require_serial: true # one full scan, not one per pre-commit file batch
195 - id: mypy-3.10 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
196 name: Run mypy for Python 3.10
197 entry: python tools/pre_commit/mypy.py "3.10"
198 <<: &mypy_common
199 language: python
200 types_or: [python, pyi]
201 require_serial: true
202 additional_dependencies: ["mypy==1.20.2", regex, types-cachetools, types-setuptools, types-PyYAML, types-requests, types-torch, pydantic]
203 - id: mypy-3.11 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
204 name: Run mypy for Python 3.11
205 entry: python tools/pre_commit/mypy.py "3.11"
206 <<: *mypy_common
207 stages: [manual] # Only run in CI
208 - id: mypy-3.12 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
209 name: Run mypy for Python 3.12
210 entry: python tools/pre_commit/mypy.py "3.12"
211 <<: *mypy_common
212 stages: [manual] # Only run in CI
213 - id: mypy-3.13 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
214 name: Run mypy for Python 3.13
215 entry: python tools/pre_commit/mypy.py "3.13"
216 <<: *mypy_common
217 stages: [manual] # Only run in CI
218 - id: png-lint
219 name: Lint PNG exports from excalidraw
220 entry: tools/pre_commit/png-lint.sh
221 language: script
222 types: [png]
223 - id: signoff-commit
224 name: Sign-off Commit
225 entry: bash
226 args:
227 - -c
228 - |
229 if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then
230 printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)"
231 fi
232 language: system
233 verbose: true
234 stages: [commit-msg]
235 - id: check-spdx-header
236 name: Check SPDX headers
237 entry: python tools/pre_commit/check_spdx_header.py
238 language: python
239 types_or: [python, rust, proto]
240 - id: check-root-lazy-imports
241 name: Check root lazy imports
242 entry: python tools/pre_commit/check_init_lazy_imports.py
243 language: python
244 types: [python]
245 - id: check-filenames
246 name: Check for spaces in all filenames
247 entry: bash
248 args:
249 - -c
250 - 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0'
251 language: system
252 always_run: true
253 pass_filenames: false
254 - id: update-dockerfile-graph
255 name: Update Dockerfile dependency graph
256 entry: tools/pre_commit/update-dockerfile-graph.sh
257 language: script
258 - id: test-nonroot-entrypoint
259 name: Test non-root entrypoint wrapper
260 entry: bash docker/entrypoints/test_vllm_nonroot_entrypoint.sh
261 language: system
262 pass_filenames: false
263 files: ^docker/entrypoints/(vllm-nonroot-entrypoint|test_vllm_nonroot_entrypoint)\.sh$
264 - id: check-forbidden-imports
265 name: Check for forbidden imports
266 entry: python tools/pre_commit/check_forbidden_imports.py
267 language: python
268 types: [python]
269 additional_dependencies: [regex]
270 # prevent use torch.cuda APIs
271 - id: check-torch-cuda-call
272 name: "Prevent new 'torch.cuda' APIs call"
273 entry: python tools/pre_commit/check_torch_cuda.py
274 language: python
275 types: [python]
276 additional_dependencies: [regex]
277 - id: validate-config
278 name: Validate configuration has default values and that each field has a docstring
279 entry: python tools/pre_commit/validate_config.py
280 language: python
281 additional_dependencies: [regex]
282 - id: validate-docker-versions
283 name: Validate docker/versions.json matches Dockerfile
284 entry: python tools/generate_versions_json.py --check
285 language: python
286 files: ^docker/(Dockerfile|versions\.json)$
287 pass_filenames: false
288 additional_dependencies: [dockerfile-parse]
289 - id: check-boolean-context-manager
290 name: Check for boolean ops in with-statements
291 entry: python tools/pre_commit/check_boolean_context_manager.py
292 language: python
293 types: [python]
294 # Rust hooks. These shell out to `cargo`; tools/pre_commit/rust-check.sh
295 # skips with a warning when cargo is not installed.
296 - id: rust-cargo-autoinherit
297 name: Rust - Normalize Cargo manifests with autoinherit
298 entry: tools/pre_commit/rust-check.sh autoinherit --prefer-simple-dotted
299 language: script
300 pass_filenames: false
301 require_serial: true
302 stages: [pre-commit] # Only run locally as Buildkite will cover this
303 files: ^rust/(Cargo\.toml|proto/Cargo\.toml|src/.*/Cargo\.toml)$
304 - id: rust-cargo-sort
305 name: Rust - Sort Cargo manifest sections
306 entry: tools/pre_commit/rust-check.sh sort --workspace
307 language: script
308 pass_filenames: false
309 require_serial: true
310 stages: [pre-commit] # Only run locally as Buildkite will cover this
311 files: ^rust/(Cargo\.toml|proto/Cargo\.toml|src/.*/Cargo\.toml)$
312 - id: rust-cargo-fmt
313 name: Rust - Format code
314 entry: tools/pre_commit/rust-check.sh fmt
315 language: script
316 pass_filenames: false
317 require_serial: true
318 stages: [pre-commit] # Only run locally as Buildkite will cover this
319 files: ^rust/.*(\.rs|Cargo\.toml|rustfmt\.toml)$
320 # Keep `suggestion` last
321 - id: suggestion
322 name: Suggestion
323 entry: bash -c 'echo "To bypass all the pre-commit hooks, add --no-verify to git commit. To skip a specific hook, prefix the commit command with SKIP=<hook-id>."'
324 language: system
325 verbose: true
326 pass_filenames: false
327 # Insert new entries above the `suggestion` entry