Skip to content

Commit d6953be

Browse files
authored
Convert formatting to use ruff instead of yapf + isort (#26247)
Signed-off-by: Harry Mellor <[email protected]>
1 parent 17edd8a commit d6953be

File tree

1,508 files changed

+115576
-94478
lines changed

Some content is hidden

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

1,508 files changed

+115576
-94478
lines changed

.buildkite/pyproject.toml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,16 @@ default_stages:
66
- manual # Run in CI
77
exclude: 'vllm/third_party/.*'
88
repos:
9-
- repo: https://github.com/google/yapf
10-
rev: v0.43.0
11-
hooks:
12-
- id: yapf
13-
args: [--in-place, --verbose]
14-
# Keep the same list from yapfignore here to avoid yapf failing without any inputs
15-
exclude: '(.buildkite|benchmarks|build|examples)/.*'
169
- repo: https://github.com/astral-sh/ruff-pre-commit
1710
rev: v0.11.7
1811
hooks:
1912
- id: ruff
2013
args: [--output-format, github, --fix]
2114
- id: ruff-format
22-
files: ^(.buildkite|benchmarks|examples)/.*
2315
- repo: https://github.com/crate-ci/typos
2416
rev: v1.35.5
2517
hooks:
2618
- id: typos
27-
- repo: https://github.com/PyCQA/isort
28-
rev: 6.0.1
29-
hooks:
30-
- id: isort
3119
- repo: https://github.com/pre-commit/mirrors-clang-format
3220
rev: v20.1.3
3321
hooks:

benchmarks/benchmark_block_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33
import gc
44

5+
from benchmark_utils import TimeCollector
56
from tabulate import tabulate
67

7-
from benchmark_utils import TimeCollector
88
from vllm.utils import FlexibleArgumentParser
99
from vllm.v1.core.block_pool import BlockPool
1010

benchmarks/benchmark_ngram_proposer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from unittest import mock
66

77
import numpy as np
8+
from benchmark_utils import TimeCollector
89
from tabulate import tabulate
910

10-
from benchmark_utils import TimeCollector
1111
from vllm.config import (
1212
CacheConfig,
1313
DeviceConfig,

benchmarks/benchmark_serving_structured_output.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@
3737
import datasets
3838
import numpy as np
3939
import pandas as pd
40-
from tqdm.asyncio import tqdm
41-
from transformers import PreTrainedTokenizerBase
42-
4340
from backend_request_func import (
4441
ASYNC_REQUEST_FUNCS,
4542
RequestFuncInput,
4643
RequestFuncOutput,
4744
)
45+
from tqdm.asyncio import tqdm
46+
from transformers import PreTrainedTokenizerBase
4847

4948
try:
5049
from vllm.transformers_utils.tokenizer import get_tokenizer

benchmarks/pyproject.toml

Lines changed: 0 additions & 49 deletions
This file was deleted.

cmake/hipify.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from torch.utils.hipify.hipify_python import hipify
1818

19-
if __name__ == '__main__':
19+
if __name__ == "__main__":
2020
parser = argparse.ArgumentParser()
2121

2222
# Project directory where all the source + include files live.
@@ -34,15 +34,14 @@
3434
)
3535

3636
# Source files to convert.
37-
parser.add_argument("sources",
38-
help="Source files to hipify.",
39-
nargs="*",
40-
default=[])
37+
parser.add_argument(
38+
"sources", help="Source files to hipify.", nargs="*", default=[]
39+
)
4140

4241
args = parser.parse_args()
4342

4443
# Limit include scope to project_dir only
45-
includes = [os.path.join(args.project_dir, '*')]
44+
includes = [os.path.join(args.project_dir, "*")]
4645

4746
# Get absolute path for all source files.
4847
extra_files = [os.path.abspath(s) for s in args.sources]
@@ -51,25 +50,31 @@
5150
# The directory might already exist to hold object files so we ignore that.
5251
shutil.copytree(args.project_dir, args.output_dir, dirs_exist_ok=True)
5352

54-
hipify_result = hipify(project_directory=args.project_dir,
55-
output_directory=args.output_dir,
56-
header_include_dirs=[],
57-
includes=includes,
58-
extra_files=extra_files,
59-
show_detailed=True,
60-
is_pytorch_extension=True,
61-
hipify_extra_files_only=True)
53+
hipify_result = hipify(
54+
project_directory=args.project_dir,
55+
output_directory=args.output_dir,
56+
header_include_dirs=[],
57+
includes=includes,
58+
extra_files=extra_files,
59+
show_detailed=True,
60+
is_pytorch_extension=True,
61+
hipify_extra_files_only=True,
62+
)
6263

6364
hipified_sources = []
6465
for source in args.sources:
6566
s_abs = os.path.abspath(source)
66-
hipified_s_abs = (hipify_result[s_abs].hipified_path if
67-
(s_abs in hipify_result
68-
and hipify_result[s_abs].hipified_path is not None)
69-
else s_abs)
67+
hipified_s_abs = (
68+
hipify_result[s_abs].hipified_path
69+
if (
70+
s_abs in hipify_result
71+
and hipify_result[s_abs].hipified_path is not None
72+
)
73+
else s_abs
74+
)
7075
hipified_sources.append(hipified_s_abs)
7176

72-
assert (len(hipified_sources) == len(args.sources))
77+
assert len(hipified_sources) == len(args.sources)
7378

7479
# Print hipified source files.
7580
print("\n".join(hipified_sources))

csrc/cutlass_extensions/vllm_cutlass_library_extension.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ class MixedInputKernelScheduleType(enum.Enum):
2727
**{
2828
VLLMDataType.u4b8: "u4b8",
2929
VLLMDataType.u8b128: "u8b128",
30-
}
30+
},
3131
}
3232

3333
VLLMDataTypeTag: dict[Union[VLLMDataType, DataType], str] = {
3434
**DataTypeTag, # type: ignore
3535
**{
3636
VLLMDataType.u4b8: "cutlass::vllm_uint4b8_t",
3737
VLLMDataType.u8b128: "cutlass::vllm_uint8b128_t",
38-
}
38+
},
3939
}
4040

4141
VLLMDataTypeSize: dict[Union[VLLMDataType, DataType], int] = {
4242
**DataTypeSize, # type: ignore
4343
**{
4444
VLLMDataType.u4b8: 4,
4545
VLLMDataType.u8b128: 8,
46-
}
46+
},
4747
}
4848

4949
VLLMDataTypeVLLMScalarTypeTag: dict[Union[VLLMDataType, DataType], str] = {
@@ -67,15 +67,13 @@ class MixedInputKernelScheduleType(enum.Enum):
6767
DataType.f32: "at::ScalarType::Float",
6868
}
6969

70-
VLLMKernelScheduleTag: dict[Union[
71-
MixedInputKernelScheduleType, KernelScheduleType], str] = {
72-
**KernelScheduleTag, # type: ignore
73-
**{
74-
MixedInputKernelScheduleType.TmaWarpSpecialized:
75-
"cutlass::gemm::KernelTmaWarpSpecialized",
76-
MixedInputKernelScheduleType.TmaWarpSpecializedPingpong:
77-
"cutlass::gemm::KernelTmaWarpSpecializedPingpong",
78-
MixedInputKernelScheduleType.TmaWarpSpecializedCooperative:
79-
"cutlass::gemm::KernelTmaWarpSpecializedCooperative",
80-
}
81-
}
70+
VLLMKernelScheduleTag: dict[
71+
Union[MixedInputKernelScheduleType, KernelScheduleType], str
72+
] = {
73+
**KernelScheduleTag, # type: ignore
74+
**{
75+
MixedInputKernelScheduleType.TmaWarpSpecialized: "cutlass::gemm::KernelTmaWarpSpecialized",
76+
MixedInputKernelScheduleType.TmaWarpSpecializedPingpong: "cutlass::gemm::KernelTmaWarpSpecializedPingpong",
77+
MixedInputKernelScheduleType.TmaWarpSpecializedCooperative: "cutlass::gemm::KernelTmaWarpSpecializedCooperative",
78+
},
79+
}

csrc/moe/marlin_moe_wna16/generate_kernels.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,30 @@
1717
namespace MARLIN_NAMESPACE_NAME {
1818
""".strip()
1919

20-
TEMPLATE = ("template __global__ void Marlin<"
21-
"{{scalar_t}}, "
22-
"{{w_type_id}}, "
23-
"{{s_type_id}}, "
24-
"{{threads}}, "
25-
"{{thread_m_blocks}}, "
26-
"{{thread_n_blocks}}, "
27-
"{{thread_k_blocks}}, "
28-
"{{'true' if m_block_size_8 else 'false'}}, "
29-
"{{stages}}, "
30-
"{{group_blocks}}, "
31-
"{{'true' if is_zp_float else 'false'}}>"
32-
"( MARLIN_KERNEL_PARAMS );")
20+
TEMPLATE = (
21+
"template __global__ void Marlin<"
22+
"{{scalar_t}}, "
23+
"{{w_type_id}}, "
24+
"{{s_type_id}}, "
25+
"{{threads}}, "
26+
"{{thread_m_blocks}}, "
27+
"{{thread_n_blocks}}, "
28+
"{{thread_k_blocks}}, "
29+
"{{'true' if m_block_size_8 else 'false'}}, "
30+
"{{stages}}, "
31+
"{{group_blocks}}, "
32+
"{{'true' if is_zp_float else 'false'}}>"
33+
"( MARLIN_KERNEL_PARAMS );"
34+
)
3335

3436
# int8 with zero point case (vllm::kU8) is also supported,
3537
# we don't add it to reduce wheel size.
3638
SCALAR_TYPES = [
37-
"vllm::kU4", "vllm::kU4B8", "vllm::kU8B128", "vllm::kFE4M3fn",
38-
"vllm::kFE2M1f"
39+
"vllm::kU4",
40+
"vllm::kU4B8",
41+
"vllm::kU8B128",
42+
"vllm::kFE4M3fn",
43+
"vllm::kFE2M1f",
3944
]
4045
THREAD_CONFIGS = [(128, 128, 256), (64, 256, 256), (64, 128, 128)]
4146

@@ -58,11 +63,12 @@ def generate_new_kernels():
5863
all_template_str_list = []
5964

6065
for group_blocks, m_blocks, thread_configs in itertools.product(
61-
GROUP_BLOCKS, THREAD_M_BLOCKS, THREAD_CONFIGS):
62-
66+
GROUP_BLOCKS, THREAD_M_BLOCKS, THREAD_CONFIGS
67+
):
6368
# act order case only support gptq-int4 and gptq-int8
6469
if group_blocks == 0 and scalar_type not in [
65-
"vllm::kU4B8", "vllm::kU8B128"
70+
"vllm::kU4B8",
71+
"vllm::kU8B128",
6672
]:
6773
continue
6874
if thread_configs[2] == 256:

0 commit comments

Comments
 (0)