@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 93dc5a2870
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 17, 04:15 UTC

chore(vllm): codespell for spell checking (#2820)

Massimiliano Pronesti committed Feb 22, 2024 at 02:56 UTC 93dc5a287086299a124e9f1f6fac75458ae0acbd
16 files changed +85 -25
.github/workflows/ruff.yml
+4 -1
@@ -25,7 +25,10 @@ jobs:
25 - name: Install dependencies
26 run: |
27 python -m pip install --upgrade pip
28 - pip install ruff==0.1.5
28 + pip install ruff==0.1.5 codespell==2.2.6 tomli==2.0.1
29 - name: Analysing the code with ruff
30 run: |
31 ruff vllm tests
32 + - name: Spelling check with codespell
33 + run: |
34 + codespell --toml pyproject.toml
\ No newline at end of file
benchmarks/benchmark_serving.py
+1 -1
@@ -375,7 +375,7 @@ if __name__ == "__main__":
375 parser.add_argument(
376 "--disable-tqdm",
377 action="store_true",
378 - help="Specify to disbale tqdm progress bar.",
378 + help="Specify to disable tqdm progress bar.",
379 )
380 parser.add_argument(
381 "--save-result",
format.sh
+48 -3
@@ -24,6 +24,7 @@ builtin cd "$ROOT" || exit 1
24 YAPF_VERSION=$(yapf --version | awk '{print $2}')
25 RUFF_VERSION=$(ruff --version | awk '{print $2}')
26 MYPY_VERSION=$(mypy --version | awk '{print $2}')
27 +CODESPELL_VERSION=$(codespell --version)
28
29 # # params: tool name, tool version, required version
30 tool_version_check() {
@@ -36,6 +37,7 @@ tool_version_check() {
37 tool_version_check "yapf" $YAPF_VERSION "$(grep yapf requirements-dev.txt | cut -d'=' -f3)"
38 tool_version_check "ruff" $RUFF_VERSION "$(grep "ruff==" requirements-dev.txt | cut -d'=' -f3)"
39 tool_version_check "mypy" "$MYPY_VERSION" "$(grep mypy requirements-dev.txt | cut -d'=' -f3)"
40 +tool_version_check "codespell" "$CODESPELL_VERSION" "$(grep codespell requirements-dev.txt | cut -d'=' -f3)"
41
42 YAPF_FLAGS=(
43 '--recursive'
@@ -93,6 +95,47 @@ echo 'vLLM yapf: Done'
95 # echo 'vLLM mypy:'
96 # mypy
97
98 +# check spelling of specified files
99 +spell_check() {
100 + codespell "$@"
101 +}
102 +
103 +spell_check_all(){
104 + codespell --toml pyproject.toml
105 +}
106 +
107 +# Spelling check of files that differ from main branch.
108 +spell_check_changed() {
109 + # The `if` guard ensures that the list of filenames is not empty, which
110 + # could cause ruff to receive 0 positional arguments, making it hang
111 + # waiting for STDIN.
112 + #
113 + # `diff-filter=ACM` and $MERGEBASE is to ensure we only lint files that
114 + # exist on both branches.
115 + MERGEBASE="$(git merge-base origin/main HEAD)"
116 +
117 + if ! git diff --diff-filter=ACM --quiet --exit-code "$MERGEBASE" -- '*.py' '*.pyi' &>/dev/null; then
118 + git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.py' '*.pyi' | xargs \
119 + codespell
120 + fi
121 +}
122 +
123 +# Run Codespell
124 +## This flag runs spell check of individual files. --files *must* be the first command line
125 +## arg to use this option.
126 +if [[ "$1" == '--files' ]]; then
127 + spell_check "${@:2}"
128 + # If `--all` is passed, then any further arguments are ignored and the
129 + # entire python directory is linted.
130 +elif [[ "$1" == '--all' ]]; then
131 + spell_check_all
132 +else
133 + # Check spelling only of the files that changed in last commit.
134 + spell_check_changed
135 +fi
136 +echo 'vLLM codespell: Done'
137 +
138 +
139 # Lint specified files
140 lint() {
141 ruff "$@"
@@ -117,9 +160,9 @@ lint_changed() {
160 }
161
162 # Run Ruff
120 -echo 'vLLM Ruff:'
121 -## This flag lints individual files. --files *must* be the first command line
122 -## arg to use this option.
163 +echo 'vLLM ruff:'
164 +### This flag lints individual files. --files *must* be the first command line
165 +### arg to use this option.
166 if [[ "$1" == '--files' ]]; then
167 lint "${@:2}"
168 # If `--all` is passed, then any further arguments are ignored and the
@@ -139,3 +182,5 @@ if ! git diff --quiet &>/dev/null; then
182
183 exit 1
184 fi
185 +
186 +
mypy.ini deleted
-8
@@ -1,8 +0,0 @@
1 -[mypy]
2 -python_version = 3.8
3 -
4 -ignore_missing_imports = True
5 -
6 -files = vllm
7 -# TODO(woosuk): Include the code from Megatron and HuggingFace.
8 -exclude = vllm/model_executor/parallel_utils/|vllm/model_executor/models/
pyproject.toml
+18
@@ -31,4 +31,22 @@ ignore = [
31 "E731",
32 # line too long, handled by black formatting
33 "E501",
34 + # .strip() with multi-character strings
35 + "B005",
36 + # Loop control variable not used within loop body
37 + "B007",
38 ]
39 +
40 +[tool.mypy]
41 +python_version = "3.8"
42 +
43 +ignore_missing_imports = true
44 +
45 +files = "vllm"
46 +# TODO(woosuk): Include the code from Megatron and HuggingFace.
47 +exclude = "vllm/model_executor/parallel_utils/|vllm/model_executor/models/"
48 +
49 +
50 +[tool.codespell]
51 +ignore-words-list = "dout, te, indicies"
52 +skip = "./tests/prompts"
requirements-dev.txt
+2
@@ -1,7 +1,9 @@
1 # formatting
2 yapf==0.32.0
3 toml==0.10.2
4 +tomli==2.0.1
5 ruff==0.1.5
6 +codespell==2.2.6
7
8 # type checking
9 mypy==0.991
tests/lora/test_layers.py
+1 -1
@@ -279,7 +279,7 @@ def test_embeddings_with_new_embeddings(dist_init, num_loras, device) -> None:
279 256,
280 org_num_embeddings=512)
281 expanded_embedding.weight.data[:512, :] = embedding_data
282 - # We need to deepcopy the embedding as it will be modifed
282 + # We need to deepcopy the embedding as it will be modified
283 # in place
284 lora_embedding = VocabParallelEmbeddingWithLoRA(
285 deepcopy(expanded_embedding))
tests/lora/test_llama.py
+2 -2
@@ -15,7 +15,7 @@ def do_sample(llm, lora_path: str, lora_id: int):
15 "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_95 (one_mora VARCHAR, gloss VARCHAR, accented_mora VARCHAR)\n\n question: What is the one mora for a low tone mora with a gloss of /˩okiru/ [òkìɽɯ́]? [/user] [assistant]",
16 "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE candidate (people_id VARCHAR, unsure_rate INTEGER); CREATE TABLE people (sex VARCHAR, people_id VARCHAR)\n\n question: which gender got the highest average uncertain ratio. [/user] [assistant]",
17 "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_60 (pick INTEGER, former_wnba_team VARCHAR)\n\n question: What pick was a player that previously played for the Minnesota Lynx? [/user] [assistant]",
18 - "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the womens doubles for werner schlager [/user] [assistant]"
18 + "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the women's doubles for werner schlager [/user] [assistant]"
19 ]
20 sampling_params = vllm.SamplingParams(temperature=0,
21 max_tokens=256,
@@ -53,7 +53,7 @@ def test_llama_lora(sql_lora_files, tp_size):
53 "\n\n answer: 1\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_96 (one_mora VARCHAR, gloss VARCHAR, accented_mora VARCHAR)\n\n question: What is the one mora for a high tone mora with a gloss of /˧kot/ [kòt]? [/user] [assistant]\n\n answer: 2\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_97 (one_mora VARCHAR, gloss VARCHAR, accented_mora VARCHAR)\n\n question: What is the one mora for a high tone mora with a gloss of /˧kot/ [kòt]? [/user] [assistant]\n\n answer: 2\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_98 (one_mora VARCHAR, gloss VARCHAR, accented_mora VARCHAR)\n\n question: What is the one m",
54 " Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE candidate (people_id VARCHAR, unsure_rate INTEGER); CREATE TABLE people (sex VARCHAR, people_id VARCHAR)\n\n question: which gender got the highest average uncertain ratio. ",
55 " Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_60 (pick INTEGER, former_wnba_team VARCHAR)\n\n question: What pick was a player that previously played for the Minnesota Lynx? ",
56 - "\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the womens doubles for werner schlager [/user] [assistant]\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the womens doubles for werner schlager [/user] [assistant]\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the womens doubles for werner schlager [/user] [assistant]\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE",
56 + "\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the women's doubles for werner schlager [/user] [assistant]\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the women's doubles for werner schlager [/user] [assistant]\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_28138035_4 (womens_doubles VARCHAR, mens_singles VARCHAR)\n\n question: Name the women's doubles for werner schlager [/user] [assistant]\n\n [user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE",
57 ]
58 expected_lora_output = [
59 " SELECT icao FROM table_name_74 WHERE airport = 'lilongwe international airport' ",
vllm/core/block_manager.py
+1 -1
@@ -178,7 +178,7 @@ class BlockSpaceManager:
178 if len(block_table) < len(logical_blocks):
179 if (self.block_sliding_window
180 and len(block_table) >= self.block_sliding_window):
181 - # re-use a block
181 + # reuse a block
182 block_table.append(block_table[len(block_table) %
183 self.block_sliding_window])
184 else:
vllm/core/scheduler.py
+1 -1
@@ -158,7 +158,7 @@ class Scheduler:
158 return len(self.waiting) + len(self.running) + len(self.swapped)
159
160 def _schedule(self) -> SchedulerOutputs:
161 - # Blocks that need to be swaped or copied before model execution.
161 + # Blocks that need to be swapped or copied before model execution.
162 blocks_to_swap_in: Dict[int, int] = {}
163 blocks_to_swap_out: Dict[int, int] = {}
164 blocks_to_copy: Dict[int, List[int]] = {}
vllm/lora/punica.py
+1 -1
@@ -87,7 +87,7 @@ def add_lora(y: torch.Tensor,
87 r = wb_t_all.size(-1)
88 if buffer is None:
89 # We set the buffer to be float32 by default to avoid
90 - # numerical innacuracies that would otherwise happen
90 + # numerical inaccuracies that would otherwise happen
91 # due to downcasting.
92 buffer = torch.zeros((x.size(0), r),
93 dtype=torch.float32,
vllm/model_executor/layers/triton_kernel/prefix_prefill.py
+1 -1
@@ -537,7 +537,7 @@ if triton.__version__ >= "2.1.0":
537 alibi_start_q = tl.arange(
538 0, BLOCK_M) + block_start_loc + cur_batch_ctx_len
539 alibi_start_k = cur_batch_ctx_len
540 - # # init debuger
540 + # # init debugger
541 # offset_db_q = tl.arange(0, BLOCK_M) + block_start_loc
542 # offset_db_k = tl.arange(0, BLOCK_N)
543 # calc q[BLOCK_M, BLOCK_MODEL] mul k[prefix_len: , BLOCK_DMODEL]
vllm/model_executor/models/decilm.py
+1 -1
@@ -41,7 +41,7 @@ class DeciLMForCausalLM(LlamaForCausalLM):
41 Based on the llama executor.
42
43 The main difference is that DeciLM uses Variable Grouped Query Attention.
44 - The constant number of GQA heads in the decoder is overriden with a value
44 + The constant number of GQA heads in the decoder is overridden with a value
45 per layer.
46
47 Usually, in the HuggingFace implementation, instead of
vllm/model_executor/parallel_utils/custom_all_reduce.py
+2 -2
@@ -36,14 +36,14 @@ def init_custom_ar() -> None:
36 if world_size not in _SUPPORTED_WORLD_SIZES:
37 logger.warn(
38 "Custom allreduce is disabled due to an unsupported world size: "
39 - "%d. Supported world sizes: %s. To slience this warning, specify"
39 + "%d. Supported world sizes: %s. To silence this warning, specify"
40 "disable_custom_all_reduce=True explicitly.", world_size,
41 str(_SUPPORTED_WORLD_SIZES))
42 return
43 if not _can_p2p(rank, world_size):
44 logger.warn(
45 "Custom allreduce is disabled because your platform lacks GPU P2P"
46 - " capability. To slience this warning, specify"
46 + " capability. To silence this warning, specify"
47 "disable_custom_all_reduce=True explicitly.")
48 return
49 _CA_HANDLE = CustomAllreduce(rank, world_size)
vllm/model_executor/parallel_utils/parallel_state.py
+1 -1
@@ -189,7 +189,7 @@ def get_pipeline_model_parallel_next_rank():
189
190
191 def get_pipeline_model_parallel_prev_rank():
192 - """Return the global rank that preceeds the caller in the pipeline"""
192 + """Return the global rank that precedes the caller in the pipeline"""
193 assert _PIPELINE_GLOBAL_RANKS is not None, (
194 "Pipeline parallel group is not initialized")
195 rank_in_pipeline = get_pipeline_model_parallel_rank()
vllm/utils.py
+1 -1
@@ -204,7 +204,7 @@ def _generate_random_fp8_e5m2(
204 # NOTE(zhaoyang): Due to NaN and Inf representation for fp8 data type,
205 # it may occur Inf or NaN if we directly use torch.randint
206 # to generate random data for fp8 data.
207 - # For example, s.11111.00 in fp8e5m2 format repesents Inf.
207 + # For example, s.11111.00 in fp8e5m2 format represents Inf.
208 # | E4M3 | E5M2
209 #-----|-------------|-------------------
210 # Inf | N/A | s.11111.00