@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 05972ea7e5
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 7, 16:30 UTC

[Refactor] Remove dead or duplicate func utils or variables (#35318)

Signed-off-by: yewentao256 <zhyanwentao@126.com>

Wentao Ye committed Feb 26, 2026 at 10:57 UTC 05972ea7e5f81250cc4ceaae8a174cfffe7755ac
9 files changed -199
benchmarks/backend_request_func.py
-6
@@ -649,9 +649,3 @@ ASYNC_REQUEST_FUNCS = {
649 "sglang": async_request_openai_completions,
650 "llama.cpp": async_request_openai_completions,
651 }
652 -
653 -OPENAI_COMPATIBLE_BACKENDS = [
654 - k
655 - for k, v in ASYNC_REQUEST_FUNCS.items()
656 - if v in (async_request_openai_completions, async_request_openai_chat_completions)
657 -]
benchmarks/benchmark_utils.py
-71
@@ -1,78 +1,7 @@
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -import argparse
4 -import json
5 -import math
6 -import os
3 import time
4 from types import TracebackType
9 -from typing import Any
10 -
11 -
12 -def convert_to_pytorch_benchmark_format(
13 - args: argparse.Namespace, metrics: dict[str, list], extra_info: dict[str, Any]
14 -) -> list:
15 - """
16 - Save the benchmark results in the format used by PyTorch OSS benchmark with
17 - on metric per record
18 - https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database
19 - """
20 - records = []
21 - if not os.environ.get("SAVE_TO_PYTORCH_BENCHMARK_FORMAT", False):
22 - return records
23 -
24 - for name, benchmark_values in metrics.items():
25 - record = {
26 - "benchmark": {
27 - "name": "vLLM benchmark",
28 - "extra_info": {
29 - "args": vars(args),
30 - },
31 - },
32 - "model": {
33 - "name": args.model,
34 - },
35 - "metric": {
36 - "name": name,
37 - "benchmark_values": benchmark_values,
38 - "extra_info": extra_info,
39 - },
40 - }
41 -
42 - tp = record["benchmark"]["extra_info"]["args"].get("tensor_parallel_size")
43 - # Save tensor_parallel_size parameter if it's part of the metadata
44 - if not tp and "tensor_parallel_size" in extra_info:
45 - record["benchmark"]["extra_info"]["args"]["tensor_parallel_size"] = (
46 - extra_info["tensor_parallel_size"]
47 - )
48 -
49 - records.append(record)
50 -
51 - return records
52 -
53 -
54 -class InfEncoder(json.JSONEncoder):
55 - def clear_inf(self, o: Any):
56 - if isinstance(o, dict):
57 - return {k: self.clear_inf(v) for k, v in o.items()}
58 - elif isinstance(o, list):
59 - return [self.clear_inf(v) for v in o]
60 - elif isinstance(o, float) and math.isinf(o):
61 - return "inf"
62 - return o
63 -
64 - def iterencode(self, o: Any, *args, **kwargs) -> Any:
65 - return super().iterencode(self.clear_inf(o), *args, **kwargs)
66 -
67 -
68 -def write_to_json(filename: str, records: list) -> None:
69 - with open(filename, "w") as f:
70 - json.dump(
71 - records,
72 - f,
73 - cls=InfEncoder,
74 - default=lambda o: f"<{type(o).__name__} object is not JSON serializable>",
75 - )
5
6
7 # Collect time and generate time metrics
benchmarks/cutlass_benchmarks/utils.py
-13
@@ -2,7 +2,6 @@
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 # Cutlass bench utils
5 -from collections.abc import Iterable
5
6 import torch
7
@@ -86,15 +85,3 @@ def make_rand_sparse_tensors(
85
86 # Compressed B, Metadata, Original A, B
87 return b_compressed, e, a, b
89 -
90 -
91 -def make_n_rand_sparse_tensors(
92 - num_tensors: int, dtype: torch.dtype, m: int, n: int, k: int
93 -) -> tuple[Iterable[torch.Tensor], Iterable[torch.Tensor]]:
94 - ABs = []
95 - for _ in range(num_tensors):
96 - b_comp, e, a, b = make_rand_sparse_tensors(dtype, m, n, k)
97 - if b_comp is not None:
98 - ABs.append(make_rand_sparse_tensors(dtype, m, n, k))
99 - BComps, Es, As, Bs = zip(*ABs)
100 - return list(BComps), list(Es), list(As), list(Bs)
benchmarks/disagg_benchmarks/rate_limiter.py deleted
-45
@@ -1,45 +0,0 @@
1 -# SPDX-License-Identifier: Apache-2.0
2 -# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -
4 -import asyncio
5 -import time
6 -
7 -
8 -class RateLimiter:
9 - """Token bucket rate limiter implementation"""
10 -
11 - def __init__(self, rate_limit):
12 - self.rate_limit = rate_limit # Requests per second
13 - self.num_available_tokens = rate_limit # Available tokens
14 - self.last_refill = time.monotonic() # Last token refill time
15 - self.lock = asyncio.Lock() # Synchronization lock
16 -
17 - async def acquire(self):
18 - """Acquire a token from the rate limiter"""
19 - while True:
20 - async with self.lock:
21 - current_time = time.monotonic()
22 - elapsed = current_time - self.last_refill
23 -
24 - # Refill num_available_tokens if more than 1 second has passed
25 - if elapsed > 1.0:
26 - self.num_available_tokens = self.rate_limit
27 - self.last_refill = current_time
28 -
29 - # Check if num_available_tokens are available
30 - if self.num_available_tokens > 0:
31 - self.num_available_tokens -= 1
32 - return True
33 -
34 - # Calculate wait time if no num_available_tokens available
35 - wait_time = 1.0 - elapsed
36 - await asyncio.sleep(wait_time)
37 -
38 - async def __aenter__(self):
39 - """Enter async context manager - acquire token"""
40 - await self.acquire()
41 - return self
42 -
43 - async def __aexit__(self, exc_type, exc_value, traceback):
44 - """Exit async context manager - no cleanup needed"""
45 - pass
benchmarks/disagg_benchmarks/request_queue.py deleted
-39
@@ -1,39 +0,0 @@
1 -# SPDX-License-Identifier: Apache-2.0
2 -# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -
4 -import asyncio
5 -from collections import deque
6 -
7 -
8 -class RequestQueue:
9 - """Request queue manager with concurrency control"""
10 -
11 - def __init__(self, max_concurrent, max_queue_size):
12 - # Maximum concurrent requests
13 - self.max_concurrent = max_concurrent
14 - self.max_queue_size = max_queue_size # Maximum queue size
15 - # Concurrency control
16 - self.semaphore = asyncio.Semaphore(max_concurrent)
17 - self.queue = deque() # Request queue
18 - self.queue_size = 0 # Current queue size
19 - self.lock = asyncio.Lock() # Sync queue Lock
20 -
21 - async def enqueue(self, task):
22 - """Add a request task to the queue"""
23 - async with self.lock:
24 - if self.queue_size >= self.max_queue_size:
25 - return False
26 -
27 - self.queue.append(task)
28 - self.queue_size += 1
29 - return True
30 -
31 - async def process(self):
32 - """Process queued requests using semaphore for concurrency control"""
33 - while True:
34 - if self.queue:
35 - async with self.semaphore, self.lock:
36 - task = self.queue.popleft()
37 - self.queue_size -= 1
38 - await task
39 - await asyncio.sleep(0.01) # Yield control to event loop
vllm/model_executor/layers/quantization/ptpc_fp8.py
-5
@@ -7,7 +7,6 @@ import torch
7 from torch.nn.parameter import Parameter
8
9 from vllm import _custom_ops as ops
10 -from vllm.logger import init_logger
10 from vllm.model_executor.kernels.linear import (
11 init_fp8_linear_kernel,
12 )
@@ -26,10 +25,6 @@ from vllm.model_executor.layers.quantization.utils.quant_utils import (
25 )
26 from vllm.platforms import current_platform
27
29 -ACTIVATION_SCHEMES = ["static", "dynamic"]
30 -
31 -logger = init_logger(__name__)
32 -
28
29 class PTPCFp8Config(Fp8Config):
30 """Config class for Per-Token-Per-Channel Dynamic Quantization Fp8."""
vllm/model_executor/layers/quantization/utils/marlin_utils.py
-18
@@ -255,18 +255,6 @@ def marlin_moe_intermediate_size(w1_packed: torch.Tensor, w2_packed: torch.Tenso
255 return w2_packed.size(1) * marlin_tile_size
256
257
258 -def marlin_make_workspace(
259 - output_size_per_partition: int, device: torch.device
260 -) -> torch.Tensor:
261 - max_workspace_size = (
262 - output_size_per_partition // GPTQ_MARLIN_MIN_THREAD_N
263 - ) * GPTQ_MARLIN_MAX_PARALLEL
264 -
265 - return torch.zeros(
266 - max_workspace_size, dtype=torch.int, device=device, requires_grad=False
267 - )
268 -
269 -
258 def marlin_make_workspace_new(
259 device: torch.device, max_blocks_per_sm: int = 1
260 ) -> torch.Tensor:
@@ -297,12 +285,6 @@ def marlin_make_empty_g_idx(device: torch.device) -> torch.Tensor:
285 )
286
287
300 -def marlin_make_empty_zp(device: torch.device) -> torch.Tensor:
301 - return torch.nn.Parameter(
302 - torch.empty(0, dtype=torch.int, device=device), requires_grad=False
303 - )
304 -
305 -
288 def marlin_sort_g_idx(g_idx: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
289 g_idx_sort_indices = torch.argsort(g_idx).to(torch.int)
290 return g_idx[g_idx_sort_indices], g_idx_sort_indices
vllm/model_executor/models/hyperclovax_vision.py
-1
@@ -49,7 +49,6 @@ from .utils import (
49 )
50 from .vision import get_vision_encoder_info
51
52 -EOT = "<|endofturn|>"
52 IMAGE_TOKEN: str = "<|dummy3|>"
53 VIDEO_TOKEN: str = "<|_unuse_missing_100270|>"
54
vllm/v1/engine/core.py
-1
@@ -72,7 +72,6 @@ from vllm.version import __version__ as VLLM_VERSION
72
73 logger = init_logger(__name__)
74
75 -POLLING_TIMEOUT_S = 2.5
75 HANDSHAKE_TIMEOUT_MINS = 5
76
77 _R = TypeVar("_R") # Return type for collective_rpc